Problem with creating shadow volume

Hi,

currently I try to implement Stencil Shadow volumes. I have read a lot of articles about it and now I want to implement it myself. But the SV creating doesn`t work the way it should. The SV is created, but looks weird, e.g. has wholes. Here is my code:
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>void CDepthPassSV::InsertEdge( unsigned int* pEdges, unsigned int& dwNumEdges, unsigned int v0, unsigned int v1 )
{
for(unsigned int i=0; i < dwNumEdges; i++)
{
if( ( pEdges[2i+0] == v0 && pEdges[2i+1] == v1 )

My posting is screwed up in some way :frowning:
So, this is the whole posting I wrote:

Hi,

currently I try to implement Stencil Shadow volumes. I have read a lot of articles about it and now I want to implement it myself. But the SV creating doesn`t work the way it should. The SV is created, but looks weird, e.g. has wholes. Here is my code:
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>void CDepthPassSV::InsertEdge( unsigned int* pEdges, unsigned int& dwNumEdges, unsigned int v0, unsigned int v1 )
{
for(unsigned int i=0; i < dwNumEdges; i++)
{
if( ( pEdges[2i+0] == v0 && pEdges[2i+1] == v1 )

You can preview and edit your posts.

I think whats happening here is that you are trying to shadow using all of your edges. I really don’t know, I just infer from what you are saying (and your code isn’t quite useful, either)

what you should do is find a set of “silhouette edges” … only the edges that dictate your shadow’s edge. The way you do this is by storing all edges with pointers to their associated faces. Calculate and find all edges which are connected to one face that’s facing “towards the light” and one face that’s facing “away from the light” … Doing this is simple, just test the sign of the value returned by the dot product of the face’s normal and the direction which the light is.

Once you have these edges, you should only use these to generate your shadow. I also suggest you save off which faces are towards the light, which are away from the light in case you want to cap your shadow volumes.

I suppose I have laid the problem bare for you without going into too much detail.