Graphics Reference
In-Depth Information
application in a constant buffer. 9 In addition, any vertex attributes that are sensitive to the
model's coordinate system must also be transformed into the new coordinate system with
a similar matrix multiplication. Both the position of the vertices and their normal vector
define the physical representation of the model, which is modified by the transformation
matrices. By performing this calculation in the vertex shader, we can be certain that all
of the model's geometry will be converted to the desired coordinate space before further
processing is performed further down the pipeline.
Another operation frequently performed in the vertex shader stage is vertex skin-
ning. 10 This performs a different type of coordinate transformation on a model, in which
bones are hierarchically linked to one another within a system of bones, and each vertex
is assigned to one or more bones. These bones move different parts of the model in differ-
ent ways, for example, to simulate how your bones move your skin when you move your
arm. Like the standard transformations example above, this operation modifies the physi-
cal structure of the model to provide the desired pose. It is also appropriate to perform this
operation in the vertex shader, before further processing.
Vertex Lighting
Geometric manipulation and vertex skinning can be efficiently performed in the vertex
shader, since they can be performed directly on the data that the vertices represent—the
physical shape, structure, orientation, and location of the geometry being rendered. Of
course, these are not the only types of operations that can be performed in a vertex shader.
Because this stage is programmable, many special types of processing can be performed in
the vertex shader and then passed to later stages. A common example of this type of opera-
tion is per-vertex lighting. Per-vertex lighting calculates the amount of light reflected from
a vertex, normally using some form of simplified lighting model (Hoxley). The lighting
data can be stored as a three- or four- component floating point attribute in the output ver-
tex format, where a value of 1.0 means that a full amount of the color is available and a 0.0
represents the complete absence of that color.
These per-vertex lighting values are passed down the pipeline and eventually arrive
at the rasterizer stage, which interpolates them as attributes between each vertex in the
primitive. These interpolated values are then applied to each pixel generated by the raster-
izer, and are eventually used to determine the final color written to the render target. By
performing these calculations in the vertex shader, lighting quantities are calculated only
at a sparse set of points (at the vertices), instead of at every pixel that a model generates.
The generated values are interpolated between the vertices, making the reduced resolution
of the calculation less noticeable, as long as the vertices are not too far apart on the screen.
9 A basic introduction to transformation matrices, as well as coordinate spaces, is provided in Chapter 8. "Mesh
Rendering."
1 0
Vertex skinning is also discussed in detail in Chapter 8, "Mesh Rendering."
Search WWH ::




Custom Search