I'm currently having issues with depth textures. When I sample from a depth texture it causes my other samplers to fail. For example, when I set gl_FragColor manually the depth buffer is correct. I can also sample from my Albedo and Lighting textures and composite an image but I then have to set gl_FragDepth manually. Could this be a hardware issue?
I'm creating my FBOs like this:
glGenFramebuffers(1, &m_glFBO);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_glFBO);
glGenTextures(1, &m_glDepth);
glBindTexture(GL_TEXTURE_2D, m_glDepth);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, Width, Height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_glDepth, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_Texture.m_glID, 0);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
I then bind to them and draw scene. Their individual depth buffers are correct (and linear).
#version 120
uniform sampler2D Albedo;
uniform sampler2D Lights;
uniform sampler2D Depth;
void main()
{
vec4 AlbedoColor, LightsColor;
AlbedoColor = texture2D(Albedo, gl_TexCoord[0].st);
LightsColor = texture2D(Lights, gl_TexCoord[0].st);
// Just by sampling from the depth texture my shader screws up (nothing shows up)
// float d = texture2D(Depth, gl_TexCoord[0].st).r;
gl_FragColor = AlbedoColor * vec4(LightsColor.rgb + LightsColor.rgb * LightsColor.a, 1.0);
}
I then composite my final image in the backbuffer.

I should be getting this but with depth information.
Thanks ahead of time!
float dBEFORE calling any other function call. Some shader compilers/platforms don't allow variable definition after calling methods (like in standard C). – r2d2rigo Sep 28 '11 at 10:10