Graphics Reference
In-Depth Information
Vertex Processing
There are many details of this fixed-function vertex pipeline process that must
be understood in terms of the hardware pipeline in order to work with shad-
ers. The first is probably the ModelView matrix , the matrix that implements the
ModelView transformation.
Whenever any vertex V is sent to the vertex processor, it is multiplied by
the ModelView matrix M as V ′ = M * V to convert it to eye space and begin its
processing.
The second detail of the vertex pipeline process is the role of the pro-
jection and viewport transformations. After vertices are transformed from
model space to eye space by applying the ModelView transformation, they
are further transformed by applying the projection transformation (set by the
functions glOrtho( ) , glFrustum( ) , or gluPerspective( ) ) into clip space ,
and the clipping is done by a separate operation. In fact, the ModelView and
Projection transformations are combined to create the ModelViewProjection
transformation that takes your model into clip space in one operation. The
name “clip space” is used because the projection transformation maps the ver-
tices into a coordinate space in which clipping is easily done. Finally, homoge-
neous division and the viewport transformation convert vertices in clip space
to their integer screen coordinates.
Why is the normal matrix the transpose of the inverse of the ModelView matrix? Let's
consider a normal vector N to a surface at a point P , and let's choose a point Q so that
the vector T = Q − P is tangent to the surface at P . Then N × T = 0 or, using matrix
multiplication, N T * T = 0 (recall that if vertices and normals are expressed as column
vectors, a transpose is a row vector, so this is a product of a 1 × 3 and a 3 × 1 matrix, or
a scalar). Then if we apply the transformation M so that P ′ = M * P and Q ′ = M * Q ,
the new tangent vector is T ′ = Q ′ − P ′ = M * Q M * P = M * ( Q P ) = M * T . Now
if we define N ′ to be the normal in the transformed space, ( N′ ) T * T must be zero. So
if R is the matrix that transforms the normal N to the new normal N ′, we have
0 = N′ T * T ′ = ( R * N ) T * T ′ = ( N T * R T ) * ( M * T ) = N T * ( R T * M ) * T .
Since N T * T = 0, the middle term R T * M must be the identity, so R T * M −1 and finally
R = ( M −1 ) T .
In fact, this process is less mysterious than it might seem, because if only rotation
is done, the matrix is orthonormal. One property of an orthonormal matrix is that its
inverse is equal to its transpose. In that case, the normal is transformed by the same
rotation that transforms the vertices.
Search WWH ::




Custom Search