I am implementing the LightPrePass at the moment into my engine, and now I have problems with rendering close geometry.
Here is a picture which shows the problem, and I think it has something to do with the depth.
Here are the DepthStencil-States I create:
D3D11_DEPTH_STENCIL_DESC dsDesc; // Depth test parameters dsDesc.DepthEnable = true; dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; dsDesc.DepthFunc = D3D11_COMPARISON_LESS; // Stencil test parameters dsDesc.StencilEnable = true; dsDesc.StencilReadMask = 0xFF; dsDesc.StencilWriteMask = 0xFF; // Stencil operations if pixel is front-facing dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Stencil operations if pixel is back-facing dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Create depth stencil state DXUTGetD3D11Device()->CreateDepthStencilState(&dsDesc, &LPP_DepthStencilState); dsDesc.DepthFunc = D3D11_COMPARISON_EQUAL; dsDesc.StencilEnable = false; // Create depth stencil state DXUTGetD3D11Device()->CreateDepthStencilState(&dsDesc, &Scene_DepthState);
This is how I render them:
DXUTGetD3D11DeviceContext()->OMSetDepthStencilState(LPP_DepthStencilState, 0); RenderWorld(LPP_DepthStencilState); //Render world TheScene->Params.SceneInfo.bFirstLightPrePass=false; //Back to normal again //Render everything which wants to be lighting LPP_Renderer->PrepareForLightPass(); RenderLighting(); TheScene->Params.SceneInfo.LightBuffer=LPP_Renderer->GetLightBuffer()->ShaderResView; LPP_Renderer->PrepareForSecondPass(RenderTargetView,DepthStencilView); //PPInterface.BeginWorldRender(); DXUTGetD3D11DeviceContext()->OMSetDepthStencilState(Scene_DepthState, 0); RenderWorld(Scene_DepthState); //Render world
The format is DXGI_FORMAT_R32_TYPELESS for the texture, DXGI_FORMAT_D32_FLOAT for the DepthStencilView and DXGI_FORMAT_R32_FLOAT for the ShaderResourceView.
I haven't got such issues before, so I hope I just missed a little thing.