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:
Now after that I would like to repeat the same thing in order to render transparent objects.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)
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
But this sounds like an overkill and maybe is also not 100% correct when it comes to blending.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
Help is really appreciated!



Reply With Quote
And it isn't one of shadow volumes strong points either. It takes an already heavyweight algorithm, makes it even more expensive, and adds more limitations.
). Then seems something along the lines of what you propose might work. Just before step b. you'll need to seed the depth buffer with those samples visible in the translucent object. This is because step c. counts the shadow volume entries and exits either from the eye to the nearest sample, or from the nearest sample to infinity. So you need the depth value in there. Could be done in step a. for light source 1. But when you go onto light source 2, in step a. the depth buffer will already be set. So you may need to flip to EQUAL depth testing for that. Also, to limit the royal boatload of fill rendering these translucents, you may also want to use stencil to limit the fill to only the visible samples within the object.
