Archived

This topic is now archived and is closed to further replies.

Syrillix

shadow volumes issue just not entirely sure of the issue

Recommended Posts

screenie if you look at the screen shot you'll notice (aside from how crap it is) that its not enitirely right, but i cant pin down where exactly its going wrong. my first guess was the edge list creation or the silhouette determination routines but somehow i think it may also be related to the model (low poly count). well im not entirely sure and i've been staring at this code for hours to no avail. so any help would be great.. Get busy livin' or get busy dyin'... - Shawshank Redemption If a man is talking in the forest, and no woman is around to hear him, is he still wrong? - Unknown Altered Vision [edited by - syrillix on October 15, 2003 8:13:14 PM]

Share this post


Link to post
Share on other sites
When messing around with shadow volumes i initially had that same problem. I don''t remember how i fixed it, it had something to do with the order of my commands. However, if making a full engine i would definately reccomend a different method of shadowing solely because shadow volumes cause bad slowdown with multiple light sources and other methods are more exact. I reccomend reading posts about shadow mapping.

Share this post


Link to post
Share on other sites
i''ve read into shadow mapping a little bit. however this isnt for any engine, but more for my own ego.. err, i mean that whole learning thing :D

anyway, i think it might have something to with my winding order of the shadow quads since im not getting the correct shadow on the plane.

so i guess a snippet of how im doing that should help

for(i=0; i<m_nEdges; i++){
float dot1, dot2;
dot1 = D3DXVec3Dot( &m_pFaceNormals[ m_pEdges[i]._usTriIndices[0] ], rLightDir);
dot2 = D3DXVec3Dot( &m_pFaceNormals[ m_pEdges[i]._usTriIndices[1] ], rLightDir);

bool d1 = (dot1 <= 0 && dot2 >= 0);//? true:false;

bool d2 = (dot2 <= 0 && dot1 >= 0);//? true:false;

if( d1 || d2 ){
D3DXVECTOR3 p1,p2,p3,p4;

p1 = D3DXVECTOR3( m_pInterpolatedVerts[ m_pEdges[i]._usVertIndices[0] ]._xyz );
p2 = D3DXVECTOR3( m_pInterpolatedVerts[ m_pEdges[i]._usVertIndices[1] ]._xyz );

p3 = p1 + (*rLightDir) *push;
p4 = p2 + (*rLightDir) *push;
//have to make sure the winding is correct

if(d1){ //second tri facing away from the light

//first shadow tri

memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p2, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p1, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p3, 12);
//second shadow tri

memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p2, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p3, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p4, 12);

}else if(d2){//first tri facing away from the light

memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p1, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p2, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p4, 12);
//second shadow tri

memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p1, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p4, 12);
memcpy(pTemp[ tempIndex++ ]._fVertices, (float*)p3, 12);
}

Share this post


Link to post
Share on other sites
From what it looks like, you''re projecting verts in a non-valid way. rather : Are you projecting every vert? Or just the edges of the model?


~Main

==
Colt "MainRoach" McAnlis
Programmer
www.badheat.com/sinewave

Share this post


Link to post
Share on other sites
im most certain that im only extruding edges that have one triangle facing the light and the other isnt. or if both triangles norms are perpendicular to the light direction, since i thought that would also be an edge of mesh. im probably wrong..

bool d1 = (dot1 <= 0 && dot2 >= 0);
bool d2 = (dot2 <= 0 && dot1 >= 0);

Share this post


Link to post
Share on other sites