shadow volumes question

Started by
1 comment, last by nini 18 years, 1 month ago
Hi all, i got a working code for Depth pass and Depth fail algorithm , but what i wonder now , is to determine if a camera Eye point is in shadow in order to determine if i use the depth pass technique or the depth fail , are there anyone else who have implemented that ? How to fast and accurately determine if the eye is in the shadow volume of an object ? thanx in advance for your help...
Advertisement
Simple answer:
You don't!

Long answer:
It would take a very long time determine that!
I know people that have tried using a BSP to find out, the problem is that the CPU doesn't calculate things in the exakt way as the GPU clipping is performed, thus if your method isn't fairly conservative you get some false answers (the answer on the CPU is correct, but since the GPU calculate and round things off differently they still doesn't agree).


The concept I use is to determine if the objects projected bounding volume (BV) intersects the near quad (NQ), the quad made up by the points you get from intersection the near plane and the side planes.
Please note that you could either project the BV along the light direction and range OR project the NQ in the opposite direction and range.

For directional lights you could expand your NQ towards the light (infinity), giving you a frustum (a volume of space defined by 5 planes), this is done once per frame (camera position).
Then you test your objects BVs against this frustum, if they intersect it the eyepoint is considered inside the volume.
For a quick and dirty test, just test each plane and if the BV is infront of the plane the object doesn't intersect.
This is a conservative method, i.e you get some false positives but it's very quick, at most 5 plane/BV tests per object. Using frame coherency (storing the plane order per object), you get about 1 plane/BV for objects that doesn't intersect (wich are the most common case) and 5 plane/BV for objects that does intersect.

For point-lights it's not as easy but the concept of either stretching the objects BV or the NQ in respect to the light and then do an overlap test is still valid.

My 2c
thank you eq_ for your reply

This topic is closed to new replies.

Advertisement