1

我正在从阴影贴图上的 DirectX SDK 示例中学习。这个示例在初始化期间创建了一个模板表面,并说:

 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.

这是什么意思?我试图评论创建和操作模板缓冲区的语句,然后我得到了相当不稳定的结果:如果我让窗口更大,阴影效果很好,而当我让窗口更小时,阴影停止移动。有人可以向我解释吗?非常感谢!!!

4

1 回答 1

2

Main DepthStencil 缓冲区是渲染到主窗口时使用的缓冲区,因此将具有与窗口相同的分辨率。然而,阴影过程不必使用相同的分辨率、视口等。这就是他们创建第二个 DepthStencil 缓冲区的原因,该缓冲区与用于渲染 Shadowmap 的视口具有相同的分辨率。

此外,正如引用所述,可能不希望使用与渲染场景相同的格式、多重采样设置等来创建阴影贴图。

编辑:

您使用模板缓冲区是因为您想存储最近的遮挡三角形的深度。

DepthStencil 缓冲区不“支持阴影映射”,它只是一种碰巧需要深度缓冲区的技术,最好具有某些属性(例如正确的大小,没有 MSAA 等)

于 2013-04-24T15:13:23.237 回答