0
\$\begingroup\$

I'm trying to achieve rendering to multiple targets with multiple viewports. Currently it does not work possibly because I have a single depth buffer so a first write to it with a specific viewport will not allow rewrite when using another viewport covering a similar area because the depth value is higher (comparison test is less). For this I'm using a geometry shader to select the target and viewport. I have this situation where the rendering to the second target does not need depth testing. So I would like to know if it is possible in the geometry shader to activate depth write when selecting the first target and deactivate it when selecting the second target.

Maybe this will not solve my problem but I'm interested to know if we can do this as it could give some improvement when not using the depth testing.

Below a picture to clarify what I'm looking for. enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Have you considered setting your test to e.g. LEQUAL and then when rendering to the "no depth" viewport, just render everything at the same depth (eg. all at the near plane or all at the far plane)? The equal depths should pass the depth test. \$\endgroup\$
    – DMGregory
    Commented Oct 4, 2023 at 10:25
  • \$\begingroup\$ Rendering all near is an idea but how do I set the depth value to near depth. Should I change in the geometry shader the view matrix or set a SV_Depth to impose a depth of 0 (or 0.5 maybe?) at the shader level? Of note I need to store the real depth value anyway from calculated Pos.z that will go to a specific rendertarget corresponding to the second target rendering whereas at the end the depthbuffer will correspond to the first target only. This is whty not writing at all when rendering the second target is better. \$\endgroup\$
    – philB
    Commented Oct 4, 2023 at 11:41
  • \$\begingroup\$ I have added a picture to visualize my needs. \$\endgroup\$
    – philB
    Commented Oct 4, 2023 at 14:45

0

You must log in to answer this question.