If I want to clear an entire depth/stencil view in Direct3D 11, I can easily call ID3D11DeviceContext::ClearDepthStencilView
.
Direct3D 11.1 adds support for clearing rectangular portions of render target views using ID3D11DeviceContext1::ClearView
.
But I see no way to clear only a portion of a depth/stencil view in Direct3D 11, short of rendering a quad over the desired area? This seems like an odd regression from Direct3D 9, where this was trivially easy. Am I missing something, or is this really not supported?
There is no such function that can clear only a part of depth/stencil view. This is my way to solve the problem:
AlphaTest
, only the pixel whose alpha is 1.AlphaBlend
,set BlendOP
to Add
,set SrcBlend
factor to 0,set DestBlend
factor to 1. StencilTest
and DepthTest
to Always
, set StencilRef
to the value you want to clear.