Original Post
Currently I'm working on shadow mapping for a program I'm making, I have most of the code up and running, however in the shader this is an issue with texture proj.
I had set GL_TEXTURE_COMPARE_MODE to GL_NONE instead of GL_COMPARE_R_TO_TEXTURE when testing the depth map to ensure it was rendering. However when I switch to GL_COMPARE_R_TO_TEXTURE I end up with a blank depth texture. Everytime I try to query with textureProj I receive back 1, regardless of whether it should be in the shadow or not. Any idea why enabling this line
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
would prevent the frame buffer object from writing to the depth map?
fragment shader is as follows, removed the lighting code that doesn't have issues.
Texture and frame buffer are defined as follows. I have verified that the framebuffer is able to write the depth buffer when the compare mode is NONE.
I define the clear values as
The only error the Shader throws is a warning
0(19) : warning C7532: global function textureProj requires "#version 130" or later
I had set GL_TEXTURE_COMPARE_MODE to GL_NONE instead of GL_COMPARE_R_TO_TEXTURE when testing the depth map to ensure it was rendering. However when I switch to GL_COMPARE_R_TO_TEXTURE I end up with a blank depth texture. Everytime I try to query with textureProj I receive back 1, regardless of whether it should be in the shadow or not. Any idea why enabling this line
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
would prevent the frame buffer object from writing to the depth map?
fragment shader is as follows, removed the lighting code that doesn't have issues.
varying vec4 diffuse,ambient;varying vec3 normal,lightDir,halfVector;varying vec4 shadowCoordinate;uniform sampler2DShadow shadowMap;void main(){ color = vec4(vec3(textureProj(shadowMap, shadowCoordinate)),1); gl_FragColor = color;}Texture and frame buffer are defined as follows. I have verified that the framebuffer is able to write the depth buffer when the compare mode is NONE.
glEnable(GL_TEXTURE_2D); glGenTextures(1, &RenderTexture); glBindTexture(GL_TEXTURE_2D, RenderTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, Width, Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE); glGenRenderbuffersEXT(1, &RenderBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RenderBuffer); glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA, Width, Height); // Create a FrameBuffer and attach the render buffer and texture glGenFramebuffersEXT(1, &FrameBuffer); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FrameBuffer); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, RenderTexture, 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER, RenderBuffer);I define the clear values as
glClearColor(0.2f, 0.2f, 0.4f, 0.5f); glClearDepth(1.0f);The only error the Shader throws is a warning
0(19) : warning C7532: global function textureProj requires "#version 130" or later