PDA

View Full Version : Shadow Volume, Capping & Open edges



Bozfr
06-25-2003, 10:57 AM
What is the solution for capping a model with opend edges when drawing its shadow volume ?
(I assume shadow volume intersects near plane so capping is required)

In Cass's demo (shadowing md2 model) and in other ones, the capping is done like this :




For all tris
{
if tri is facing light
draw tri
else
draw tri projected to infinity wrt light
}


Does it work for models with open edges ?

Shouldn't it be something like :




For all tris
{
if tri has open edge
{
if tri is facing light
{
draw tri
draw tri with reversed winding projected to infinity wrt light
}
else
{
draw tri with reversed winding
draw tri projected to infinity wrt light
}
}
else
{
if tri is facing light
draw tri
else
draw tri projected to infinity wrt light

}

}


What do you think ?

I'd really appreciate some help from the gurus.

V-man
06-25-2003, 12:58 PM
I pre-process objects, so open objects get closed up. I have a more complex system actually.

I tried something like the second code you have there but having open objects is just a pain in the butt. You can't use the silhouette finding algorithm on that.

The current system I have renders pretty fast so I'm satisfied.

skynet
06-25-2003, 01:40 PM
this is how I handle single-connected edges:




for (int e=0; e<num_shadowedges; ++e)
{
SHADOWEDGE &amp;edge=shadowedges[e];
if (edge.faces[1]!=-1) // neighbour face existing
{
edge.active=shadowfaces[edge.faces[0]].dir^shadowfaces[edge.faces[1]].dir;
}
else
{
// single connected edges only become active if face frontfacing
edge.active=shadowfaces[edge.faces[0]].dir;
}
}


So if your model would only consist of one triangle with 3 single-connected edges, they would only become "active" (contributing to possible silhouette) if the face is facing thelight. The face won´t cast a shadow if the light is behind it.

Bozfr
06-25-2003, 10:43 PM
V-man,

I agree but getting closed models for any kind of model seems also very complicated to me... no ?


skynet,

It seems that you do exactly the opposite of me. My code snippet was specially for a face with a light behind it.
I think the two methods are right !?


Any other opinion on shadow volume capping and open edges ?

DopeFish
06-26-2003, 02:11 AM
As long as you use the front-facing polygons for your capping, you dont need any special cases for them.

Determine the silhouette from your front facing polygons, those that have an open edge you simple *always* cast shadow for. Cap the shadow using the front faces for the cap, and you shouldnt have any problems at all.

That method works 100% of the time in my test cases.

Bozfr
06-26-2003, 04:01 AM
DopeFish

You mean front-facing wrt light, don't you ?

Do you mean something like this for capping :



For all tris
{
if tri is facing light
{
draw tri
draw tri with reversed winding projected to infinity wrt light
}
}


Suppose I have the following situation : in my viewing frustum, I have only one triangle (so 3 open edges) and a light behind it. The triangle's normal is facing the viewpoint, and so back-facing the light source. The shadow volume of this triangle intersects the near plane (so I must use zFail method and cap the shadow volume).
With the previous code no capping is drawn because no triangle is facing the light !

So, DopeFish, what is your solution for such a case ?

DopeFish
06-26-2003, 04:43 AM
Correct, but as the triangle is backfacing the light, the light cannot see the triangle, so there is no shadow to cast if the light cannot see it.

Makes sense to me anyway