Blending and projection shadows

Hi!

I have the following problem with projection shadows. Imagine the following setup:

  • I have four quad-polygons, building part of cube, but without top and bottom. They represent walls, standing on the z-plane.
  • then, I have a light-source outside this semi-cube.
  • I project all polygons onto the z-plane, in order to get projection-shadows.
  • the polygons are projected with no light, using black as the color, with an alpha of 0.5f.
  • blending is enabled (They blend with the “ground”, which is a fith polygon, coloured in a medium grey)

Now, the problem is, that wherever there are several polygons projected onto the same part of the z-plane, both of their colors are blended. The result is, that the shadow gets darker for each polygon that is rendered on a piece of ground.

Question: is there a way to ensure that the shadow will have the same color everywhere? That would somehow require that only one shadow gets blended per piece of ground… Is that possible?

Thanks for help,

Dunk

Use the depth buffer. I think you need to set the mode to GL_LESS or GL_MORE. Im not sure. But make sure that nothing is drawn if the z is the same.

Thomas

Sounds like a job for stencil. Clear the stencil buffer before drawing anything. Then, when it is time to draw the shadows, increment the value in the stencil buffer and only draw where the stencil value is 0.