• Advertisement
Sign in to follow this  

Copying raw depth from FBO to backbuffer

This topic is 2934 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

My render loop currently looks like this: 1) Render solid geometry to an FBO. 2) Copy the fbo to the back buffer using a flat quad, with outline post-process 3) Render the particles. The problem is that I can't get step 2 to copy depth as well as color. I want the particles to be occluded by the geometry that was rendered in step one, but even writing the depth directly with gl_FragDepth doesn't seem to work. zDepth is calculated as: gl_FragDepth = (z + 1.0) * (1.0 / 200.0) ...in both the solid geometry and particle shaders used in steps 1 and 3, and in the post process shader I do this when I render the fbo quad across the screen: gl_FragDepth = texture2D(depthTexture, texCoord).r; I assumed that would take whatever raw result came from step 1 and shove it into the back buffer, but that doesn't appear to be the case. There is definitely depth in the depth texture as I get outlining (I also rendered the depth texture as color to visually ensure it was linear), but the particles are not being occluded at all. Are there any gotchas I should be aware of when trying to do this?

Share this post


Link to post
Share on other sites
Advertisement
Do you use a depth texture as GL_DEPTH_ATTACHMENT?
Do you unbinding your fbo before the step 2?

Share this post


Link to post
Share on other sites
Quote:
Original post by FXACE
Do you use a depth texture as GL_DEPTH_ATTACHMENT?
Do you unbinding your fbo before the step 2?


Yes and yes.

Share this post


Link to post
Share on other sites
I figured it out. I was calling glDisable(GL_DEPTH_TEST) to prevent the particles from occluding each other, but that disables all depth buffer interactions. Switched to glDepthMask and everything works.

Share this post


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

  • Advertisement