Direct3D Stencil Shadow Volume

Started by
5 comments, last by Draigan 21 years, 6 months ago
Okay, I''ve still be having lots of problems getting my stencil shadow volumes to work with the z-fail method. I''ve written up an outline (along with source and pictures) and placed it on my temporary website. If any guru''s who''ve implemented this before can please take a look and let me know of any ideas you have, I''d greatly appreciate it. Thank you very much. http://www.geocities.com/dpicco2002/
Advertisement
And another quick question...

Should my caps be facing inwards into the shadow volume or outwards?
OK, Ideas:

Your silhouette-determining code seems OK, although it took me a little while to figure it out as I have not seen it done this way before.
You are getting a smaller shadow as well as your main one because your shadow volume is being clipped by the far plane.
Thus, stencil counts are off is this area. I presume you have seen the papaer on infinite shadow volumes at nVidia? The infinite far plane trick is used to prevent the shadow volume being clipped. There was a post here recently about using an infinite far plane in D3D.

As for your other problem, it is correct that you can see the shadow of the character when you look from the other side of the hill. If you imagine the shadow volume, it will clearly intersect the back of the hill.
How to fix it? Hmm...let me think...

Oh, and the caps should face outwards, just like the rest of the volume.

http://users.ox.ac.uk/~univ1234
Okay, I changed it so that my far plane is 5000 units away and my shadow volume extends only around 800 units... the small shadow still shows up...
Alright, I reversed my front/back caps vertex orders and now I don't get that shadow through the hill or the small shadow... actually I get small speckles where the small shadow was... kinda like little parts of it are still drawing. Almost like the back caps don't quite mask it out. Any ideas about that? Could it be because my model has cracks in it? Could it be a resolution thing?

I've posted a description and pic of this on the website again... it's right at the top with my old problems below. I guess you can ignore the bottom stuff unless they perhaps explain the top problem.

http://www.geocities.com/dpicco2002/

Edit: There's also a zoom-in shot there as well now.. follow the link to see the zoom-in.
Thanks all.

[edited by - Draigan on October 22, 2002 6:48:47 PM]

[edited by - Draigan on October 22, 2002 7:08:32 PM]
Anyone?
I''ve uploaded a color-coded version to show the values of the stencil buffer when the artifacts appear. Normal coloring means the stencil is 0. Yellow means the stencil is 1. Red means the stencil is > 1.

Someone must have an idea or two...

http://www.geocities.com/dpicco2002/
Just a thought: try playing around with the Z-Bias value which is one of render states. I didn''t really go through your code, so I couldn''t tell you you''re already doing that.

This topic is closed to new replies.

Advertisement