Alpha obiects with multiple lights and stencil shadows

Do you have any ideas how to make such thing:
I’m doing one pass for every light in the scene and I have stencil shadows. I want to add transparent obiects that are affected by shadows.
I’m making first pass for depth only (and ambient light) so I cannot modify depth by transparent obiects, because after that I wouldn’t be possible to render obiects behind transparent one. And if I render transparent obiect and in next pass for next light I render obiect behind this transparent one won’t be visible.
I can render transparent obiects after rendering all lights, but this needs to render shadow volumes one more time for every light.
I dont’t have any idea so I think I’m gonna make transparent obiects without shadows but I’m very curious how to make it with shadows without rendering volumes two times.

Here’s an example but it’s D3D, you could try porting it. It should give you a pretty good idea of how this can be done.

That usually the disadvantage of volume shadows with the stencil buffer. Transparent polygons cannot receive or cast shadows.


                          Solid  Alpha-Test  Alpha-Blend

Shadow Volume cast         +       
Shadow Volume receive      +       +
Shadow Buffer cast         +       +
Shadow Buffer receive      +       +           +

Yes i think it is better to project a shadow texture for the alpha transparent objects unstead of volume texture. This is what is done in Doom 3. Perhaps with shaders 3.0 we will be able to have some improvements in the stencil part. (useful for the soft shadows, see the unreal 3 engine :slight_smile: )