Skip to main content
GameDev.net gamedev.net
🔒 Locked

Copying raw depth from FBO to backbuffer

Started by kuroioranda Feb 7, 2010 at 10:31 PM 2 replies 1.7k views
Original Post
kuroioranda
kuroioranda
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?
FXACE
FXACE
Do you use a depth texture as GL_DEPTH_ATTACHMENT?
Do you unbinding your fbo before the step 2?
kuroioranda
kuroioranda
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.
kuroioranda
kuroioranda
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.