Part of the Khronos Group
OpenGL.org

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
    Posts
    15

    Gl_texture_border_color

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

Name:	Shadow_Border_0.jpg 
Views:	92 
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:	90 
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,

    Carlos.
    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
  •