This talks about some topics we need to know before designing our rendering engine, and it describes the graphics pipeline how to handle 3D objects drawing.
21. Vertices mapped from object space to world
space
M = model transformation (scene)
V = view transformation (camera)
21
X’
Y’
Z’
W’
X
Y
Z
1M *V *
22. Operate on a vertex to transform it into the
viewport space
The viewport is two-dimensional: however,
vertex z-value is retained for depth testing.
22
23. All primitives are now converted to
fragments.
Data type change !Vertices to fragments
The rasterizer produces a stream of
fragments.
23
Fragment attributes:
(r,g,b,a)
(x,y,z,w)
(tx,ty), …
24. 24
Color R G B A
Position X Y Z W
Texture
coordinates
X Y [Z] -
Texture
coordinates
X Y [Z] -
…
Interpolated from
vertex information
X Y Z W
Input: Fragment
Attributes
25. Color(v) = emissive + ambient + diffuse +
specular
Each term in the right hand side is a function
of the vertex color, position, normal and
material properties.
25
26. Each fragment undergoes a series of tests.
Scissor
Alpha
Stencil
Depth
26
27. Blending: pixels are accumulated into final
framebuffer storage
new-val = pixel-value op old-val
new-val = SrcColor * A + DstColor * B
27
29. Lock index buffer, vertex buffer, texture
Create device, index buffer, vertex buffer,
texture
Destroy device, index buffer, vertex buffer,
texture
VaildateDevice
Present
Command buffer is full
Query::GetData
29
30. Group similar material
Avoid redundant state change
Adv:
Reduce probability of full command buffer
Separate transparent / Opaque objects
30
31. Static / Dynamic type
Share buffer is better
Large buffer is better
31