Hello,

as explained in this article...
http://www.gamasutra.com/view/featur...t_stencil_.php
...I would like to split my lighting into ambient pass and a pass for diffuse+specular lighting.

For opaque objects this should be straight forward:

1. Render all objects with global scene ambient
2. For each LightSource
a. Render all affected objects with LightSource.ambient (could be skipped if LS does not contribute to ambient)
b. Calculate shadow volumes
c. Calculate stencil mask
d. Render all affected objects with LightSource.diffuse/specular (only areas not in the shadow are lit thanks to the stencil mask)
Now after that I would like to repeat the same thing in order to render transparent objects.
And the transparent objects should be rendered in back-to-front order (for correct blending).
But how can I do this with separate ambient and diffuse+specular pass?

I cannot just render all affected objects for each LightSource as done in (a.)
and then render all objects with diffuse+specular values as in (d.) without
violating the back-to-front order.

I already thought about something like this

For each transparent Object
For each LightSource
a. Render with LightSource.ambient
b. Reuse shadow volumes from opaque pass
c. Calculate stencil mask
d. Render with LightSource.diffuse/specular
But this sounds like an overkill and maybe is also not 100% correct when it comes to blending.

Help is really appreciated!