Game Development Reference
In-Depth Information
Of course, in order for this to work, Direct3D needs to know which
polygons are front facing and which are back facing. By default,
Direct3D treats triangles with vertices specified in a clockwise winding
order (in view space) as front facing. Triangles with vertices specified in
counterclockwise winding orders (in view space) are considered back
facing.
Note: Notice that we said in “view space.” This is because when a
triangle is rotated 180 degrees, its winding order is flipped. Thus, a tri-
angle that had a clockwise winding order when it was defined in its
local space might not have a clockwise winding order when it's trans-
formed to view space due to possible rotations.
If for some reason we are not happy with the default culling behavior,
we can change it by changing the D3DRS_CULLMODE render state.
Device->SetRenderState(D3DRS_CULLMODE, Value);
where Value can be one of the following:
D3DCULL_NONE —Disables back face culling entirely
D3DCULL_CW —Triangles with a clockwise wind are culled.
D3DCULL_CCW —Triangles with a counterclockwise wind are
culled. This is the default state.
2.3.5 Lighting
Light sources are defined in world space but transformed into view
space by the view space transformation. In view space these light
sources are applied to light the objects in the scene to give a more real-
istic appearance. Lighting in the fixed function pipeline is covered in
detail in Chapter 5. Later in Part IV of this topic, we implement our
own lighting scheme using the programmable pipeline.
2.3.6 Clipping
At this point we need to cull the geometry that is outside the viewing
volume; this process is called clipping . There are three locations where
a triangle can be with regards to the frustum.
Completely inside—If the triangle is completely inside the
frustum, it is kept and will move onto the next stage.
Completely outside—If the triangle is completely outside the
frustum, it is culled.
Partially inside (partially outside)—If the triangle is partially inside
and partially outside the frustum, the triangle is split into two
Search WWH ::




Custom Search