Skip to main content
gamedev.net
🔒 Locked

Depth mapping problem

Started by Altourus Sep 5, 2010 at 2:31 PM 1 replies 1.6k views
Original Post
Altourus
Altourus
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.

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
sprite_hound
sprite_hound
Well what happens if you do put in "#version 130"?
Altourus
Altourus
Quote:
Original post by sprite_hound
Well what happens if you do put in "#version 130"?


Still has the same problem, just some of the variables I use are depreciated. When I remove them the texture proj call still always returns 1

Edit: It seems like the depth map is all blank when I do add the depth compare mode

Edit Edit: Rewriting the program to use version 140 since its the version I have a copy of the orange book for. Will update this thread if it works

[Edited by - Altourus on September 7, 2010 12:49:27 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.