i use this silhuette detection function:
for(loop=0;loop<part[frame].planezahl*3;loop+=3) // loop through all triangles
{
n = fetchnormal; // set plane normal
NDotL = n.dotProduct(lPos); // caclulate angle beetween normal and lightdir
if(NDotL>0.0) // Triangle faces the light
{
pT[0] = fetchfirstvertex;
pT[1] = fetchsecondvertex;
pT[2] = fetchthirdvertex;
for(int i=0;i<3;i++) // loop through vertices
{
p1 = pT[i];
p2 = pT[(i+1)%3];
// Loop through silhuetteEdges vector
bool killed = false;
for(int i=0;i<silhuetteEdges.size();i++)
{
// if there neighbour already pushed bac:
if((p1.compareTo(silhuetteEdges[i].p1)&&p2.compareTo(silhuetteEdges[i].p2))||(p1.compareTo(silhuetteEdges[i].p2)&&p2.compareTo(silhuetteEdges[i].p1)))
{
// kill neighbour
silhuetteEdges.erase(silhuetteEdges.begin()+i);
killed = true;
break;
}
}
// if nothing was killed -> push current edge back
if(!killed)
{
edge temp;
temp.p1 = p1;
temp.p2 = p2;
silhuetteEdges.push_back(temp);
}
}
}
}
as shadowvolume i loop through the silhuetteEdges and render the quads with extruded vertices.
it looks like this:
everything works fine with simple objects.
but with complex models i get this result:
i know there is antoher thread about stencil shadows here but i don’t understand my problem.
(look at the silhuette determine function. i use Lightdirection dot Normalvector so only light facing triangles are submitted)
a possible problem i could think about is the orientation of the vertices. imagine some triangles have other oriented vertices and the shadowvolume quad is not clockwise anymore.
thanks a much