Sign in to follow this  
kuroioranda

Copying raw depth from FBO to backbuffer

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this