Jump to content
  • Advertisement
Sign in to follow this  
remigius

[MDX] Two problems with Stencil Shadow Volumes [SOLVED]

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, After a good week of tinkering and cursing the lack of documentation of the Managed API, I finally got my stencil shadow volumes working. I was quite happy with the result, the only little problem I have with my initial test setup is that I have some 'dithering' in the shadow when the shaded object is very light, like the terrain in this picture: If you look closely, you'll see the little 'unshaded' pixels in the shaded region. This may be related to my second problem, but if it is a seperate problem and anyone knows how to fix it, pray tell :) Now on to my real, serious problem. My shadow volumes seem to be generated correctly for 'convex' objects, like the torus and the teapot. When I tried to shadow a 'concave' object (hope I got the terminology right :), like the mushroom top in the next picture, the volumes got completely screwed as you can see below (the mesh is a geosphere, with the bottom 'pushed in'). The effect:
And the volumes:
I don't know if this problem is just a limitation of the stencil shadow volume approach, or if I did something wrong with creating the volumes. I translated Kevin Harris' shadow volumes tutorial from Codesampler.com to C# and I'm quite certain my translation is correct. I can't test my mesh with the tutorial code since it uses a different vertex format, so I'm a bit stomped. Here's the code I use to generate the shadow volumes: [Download here], ShadowVolume class only, zipped (I had to put this in an external file, because the source tags seems to mess up my C# code, omitting stuff etc). Is my problem indeed a limitation of the shadow volume approach, or should I take another look at my volume generation code? By the way, feel free to use my ShadowVolume class if you want, but please post any fixes and/or improvements in this thread. Well, thanks again in advance! :) [Edited by - remigius on August 26, 2005 3:21:30 AM]

Share this post


Link to post
Share on other sites
Advertisement
No one? Not even someone who can tell me whether or not my problem is a known limitation of stencil shadow volumes? :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
is your mesh manifold ? ( Manifold Mesh - A mesh where every edge must be shared by exactly 2 triangles. )

I think it's not the case for the mushroom top. Check if you don't have duplicate vertex ( check distance <

Share this post


Link to post
Share on other sites
Incredible how a day away from the computer can help solve stomping problems :)

I realized that my ShadowVolume class assumes the mesh uses a PositionNormalTextured format. For the additional tests I didn't bother to texture the meshes, so the Panda Xporter smartly used another format, which screwed up the reading of the vertices needed for the shadow volume. Ergo:



So my ShadowVolume class is correct for meshes with the PositionNormalTextured format. Again, feel free to download it if you want to take a crack at creating shadow volumes in Managed DX. It's quite efficient and it doesn't require shaders.

If anyone knows a good way to lock multiple (preferably all) vertex formats for processing, you're quite welcome to have a go at my code :)

Edited for future reference:

A complete sample project on creating z-pass shadow stencil volumes on the CPU can be found at our MDXInfo site near the bottom of this page.

[Edited by - remigius on June 10, 2006 2:21:34 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!