Hi, I think the used data type for the depth texture is set wrong. A depth buffer does not use a floating point type but a fixed point type. When you access the texture in a shader you get values in the range of [0,1]. But it is stored as a 24 bit integer value in the texture. Just like a RGBA8 texture stores values from 0 to 255, they are returned as normalized [0,1] values in the shader. This may not be a huge problem as it seems to work anyways(either OSG or your graphics driver is correcting this). But it could lead to undefined behaviour on another machine. You should set the source type to GL_UNSIGNED_BYTE. I now this looks strange as this would only be 8 byte per component, but it is used in every OpenGL tutorial I have seen so far. It seems to be the correct way.
As an alternative you could also use a GL_R32F or GL_LUMINANCE(deprecated in OpenGL 4.0!) texture for your depth buffer. For this you need to bind it to as a regular color buffer and write a shader that calculates the depth. You could either directly write p_viewspace.z or normalize it to the [0,1] range with (-p_viewspace.z-near)/(far-near). With this approach you get a better precission and automatically get rid of some nasty shadow mapping artifacts like moiré patterns. The problem is that you lose hardware support and can not use "sampler2DShadow" in your shader code. This could make the implementation a bit slower. Thank you! Cheers, Marcel ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56691#56691 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

