PDA

View Full Version : Draw the depth buffer as 2D image



Boschiotto4
05-14-2007, 01:01 AM
I need to draw on the color buffer the depth buffer,in a greyscale. I try with glcopypixel, but it went wrong..
Pratically, I need to use the depth buffer as an image, so I'm looking for a command or a method to do this.

Vexator
05-14-2007, 01:47 AM
compute the depth manually. i do that for shadow cube maps, like this:

in your vs:


v_LightVector = u_LightPosition-gl_Vertex.xyz;and in your fs:


gl_FragColor.r = length( v_LightVector );v_LightVector is a varying vec3. instead of the light's position, you'd need the camera's, of course.

arekkusu
05-14-2007, 12:21 PM
In fixed function, CopyTexImage to a DEPTH_COMPONENT texture.
Draw that texture as a quad back to the window, as L, A, or I values.