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 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Shadow Mapping in OpenGL

  1. #1
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    65

    Shadow Mapping in OpenGL

    Hi, this is a brief explanation of what I'm trying to do:

    Some time ago I've read about a technique called 'Projective Shadow Mapping', and now I'm trying to implement it using OpenGL.

    I can render the light view of an object in a 256x256 texture (the shadow map), with glTexSubImage2D etc.. that works fine, but when I try to set the texture matrix with the matrix I've used to render the shadow map (that's correct?) to project the shadow map to a wall or some other object, I got very strange 'projections'...

    The shadow map is working as well as the rendering of the shadow on other objects, but I don't know whats wrong... the projection matrix (texture matrix) used to render the shadow map to an object (to project it to that object) is really the light view matrix? If there's someone that knows how to do it right (I'm not) please help me...

    Thanks..


    - Royconejo.

  2. #2
    Intern Contributor
    Join Date
    May 2001
    Posts
    58

    Re: Shadow Mapping in OpenGL

    Sounds like you need to handle the projection matrix and the depth comparision to find if a pixel is in shadow in the light view space-

    The best advice is to read the Nvidia tutorials and download their OpenGL sample w/ source. It works quite fine, exposes a 16bpp compare via Register Combiners, and really helps you understand the pros/cons of the method-

    Buena Suerte-

  3. #3
    Senior Member OpenGL Pro cass's Avatar
    Join Date
    Feb 2000
    Location
    Austin, TX, USA
    Posts
    1,058

    Re: Shadow Mapping in OpenGL

    I would also encourage you to look at the shadow mapping examples for GeForce3 that use the SGIX_shadow and SGIX_depth_texture extensions. These are much more efficient and higher quality if you have direct hardware support.

    A whitepaper on this is coming soon.

    Cass
    Cass Everitt -- cass@xyzw.us

  4. #4
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    65

    Re: Shadow Mapping in OpenGL

    Originally posted by Mahjii:
    Sounds like you need to handle the projection matrix and the depth comparision to find if a pixel is in shadow in the light view space-

    The best advice is to read the Nvidia tutorials and download their OpenGL sample w/ source. It works quite fine, exposes a 16bpp compare via Register Combiners, and really helps you understand the pros/cons of the method-

    Buena Suerte-
    Gracias.

    I have every demo and doc. on the nvidia site... The one you are speaking about uses a Zbuffer algorithm, but I'm only trying to project a texture over an object. It's just a 'shadow' texture map, that I have to project.. no Zbuffer op. is involved, just the light view of the object, renderer in black, with a white background, and then I only have to project it (using the texture matrix) to some geometry... that's it.

    I think that Quake2/3 uses this technique... (or some less expensive one, but it's not based on the Zbuffer info).

    My problem basically is that I don't know how to build that projection matrix...


    - Royconejo.

    PS: Thanks cass.. I'll use that extensions when I get a GF3.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Shadow Mapping in OpenGL

    The texture matrix for the shadow texture should be the light matrix as seen from the current modelview -- which is not the same as the projection matrix you used to render the shadow as seen from the light. Uh, if that's clear, or even correct, it might help :-)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  6. #6
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    65

    Re: Shadow Mapping in OpenGL

    So.. I shoudn't be using the light view matrix (the matrix I've used to render the texture shadow, the 'point of view of the light'), as the shadow projection?

    Could you be more specific? do you have some code or something? sorry but I'm very confused...

    Thanks..

    - Royconejo.

  7. #7
    Senior Member OpenGL Pro cass's Avatar
    Join Date
    Feb 2000
    Location
    Austin, TX, USA
    Posts
    1,058

    Re: Shadow Mapping in OpenGL

    There's a whitepaper on the NVIDIA web site that discusses this. You can find it at:
    http://www.nvidia.com/Marketing/Deve...256A38007DE5E6

    I'll have another specifically on shadow mapping Real Soon.

    Thanks -
    Cass
    Cass Everitt -- cass@xyzw.us

  8. #8
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    65

    Re: Shadow Mapping in OpenGL

    Thanks Cass, I'm reading it now...

    The problem was that I recently started to use OpenGL, I didn't even know about texgen..

    - Royconejo.

  9. #9
    Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Inside an xbox
    Posts
    290

    Re: Shadow Mapping in OpenGL

    No tendrás una hermana que se llama vanessa?

  10. #10
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    65

    Re: Shadow Mapping in OpenGL

    Sorry Cass, but I can't find the 'projspot' and 'qcoord' demos in the latest nvidia OpenGL sdk, they are really there?

    santyhammer: Porque me preguntas eso?

    - Royconejo.

Posting Permissions

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