|
发表于 2010-5-18 23:44:00
|
显示全部楼层
Re:为什么ShadowMap要是设置深度模板表面???
由于g_pDSShaodw是用于渲染深度图的深度缓冲,它与深度图的大小相同,而建立的窗口大小与深度图不同,因此在渲染深度图时,需要设置对应的深度缓冲区.
如果在建立窗口时将窗口设置的与深度图大小一样,都为512*512的话,就不会出错了.
这个在建立g_pDSShadow时有解释:
// Create the depth-stencil buffer to be used with the shadow map
// We do this to ensure that the depth-stencil buffer is large
// enough and has correct multisample type/quality when rendering
// the shadow map. The default depth-stencil buffer created during
// device creation will not be large enough if the user resizes the
// window to a very small size. Furthermore, if the device is created
// with multisampling, the default depth-stencil buffer will not
// work with the shadow map texture because texture render targets
// do not support multisample.
DXUTDeviceSettings d3dSettings = DXUTGetDeviceSettings();
V_RETURN( pd3dDevice->CreateDepthStencilSurface( ShadowMap_SIZE,
ShadowMap_SIZE,
d3dSettings.d3d9.pp.AutoDepthStencilFormat,
D3DMULTISAMPLE_NONE,
0,
TRUE,
&g_pDSShadow,
NULL ) );
|
|