renderdoc
renderdoc copied to clipboard
Value readed from the depth/stencil buffer is 0 when I use it as a stencil in unity
Description
When I study about SSR in unity, I found a stencil buffer should be used for rendering, so I try to blit stencil data from the depth/stencil texture to a custom texture. Everything is going well except shader debug. The value loaded from the depth/stencil texture is always 0 when I debug shader, but the output texture is rendered correct. That means the shader rendering is correct but something wrong about the debug.
Steps to reproduce
1 Use the unity SRP to render opaque object and get a depth/stencil texture.(stencilFormat = U8_U_Int) 2 Use the depth/stencil texture in the compute shader as stencil m_bjCommandBuffer.SetComputeTextureParam(cs, kernel, Shader.PropertyToID("_DepthTexture"), depthResource, 0, RenderTextureSubElement.Stencil); 3 load the value from the depth/stencil texture uint stencilValue = GetStencilValue1(LOAD_TEXTURE2D(_DepthTexture, dispatchThreadId.xy));
Environment
- RenderDoc version: 1.21
- Operating System: window10
- Graphics API: DX 12
- Unity 2019.4.31
Can you please provide a unity project that reproduces the problem? It seems like from your description that you're saying it's possible to create a small demo from scratch that doesn't contain anything private, but I am not at all familiar with unity so I don't know how to "use the unity SRP" or any of the other steps you outline.
Closing this due to lack of activity and no further information to investigate.