Game Development Reference
In-Depth Information
This lets the root node have a very fine control over when each pass gets rendered and
even what special render states get set for each one:
HRESULT RootNode::VRenderChildren(Scene *pScene)
{
for (int pass = RenderPass_0; pass < RenderPass_Last; ++pass)
{
switch(pass)
{
case RenderPass_Static:
case RenderPass_Actor:
m_Children[pass]->VRenderChildren(pScene);
break;
case RenderPass_Sky:
{
D3DRendererSkyBoxPass11 skyBoxPass;
m_Children[pass]->VRenderChildren(pScene);
break;
}
}
}
return S_OK;
}
'
For static and dynamic actors, the root node doesn
t do anything special other than
draw them. The sky node needs a little extra attention since it is something that looks
infinitely far away, even though if you were to see it the way it actually existed in the
3D world, it would look like it was a box worn over the viewer
'
s head. That requires
a little Direct3D trickery.
The trickery involves changing the normal operation of the depth stencil, which is
also called a Z-buffer. When pixels are transformed into screen space, the X and Y
values map directly to the X and Y coordinates of the display. The Z value is set to
something that determines its depth into the scene as compared to the front and rear
clipping planes of the view frustum. Any pixel
in the scene will get covered
by one in the same location, but shallower. This gives the viewer the impression that
a 3D world really exists, even though it is projected onto a 2D screen, since every
pixel of every object sorts just the way it should.
The skybox is actually something that is geometrically small, like a box hovering
around the camera. But because it resets the depth stencil, it always looks like it is
deeper
Search WWH ::




Custom Search