[GGP] 4. Input Assembler & Vertex Processing (1)

Cherish·2023년 6월 2일

Game Graphic Programming

목록 보기
3/14
post-thumbnail

☁️ Direct3D 12 graphics Pipeline

  • 아래와 같은 구조의 pipeline을 통해 GPU는 rendering을 한다.
  • 전체 pipeline을 frame 마다 수행
  • 한 스테이지의 output은 다음 stage의 input이 된다.
  • Shader : program
  • Input assembler, Tessellator, Rasterizer, Output merger : hard-wired(역할, 목적이 고정되어있는) stage이다. 고정된 함수만 사용하여 일을 수행



☁️ Input-Assembler Stage (IA)

produce primitives or patches

  • user-specified buffer(vertex, index buffer)에서 vertex 정보를 read한다.
  • vertex 정보들을 primitive(도형 - 삼각형, 선 등) 단위로 묶는 역할을 한다.
  • user들은 primitive type를 정할 수 있다. IASetPrimitiveTopolgy(data를 어떻게 자를 건지)를 이용.

🔎 용어
primitive = basic shapes (triangles, lines, points)
view = 구조체



☁️ Vertex Shader


🔎 Shader

  • 프로그래밍 가능한 영역 (programmable)
  • floating point 연산이 배우 빠르다
  • 특정 program guideline(ex. input output structure)에 맞게 디자인 되어야 함.
  • 5 type 있음 (Vertex, Hull, Domain, Geometry, Pixel )
  • vertex shader : 생략 불가능
  • pixel shader : 생략 가능
  • DirectX : HLSL / OpenGL : GLSL

🔎 Vertex Shader

  • Input : vertex specifications
  • vertex specifications : input-assembler에서 vertex,index buffer를 통해 제공된다.
  • 각 vertex 마다 한번씩 동작한다.
  • 보통 input vetex들의 최종 position을 계산하는데 사용된다.
  • GPU는 for문이 안좋다 - dependancy 때문에 성능이 저하될 수 있음
  • Vertex 위치 정보 변환 과정


🔎 Spaces

📁 Object space

  • 오브젝트 내에서의 위치
  • 오브젝트에 따라 axes가 바뀐다
  • = model space

📁 World space

  • 3D World space에서의 위치

📁 Camera space

  • Camera를 중점으로 한 상대좌표
  • world space coordinate가 target camera를 기준으로 다시 계산된다.
  • = eye space

📁 Clip space

  • camera space에서 projection transform을 한 것

🔎 World Transform

  • 오브젝트 각각의 object space에 정의되어있는 것들을 world space로 옮겨준다.
  • World Matrix = [Lt][L|t]
  • L = combined linear transform
  • t = combined translation


📁 Object Space vs World Space

  • object space는 model들 끼리는 no relationship
  • World transform : 모든 model들을 assemble -> 하나의 coordinate system으로 합치는 것

📁 Vertex Normal
[Lt][L|t] 에서 L에만 영향을 받는다.
if L이 non-uniform scaling을 포함한다면 surface normal에는 적용이 되지 않을 수도 있다.
아래처럼 normal이 이상한 것을 볼 수 있음

대신, L의 inverse transpose (L1)T(L^-1)^T 를 쓰자.
L이 non-uniform scaling을 갖고있던 말던 그냥 L^-T를 쓰자.


🔎 View Transform

📁 Camera pose specification

  • EYE : camera position
  • AT : camera가 aimed 중인 point
  • UP : camera의 위를 가리키는 vector (일반적으로 vertical axis, y axis로 set)
  • 카메라의 좌표계
    u,v,n은 서로 직교하며 크기가 1이다
  1. EYE를 world space의 원점으로 translation

  2. Rotation

  3. 결론
    M = view Matrix


🔎 CPU vs GPU

CPU : int연산이 빠르다
GPU : floating point 연산이 빠르다. 벡터 계산에 유리



















0개의 댓글