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 9 of 9

Thread: Shadow Mapping

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    2

    Shadow Mapping

    Dear frnds,
    please clarify the doubt,
    I have a doubt in light source point of view,

    [x
    ]= [view matrix of light ] * [ projection matrix of light ] * [ object of world matrix ] *[vertex (hitting point)]

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    I'm guessing you meant you have a "question" rather than a "doubt".

    What's your question?

    BTW, your space transformations need the light VIEWING and the light PROJECTION matrices swapped. And even then that's going to leave you in light CLIP-SPACE. You still need a bias matrix to shift your projected coords from -0.5..0.5 to 0..1 needed for shadow map texture lookup.

  3. #3
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    2
    sorry for posting like that...

    In light source point of view,i have doubt in depth buffer

    (COLUMN MATRIX)[x,y,z,w]=[bias matrix]*[view matrix of light]*[projection matrix of light]*[object of world matrix]*[vertex]

    In this calculation,how to find the depth value ?

  4. #4
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    Quote Originally Posted by Gprogrammer View Post
    sorry for posting like that...

    In light source point of view,i have doubt in depth buffer

    (COLUMN MATRIX)[x,y,z,w]=[bias matrix]*[view matrix of light]*[projection matrix of light]*[object of world matrix]*[vertex]

    In this calculation,how to find the depth value ?
    As Dark Photon mentioned, you've got the wrong matrix order. It should be

    (COLUMN MATRIX)[x,y,z,w]=[bias matrix]*[projection matrix of light]*[view matrix of light]*[object of world matrix]*[vertex]

    The depth value will be in 'z'. Note, if you are using a perspective projection, then you also need to divide by 'w'.

    The bias matrix should be:
    0.50000 0.00000 0.00000 0.50000
    0.00000 0.50000 0.00000 0.50000
    0.00000 0.00000 0.50000 0.50000
    0.00000 0.00000 0.00000 1.00000

    But you can also do this transformation in the shader with the more optimized (and easier to read?):

    [x,y,z,w]=[projection matrix of light]*[view matrix of light]*[object of world matrix]*[vertex]/2+0.5

    Maybe the shader compiler will optimize it this way.

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    Quote Originally Posted by Kopelrativ View Post
    [x,y,z,w]=[projection matrix of light]*[view matrix of light]*[object of world matrix]*[vertex]/2+0.5
    I don't think that's equivalent. Note: the operand is vec4.

    Go with the first form with the bias matrix in front.
    Last edited by Dark Photon; 11-14-2012 at 05:21 AM.

  6. #6
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    Quote Originally Posted by Dark Photon View Post
    I don't think that's equivalent. Note: the operand is vec4.
    It should be equivalent? Good enough for me to use it, and it is working.

    Doing multiplication or division with a scalar on a vector is done piecewise.

    Whether the compiler can do the optimization anyway, I can't say.

Posting Permissions

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