View Full Version : laying down depth
a bit embarrassed to ask ( as i should know it ) but whats the best way to lay down depth info, from a depthtexture.
i could do it with glsl + gl_FragDepth
but is there a way to do it with the fixed function pipeline?
07-08-2007, 04:03 AM
07-08-2007, 07:16 AM
If you have the depth info in host memory, you can copy it to the depth buffer via glDrawPixels(GL_DEPTH_COMPONENT). You must enable DEPTH_TEST and depth writes, set the DepthFunc appropriately and you may wish to disable color buffer writes.
If you have the depth info in a depth texture already, you may associate it with a FBO and copy it directly with BlitFramebufferEXT:
cheers, framebuffer blit looks ideal unfortunatly i cant do it cause
11) Should blits be allowed between buffers of different bit sizes?
Resolved: Yes, for color buffers only. Attempting to blit
between depth or stencil buffers of different size generates
INVALID_OPERATION.heres what im doing
i have the main scene as a fullsized FBO (color + depth textures)
+ i have 2 other FBOs, glow buffer + particle system buffer.
both these are 1/4 sized (to conserve fillrate).
now to get these to display correctly i need to take into consideration the depth info when i draw into the FBOs.
ok got it working with the following (just in case someone wants to do the same)
glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE );
g_GL->draw_fullsize_quad_rectangle( g_Program.options.renderbuffer_width, g_Program.options.renderbuffer_height );
// fragment shader //
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect depthtex;
varying vec2 texcoord;
void main( void )
gl_FragDepth = texture2DRect( depthtex, texcoord );
another thing since im writing the depth to the whole screen, is it worthwhile turning off the clear( GL_DEPTH ) ?
07-23-2007, 12:03 PM
Yes, make sure your depth test is set to GL_ALWAYS when drawing the depth values, that compare_mode is just the depth shadow comparrison (fragment z vs. texture R), you still need the depth fragments to wuin when tested against the framebuffer and so that clear may be saving you for now.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.