
942 Chapter 20 Special Effects Using Shaders
but with stencil buffering enabled yet again, the only pixels blended with the shadow
color are those that were drawn with the plane. The stencil buffer only allows those
pixels to be touched. The remainder of the code is the restoration of rendering state
to what it was before the function call was made.
The projection matrix construction requires a small amount of mathematics.
The projection plane is implicit in the
TriMesh representation of the plane. We need
to know the equation of the plane in world coordinates. The
TriMesh::GetWorld-
Triangle
function call returns the three vertices of the first triangle ...