Jump to content
  • Advertisement
Sign in to follow this  
gcard28

Depth only render pass

This topic is 4332 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok before I render my scene I first draw to the depth buffer. Here is how I do this: - disable color buffer writes - enable writes to the depth buffer - set a vertex shader that only transforms vertices (ie. no dealing with lights) - set the pixel shader to NULL - draw the render primitive then - enable writes to color buffer - disable writes to depth buffer - set vertex\pixel shaders for object and draw for total number of lights affecting the object. Now I've seen some examples where when people draw to the depth buffer in the Z prepass they set a pixel shader that only renders an ambient pass. Why would you need to do that? You've disabled writes to the color buffer so isn't setting a pixel shader irrelevant in this case? Thanks for anyones help.

Share this post


Link to post
Share on other sites
Advertisement
That is usually because the intent is to add direct lighting in a second pass: Shadow volumes are rendered against the z-buffer from the first pass to create a stencil mask. Using this mask, the diffuse+specular bits are then added in the next pass to those parts of the scene visible from the light source.

Share this post


Link to post
Share on other sites
Quote:
Original post by gcard28
Now I've seen some examples where when people draw to the depth buffer in the Z prepass they set a pixel shader that only renders an ambient pass. Why would you need to do that? You've disabled writes to the color buffer so isn't setting a pixel shader irrelevant in this case?

There are two versions of the technique. Either you do a z-only pass or you can combine this with the ambient pass. In the second case, color writes shouldn't be disabled.

There are some situations though, where you need a pixel shader for the z-only pass. These include alpha tested surfaces and pixel shaders that alter pixel's depth. Even if you disable color writes in these cases, you need a pixel shader in order to output the correct alpha and/or depth value for the pixel.

Hope that clears things up a bit.

HellRaiZer

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!