参考教程
学习记录
在这篇开始,我们首先需要纠正上一篇部分的错误之处,在上一篇我们渲染到纹理的时候,渲染了一张 200 x 200 的纹理,然后使用的还是我们之前渲染 1920 x 1080 后缓冲用的深度缓冲,所以会出现错误,错误信息如下:
D3D11 ERROR: ID3D11DeviceContext::OMSetRenderTargets: The RenderTargetView at slot 0 is not compatible with the DepthStencilView. DepthStencilViews may only be used with RenderTargetViews if the effective dimensions of the Views are equal, as well as the Resource types, multisample count, and multisample quality. The RenderTargetView at slot 0 has (w:200,h:200,as:1), while the Resource is a Texture2D with (mc:1,mq:0). The DepthStencilView has (w:1920,h:1080,as:1), while the Resource is a Texture2D with (mc:1,mq:0). [ STATE_SETTING ERROR #388: OMSETRENDERTARGETS_INVALIDVIEW]
如果我们确实需要渲染不同的视图,那么需要创建不同的深度模板使用,如上。
这一篇中,我们主要学习在 D3D11 中实现雾效果。