PDA

View Full Version : Gl_texture_border_color



icebeat
08-07-2013, 07:10 AM
Hi,

I am implementing PCF shadow map based on the OpenGL 4 Shading Language Cookbook example and for some reason, one of the border is always black when I paint the shadow map over a ground plane.

I am creating the texture and attaching to a fbo in this way:


GLfloat border[] = {1.0f, 0.0f,0.0f,0.0f };
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);

...
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowMapID, 0);
..


The scene is painted in 3 Pass:
Pass 1: Generate Shadow maps. Draw occluders in ZBuffer only.
Pass2: Draw geometry Phong + shadow maps.
Pass3: Draw a ground plane with shadow maps with write in Z disabled and discarding pixels not inside shadow. The black corner is generated here.

This screen is with borders set to GLfloat border[] = {0.0f, 0.0f,0.0f,0.0f };.
1103

This screen is with borders set to GLfloat border[] = {1.0f, 0.0f,0.0f,0.0f };.
1104

Edit: I was calculating the best Near/Far plane for the scene Bounding box 2 times one for the normal camera and another for the light. The error didn't happen when I set a far distance > 10000 for the light projection, so I guess it is not a error of border color function.

Thanks in advance,

Carlos.