multiple shadow volumes

Started by
10 comments, last by thedo 21 years, 8 months ago
I have a mesh class which contains the following methods: Load() Draw() BuildShadowVolume() DrawShadow() All works fine with 1 light but I want to have at least 2 or half my world will be in shadow. Has anyone overcome this problem? My shadow drawing code is based on (ie originally directly copied but now heavily optimized) the shadow volume example in the sdk. Neil WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
Advertisement
I think you would have to generate the volumes for every light you want to cast shadows, and then simply combine them into one single volume before you start rendering.
Just take care how many lightsources you''re actually using for it, since it will eat you cpu-cycles pretty fast.


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.
no, dont combine them to one shadow volume. render each light seperately, with it''s own shadow volume. if you will combine them, areas that should be lit will be dark.
Well the problem at the moment is that lit areas are in shadow if the lights are at opposite sides of my mesh. Example : the mesh is drawn, shadowvol 1 is built and rendered (shadowing light areas from light 2), shadow vol 2 is built and rendered (shadowing light areas from light 1). I''ll try and post a render from my engine soon to demonstrate the problem.

Would building a combined shadow volume get around this? In my head it does not work (you know when you just cant get your head around something?), but if you''ve tried it I''ll give it a go and see where I end up.

Cheers

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
Heres a screenshot of how it looks if I have 2 shadow volumes from 2 lights in my scene at the moment

Screenshot

1 Light is on the left (and casts a shadoe to the right), and the other is to the right (and casts a shadow to the left).

This is essentially using the method by ofer already. Any ideas at all.

Another problem with my shadows is if I step into the shadow volume. Any ideas how to fix this?

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!


[edited by - thedo on August 13, 2002 3:12:56 AM]
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
a) i said not to combine them. draw ambient for the scence, than draw the 1st SV to the stencil, than draw the first light contribution. CLEAN the stencil (you probably forgot that) and draw the second set of SV. now add the second light. i see your not using attenuation, you should, it will look much ,much better.

as for the second problem, you can check when your are inside the volume and reverse the check, but if you use the carmack''s reverse method (the z fail method) it will solve itself.
Ah I see. I'll give it a try tommorrow.

quote:
i see your not using attenuation, you should, it will look much ,much better.


Clues on how to do this? I was quiet impressed that my code worked first time (even more impressed it works at 180fps with 30 models casting shadows)

Cheers

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

[edited by - thedo on August 13, 2002 3:39:54 PM]
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
Actually, what is exactly a shadow volume?
It is where you build up a mesh from your mesh which follows rays from a light to a plane. This is the shadow volume. Combine this with the use of a stencil buffer and a couple of simple techniques and you can cast nice little shadows

Look at the SDK example in the stencil effects folder

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
Ok here is what i have understood so far (and how i belive Carmack is doing his engine):

The first thing you need to do is to draw the ENTIRE scene, with only global ambient light and emissive lights if any. This will take care of filling the z-buffer as well. you can now turn of z-buffer writes.

Then for EACH shadow casting light you do the following (more or less)

1) Clear the stencil buffer
2) Draw the shadow volumes to the stencil buffer as you normally do

3) Now the stencil buffer should contain 0 for non-shadowed regions and >0 for shadowed ones. Set the stencil check so that only regions with stencil value of 0 are drawn to. Also set ZTest to EQUAL, which means you only update the pixels that are actually visible

4) Redraw the scene, using that particular light. You can use any lighting model (eg Per-pixel Dot3 lighting or simple vertex diffuse or something)

Finally repeat steps 1-4 for every shadowy light. You need to somehow blend this with the preivous value at the pixels so that the final shadow and lighting is correct (ie has contribution from all the lights which see that pixel)

I still have to figure out an efficient way of dividing my scene such that not every light makes contribution to every poly (BSP properties?). It can be rather slow otherwise.


As far the problem with standing in the shadow volume goes, if you choose to take the z-fail method used by carmack, not only do you have to project the sillhoute (excuse the spelling) edges for the volume, you need to CAP the volume by projecting and rendering the polys facing away from the light, and rending the polys which are facing the light where they are. Just picture your shadow volume being sealed on either side. I still haven''t figured out WHY you need to do this. As you can imagine this makes the shadow volumes rather expensive. Carmack said that even after his mega optimisations, the number of polys in the shadow volume is 2X the number of polys in the model Still it is the most robust, simple and artifect free solution to rendering shadows

I''m pretty sure all of the above made little or no sense. For an awsome read about these topics, look at the nVidia developers site. There is paper with the name "Robust Shadow Volumes" (or something similar), which explains all of these topics really well.

This topic is closed to new replies.

Advertisement