i have following problem. I want to count my depth complexity and then render it with different colors
my approach was this depth_stencil_desc (but im not sure if it even is right)
D3D11_DEPTH_STENCIL_DESC colorDepth;
colorDepth.DepthEnable = true;
colorDepth.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
colorDepth.DepthFunc = D3D11_COMPARISON_LESS;
colorDepth.StencilEnable = true;
colorDepth.StencilReadMask = 0xff;
colorDepth.StencilWriteMask = 0xff;
colorDepth.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
colorDepth.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
colorDepth.FrontFace.StencilPassOp = D3D11_STENCIL_OP_INCR;
colorDepth.FrontFace.StencilFunc = D3D11_COMPARISON_EQUAL;
colorDepth.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
colorDepth.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
colorDepth.BackFace.StencilPassOp = D3D11_STENCIL_OP_INCR;
colorDepth.BackFace.StencilFunc = D3D11_COMPARISON_EQUAL;
and my draw depth_stencil_desc
D3D11_DEPTH_STENCIL_DESC drawDepth;
drawDepth.DepthEnable = true;
drawDepth.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
drawDepth.DepthFunc = D3D11_COMPARISON_LESS;
drawDepth.StencilEnable = true;
drawDepth.StencilReadMask = 0xff;
drawDepth.StencilWriteMask = 0xff;
drawDepth.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
drawDepth.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
drawDepth.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
drawDepth.FrontFace.StencilFunc = D3D11_COMPARISON_EQUAL;
drawDepth.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
drawDepth.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
drawDepth.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
drawDepth.BackFace.StencilFunc = D3D11_COMPARISON_EQUAL;
my idea was that always when two pixel are rendered on the same location the stencilRef increases
in the end this kinda works (somehow)
first i draw my whole scene with this depthStencil
then i redraw all again but all in a for loop (i think that this is not the right way, but it was the only idea how to solve it)
landAndWavesTech->GetDesc( &techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
for(UINT i = 0; i < 5; i++)
{
md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB, &stride, &offset);
md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);
Effects::BasicFX->SetMaterial(depth[i-1]);
md3dImmediateContext->OMSetDepthStencilState(RenderStates::DrawDepthDSS, i); // << here i try to go through all stencil refs
quesitons:
1) how can i get the count of how many stencilrefs i have? (how often did the stencilref increment ?)
2) is this the right way to do it - loop through all stencil refs? seems not very performant
3) how can i access the stencil ref if i implement the depth_stencil_state via hlsl?
4) it works fine but it doesnt include the water, any idea why?
look at the attach to understand what i mean
hope that someone can help
regards helgon