Game Development Reference
In-Depth Information
Generating texture mapping coordinates procedurally. Examples in-
clude projected spot lights, Doom-style volumetric light, reflecting a
view vector about the normal for environment mapping, various fake
reflection techniques, scrolling or otherwise animated textures, and so
on.
Passing through raw vertex inputs without modification, if they are
already in the correct format and coordinate space.
If we are using Gouraud shading, we might actually perform the lighting
calculations here, and interpolate the lighting results. We'll show some
examples of this later in the chapter.
The transformation from modeling to clip space is the most common
operation, so let's review the process. We do it with matrix multiplication.
Conceptually, the vertices undergo a sequence of transformations as follows:
The model transform transforms from modeling space to world space.
The view transform transforms from world space to camera space.
The clip matrix is used to transform from camera space to clip space.
Conceptually, the matrix math is
v clip = ( v model )( M model→world )( M world→camera )( M camera→clip ).
In practice, we don't actually perform three separate matrix multiplica-
tions. We have one matrix that transforms from object space to clip space,
and inside the vertex shader we perform one matrix multiplication using
this matrix.
10.10.4
Clipping
After vertices have been transformed into clip space, two important tests
are performed on the triangle: clipping and culling. Both operations are
usually performed by the rendering API, so although you won't usually
have to perform these operations yourself, it's important to know how they
work. The order in which we discuss these tests is not necessarily the order
in which they will occur on a particular piece of hardware. Most hardware
culls in screen space, whereas older software renderers did it earlier, in 3D,
in order to reduce the number of triangles that had to be clipped.
Before we can project the vertices onto screen space, we must ensure
that they are completely inside the view frustum. This process is known
as clipping. Since clipping is normally performed by the hardware, we will
describe the process with only cursory detail.
 
Search WWH ::




Custom Search