[gameprogrammer] Re: culled objects and shadow volumes

  • From: Sami Näätänen <sn.ml@xxxxxxxxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Tue, 28 Apr 2009 15:44:15 +0300

On Tuesday 28 April 2009 09:10:44 Alan Wolfe wrote:
> Heya!
>
> I'm culling objects against the viewing frustum and am only rendering the
> shadows of non culled objects, so am hitting the problem where objects that
> are outside of the frustum that should be casting shadows into the frustum
> aren't.
>
> An easy solution might be to check if the shadow volumes intersect with the
> frustum but the problem with that is that all objects would have to be
> considered since i have dynamic lighting and would possibly need to
> re-compute the shadow volumes every frame, which really hampers the
> gainstof culling against the frustum in the first place (at least for the
> shadow rendering).
>
> Does anyone know any good ways to deal with this situation?

Some ideas:

First do like you now do and if the object would be culled do the testing for 
the lighting. Ie if there are any light sources that could cast a shadow with 
the tested object to the direction of the view frustum. If there are such 
light sources, create the shadow volume for those light sources only and test 
the shadow volumes against the frustum. You don't need to create all the 
shadow volumes as you obviously need only those that really are able to cast 
shadow to the direction of the frustum.

an example:
L is one light source
O is the tested object
c is the camera
f is area that is inside the view frustum.

---------------------------------------
L

               O
c
   fffffffffffffffffff
        fffffffffffff
             ffffff
---------------------------------------

so if the vector from L through O will intersect with the view frustum you 
need to create the shadow volume.

You also want to consider the size of the shadow volume:
so calculate the minimum distance of the line from L through O to the frustum.
Also the distance from that point to L is needed.
Also the radius of the bounding sphere of object O and the length from O to L 
is needed.

LO = length from the light to the center of the object.
Ld = length from the light to the point of minimum distance to the frustum
r = radius of the objects bounding sphere
d = minimum distance from the frustum of the line that goes from L through the 
center of the object O.

So if the following comparison is true the shadow volume of the objects 
bounding sphere intersects with the frustum. So there are a chance that the 
real shadow volume will do that as well, so it should be tested/used. You 
might want to test, which of these is more efficient. Simply using the final 
shadow volume if the shadow volume of the objects bounding sphere intersects 
or further testing will stress different parts of the system.

r/LO > d/Ld


You of course want to do all this testing in 3D and not in 2D like the ASCII 
example.


---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: