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

Thread: shadow question

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    Altheim, Germany
    Posts
    21

    shadow question

    Hi,
    I have a little scene with per-pixel lighting and stencil shadows. First I render the lit scene and then the shadows. This is ok for one light. But when I have two, the shadow of the second light don't become brighter when they are near the first light. How can I render the shadows correctly?

    -FA-

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

    Re: shadow question

    Shadows equals absence of light. Shadows do not equal a darkening of specific areas. Microsoft has done the world a dis-service by arguing for the "one darkening whole-screen quad" version of stencil shadows.

    The real way to do it is something like:

    Code :
    foreach object
      render into depth and ambient
     
    foreach light
      clear stencil buffer
      foreach object intersecting light
        render object into stencil buffer
      foreach object intersecting light
        add light contribution, unless in shadow volume
    With modern cards, where "render light contribution" is single-pass for per-pixel bumped specular, this is no problem. For older cards (GF2 and back) you may need to settle on rendering specular into alpha and not getting a specular color, or using multiple passes, or both.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  3. #3
    Member Regular Contributor
    Join Date
    Feb 2002
    Location
    Hamburg, Germany
    Posts
    415

    Re: shadow question

    Originally posted by FullAmmo:
    Hi,
    I have a little scene with per-pixel lighting and stencil shadows. First I render the lit scene and then the shadows. This is ok for one light. But when I have two, the shadow of the second light don't become brighter when they are near the first light. How can I render the shadows correctly?

    -FA-
    this way you can't get correct shadows with multiple lightsources.
    you have to do it this way:

    1. ambient pass (scene geometry with ambient lighting and depth writes)
    2. for each light:
    - clear stencil buffer
    - draw shadowvolumes
    - draw scene geometry using stencil test and lighting.

    this way you draw only lit pixels instead of drawing all first, and then trying to remove the shadowed areas.

Posting Permissions

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