Somehow a very simple test of depth values between the gbuffer depth texture and the current frag depth of a forward rendering pass causes a hard crash. I feel like there must be something I'm missing here. NOTE: the framebuffer where the frag shader is being used is multisampled. Here's the crashing frag shader:
#version 330
out vec4 out_Color;
in vec2 TexCoords;
uniform sampler2D gDepth;//depth attachment from gBuffer render passs
void main() {
float z1 = texture(gDepth, TexCoords).r;//depth from gbuffer depth, a float32 texture
float z2 = gl_FragCoord.z;
if(z1 < z2) { //MANUAL Z TEST -- this single line causes a huge crash at run time
out_Color = vec4(1, 0, 0, 1);//color rejected frags red as a diagnostic
return;
}
else{
out_Color = vec4(0,0,1,1);//else, frags are colored blue
}
}
This is all from code that works fine otherwise, and I've diagnosed this problem down to this single line. My graphics card is somewhat recent Nvidia card (Geforce GT 710), and I am using glew and wgl. If I can do z-testing here I can bump up my frame rate by quite a bit
Here's a photo of rendering a scene using z1 and z2:
EDIT: I forgot to mention that that FBO where the frag shader is being used is multisampled.