How can i render the depth texture to a quad in fixed function pipeline OpenGL?

Adrian M

Newcomer
I have captured the depth buffer in a depth texture and now i want to see it. How can this be achieved in OpenGL using only fixed function pipeline?
 
I tried that and all i can see is a white quad. If i change the type of the texture from GL_DEPTH_COMPONENT to GL_RGB i can see the rendered scene from the light's point of view.
 
That's because the depth buffer generally is pretty much all white. The vast majority of the values will be close to 1.0, unless you use a reversed projection matrix, in which case the vast majority of the values will be close to 0.0. When I want to visualize a depth buffer I usually do something like pow(depth, 64.0) in the shader. With fixed function you'll have a much harder time getting any visual feedback. Try pushing the near clipping plane as far forward as possible. That should bring the values in the buffer down.
 
That's because the depth buffer generally is pretty much all white. The vast majority of the values will be close to 1.0, unless you use a reversed projection matrix, in which case the vast majority of the values will be close to 0.0. When I want to visualize a depth buffer I usually do something like pow(depth, 64.0) in the shader. With fixed function you'll have a much harder time getting any visual feedback. Try pushing the near clipping plane as far forward as possible. That should bring the values in the buffer down.

Thank's for the tip. I managed to visualize the depth buffer using multiplicative blending using this function

glBlendFunc(GL_DST_COLOR, 0);

now I render the quad first with blending disabled and then do a for loop with blending enabled. And that's it. The depth buffer will look as dark as i want :D.
 
Dude, just switch to programmable pipeline. It's awesome. And you'll almost never have to bother with some silly things like which texture goes where and how to visualize it. I made the switch and I am not coming back.
 
Dude, just switch to programmable pipeline. It's awesome. And you'll almost never have to bother with some silly things like which texture goes where and how to visualize it. I made the switch and I am not coming back.

Yeah it's awesome, i agree but sometimes it isn't available and you have to stick to what you have. I don't have programmable pipeline on my mac with an intel graphics card. :D
 
Really? GMA950 should support GLSL on OSX, and I don't recall Apple using another Intel graphics chip.
 
Gee, you are right, i checked what glGetString(GL_EXTENSIONS) was saying and i can see there is support for shaders. That's fantastic! I had the preconception that integrated graphics cards don't support shaders :D
 
Integrated graphics may be a generation behind, but seldom several generations. We've had programmable shaders for quite a while. GLSL was standardized in 2003.
 
Back
Top