Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: GLSL Shadow Map code sample.

  1. #11
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    3

    Re: GLSL Shadow Map code sample.

    I found the problem in the fragment shader.
    The shadow2DProj function end's with ".w" - I change this to ".r" and now it work

  2. #12
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: GLSL Shadow Map code sample.

    Quote Originally Posted by AMDFX
    I found the problem in the fragment shader.
    The shadow2DProj function end's with ".w" - I change this to ".r" and now it work
    Ah! Ok. Pre-GLSL 1.3, you can set how the rgba (xyzw) vec4 return value is set by the shadow texture lookup via GL_DEPTH_TEXTURE_MODE:

    Code :
      GL_INTENSITY = rrrr
      GL_LUMINANCE = rrr1
      GL_ALPHA = 000r
      GL_RED = r001

    The default is LUMINANCE, so you were probably getting "1" before when you were using .w.

    Post-GLSL 1.3, DEPTH_TEXTURE_MODE is deprecated and GLSL behaves as if its always set to LUMINANCE (so you get a rrr1 return, where r is the depth comparison value).

  3. #13
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    1

    Re: GLSL Shadow Map code sample.

    I'm trying to implement the PCF Soft Shadows in my own project. The idea is to adapt the code from the example.

    Unfortunately, I'm getting an incorrect lighting, very bright and without shadows. I need some help diagnosing the issue.

    I'm using a QGLWidget (from Qt) to render. Before this implementation, I was just doing rendering on the widget; however, I've seen that the tutorial uses two FBO objects. I copied that part, but I don't know if I have to change also my code.

    This is the result that I'm getting:

    http://minddebuggers.com/fotos/rendering-wrong.jpg

    This is a reference of what I get without lighting:

    http://minddebuggers.com/fotos/rendering-OK.jpg

    Thanks in advance.

  4. #14
    Junior Member Newbie
    Join Date
    Sep 2011
    Location
    Florence, Italy
    Posts
    14

    Re: GLSL Shadow Map code sample.

    I have some trouble with the simple shadow mapping.
    I'm using textureProj() with sampler2DShadow.

    Maybe i put the wrong TextureMatrix.

    Proj-Light --> perspective projection of the light
    View-Light --> view matrix of the light

    I do the following:

    - for the depth texture:
    Code :
            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 );
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
            glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);


    - during shadow map rendering (with FBO like the tutorial) I use Proj-Light and View-Light*ModelMatrix
    respectively as projection and model-view matrix

    - during the regular rendering pass I use the following TextureMatrix:
    TextureMatrix = Bias * Proj-Light * View-Light * ModelMatrix;
    - vertex shader:
    Code :
            shadowmapCoord = TextureMatrix * inputVertex:
    - fragment shader:
    Code :
             shadow = textureProj(shadowMap, shadowmapCoord )


    The result is no shadow at all...
    Any help is much appreciate!

  5. #15
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171

    Re: GLSL Shadow Map code sample.

    I think we need to see the entire shader. Many subtle things could be wrong.

  6. #16
    Junior Member Newbie
    Join Date
    Sep 2011
    Location
    Florence, Italy
    Posts
    14

    Re: GLSL Shadow Map code sample.

    OMG you're right. I accidentally changed some piece of my spaghetti code, and.. tahdah.. it works! I can see the Moiré pattern!

    Thanks anyway.

Posting Permissions

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