PDA

View Full Version : Problem with creating shadow volume



lodder
06-12-2004, 03:36 AM
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[2*i+0] == v0 && pEdges[2*i+1] == v1 )

lodder
06-12-2004, 03:38 AM
My posting is screwed up in some way :(
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[2*i+0] == v0 && pEdges[2*i+1] == v1 )

CatAtWork
06-17-2004, 05:46 AM
You can preview and edit your posts.

147-2
07-06-2004, 07:03 PM
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.