H.Stony

04-24-2006, 10:17 AM

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))&#0124;&#0124;(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:

http://hw4a.awx.at//uploads/Eitsch/silhuette.jpg

everything works fine with simple objects.

http://hw4a.awx.at//uploads/Eitsch/workfiemi.jpg

but with complex models i get this result:

http://hw4a.awx.at//uploads/Eitsch/killermull.jpg

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

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))&#0124;&#0124;(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:

http://hw4a.awx.at//uploads/Eitsch/silhuette.jpg

everything works fine with simple objects.

http://hw4a.awx.at//uploads/Eitsch/workfiemi.jpg

but with complex models i get this result:

http://hw4a.awx.at//uploads/Eitsch/killermull.jpg

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