I've very less knowledge when it comes to rasterization and typical rendering in games and other applications. So I was reading up on the rendering pipeline and found that the hardware could do early depth testing if you don't write to depth in fragment shader and this struck as odd to me. I'm having a hard time imagining cases where you'd wanna write to depth inside a fragment shader. In a normal rendering environment, the depth value gets calculated properly through all the transformations so why would you wanna mess with that? If anybody can explain briefly 2 or 3 examples it'd be great. Thanks.

  • 1
    $\begingroup$ The most common use of writing to a depth buffer in the fragment shader is for shadow map generation some algorithms require the use of the fragment shader. Others can get away with just a vertex shader for shadow maps. $\endgroup$
    – pmw1234
    Sep 6 at 15:05
  • $\begingroup$ ok. waiting for further examples. $\endgroup$ Sep 8 at 7:06
  • $\begingroup$ Proxy geometry may want to write the zbuffer. Other more exotic objects like raymarched or raytraced objects that are mixed into your pipeline could also need their own zbuffer writes. $\endgroup$
    – PaulHK
    Sep 10 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.