Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: Gl_texture_border_color

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012



    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:
    Code :
            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);
            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 };.
    Click image for larger version. 

Name:	Shadow_Border_0.jpg 
Views:	225 
Size:	31.9 KB 
ID:	1103

    This screen is with borders set to GLfloat border[] = {1.0f, 0.0f,0.0f,0.0f };.
    Click image for larger version. 

Name:	Shadow_Border_1.jpg 
Views:	209 
Size:	23.5 KB 
ID:	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,

    Last edited by icebeat; 08-07-2013 at 08:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts