Game Development Reference
In-Depth Information
'
behind every other object. Here
s the helper class that sets the ID3DDeviceContext
for rendering a skybox:
D3DRendererSkyBoxPass11::D3DRendererSkyBoxPass11()
{
// Depth stencil state
D3D11_DEPTH_STENCIL_DESC DSDesc;
ZeroMemory( &DSDesc, sizeof( D3D11_DEPTH_STENCIL_DESC ) );
DSDesc.DepthEnable = TRUE;
DSDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
DSDesc.DepthFunc = D3D11_COMPARISON_LESS;
DSDesc.StencilEnable = FALSE;
DXUTGetD3D11Device()->CreateDepthStencilState(&DSDesc,
&m_pSkyboxDepthStencilState );
DXUT_SetDebugName( m_pSkyboxDepthStencilState,
SkyboxDepthStencil
);
UINT StencilRef;
DXUTGetD3D11DeviceContext()->OMGetDepthStencilState(
&m_pOldDepthStencilState, &StencilRef );
DXUTGetD3D11DeviceContext()->OMSetDepthStencilState(
m_pSkyboxDepthStencilState, 0 );
}
D3DRendererSkyBoxPass11::~D3DRendererSkyBoxPass11()
{
DXUTGetD3D11DeviceContext()->OMSetDepthStencilState(
m_pOldDepthStencilState, 0 );
SAFE_RELEASE(m_pOldDepthStencilState);
SAFE_RELEASE(m_pSkyboxDepthStencilState);
}
The goal for the skybox is to simulate drawing in the far background, without actu-
ally being in the far background. This little trick requires changing the depth stencil
settings to draw the polygons of the sky without affecting the current Z values of the
display buffer. Depth stencil state, just like blending states, has a wide range of cool
effects you can create, this being but one very simple one.
A Simple Camera
You
ll need a camera if you want to take pictures, right? The camera in a 3D scene
inherits from SceneNode just like everything else and adds some data members to
keep track of its viewable area, the projection matrix, and perhaps a target scene node
that it will follow around:
'
class CameraNode : public SceneNode
{
 
 
Search WWH ::




Custom Search