modulate black shadow with fragment's color

Hi Shadow Freax,

I use the shadow mapping technic to create shadows and work with GL_ARB_SHADOW and GL_ARB_DEPTH_TEXTURE.

But I don’t want 100% black shadows. What I want is a modulation between the black shadow and fragment’s color. Like 50% shadow and 50% color.
How can I do this?

I am sure, you guys can me help in this.

Thanks a lot!!!

The simplest way is to first paint your scene with ambient color and Z buffer.

Then turn off Z buffering, and draw each light, with the appropriate shadow map. That way, each light adds the amount that it should add, and nothing where it’s in shadow. Meanwhile, the entire scene is visible because of your ambient term.

Note: you probably shouldn’t have much ambient (light or scene) in the lights, because all of that is put into your initial pass anyway.

There’s two theories about how to add diffuse color: One says to modulate in the diffuse map for each light you draw. The other says to modulate in the diffuse color at the end (but then adding non-modulated specular becomes somewhat harder).

Thanks for your reply.

To make it easier I am doing it only with one light. Here are the steps:

1 create Depth map
2 render scene without shadow mapping
3 turn my light on and let OpenGl create tex coords to do shadow mapping.
4 render scene again without depth buffer

But this doesn’t work. Do you maybe see a mistake?

[This message has been edited by A027298 (edited 10-25-2002).]

You need to render with depth TESTING on but depth WRITE off in pass 4.

Also, “it doesn’t work” is rather vague – even vaguer than the four steps you described. On the other hand, I won’t have time to dive into someone else’s code anyway – but perhaps someone else on the board could help more if you gave more details.

I didn’t want to bother anybody with code here.

Or does maybe anybody know a pointer, where I can see some code examples or where I can read more about it? I would appreciate this so much, since I really need those transparent shadows.

Thanks!!!

[This message has been edited by A027298 (edited 10-28-2002).]

From the GL_ARB_shadow_ambient extension:

The desired color for a lit, textured, shadow fragment is:

  ( ambient + diffuseShade * diffuse) * decal + specular * shade

  where diffuseShade = dimming + ( 1.0 - dimming ) * shade, and
  shade is the result of the shadow test in [0,1].	dimming
  expresses the scattered light in a scene.

  If we limit shade to the range [<dimming>, 1] (where <dimming> is
  TEXTURE_FAIL_VALUE_ARB) then we can express the diffuse term with
  the standard GL_MODULATE texture env mode.

  Furthermore, this extension allows implementing shadow arithmetic
  with a single texture stage.  Otherwise, two texture stages are
  needed in order to compute diffuseShade * diffuse * decal.

  This extension is also useful for implementing shadowed lighting
  expressions other than the one above.  In particular, a "poor-man's"
  shadow mode can be implemented by setting TEXTURE_FAIL_VALUE_ARB to
  the scene's ambient intensity and the texture environment mode to
  GL_MODULATE.  This is the intention of the original
  GL_SGIX_shadow_ambient extension.

Hope this helps!

Thanks MrB,

That helps a lot!