Jump to content
  • Advertisement
Sign in to follow this  
compiler

[MDX] Stencil Shadows

This topic is 4659 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, im trying to add shadow volumes to my little 3D Engine. it works quite fine except one strange bug. beside the shadow on the floor the shadow is also visible far away: image of problem does anyone already worked with shadow volumes and also had this bug or knows the reason for this behaviour? if anyone has some experience with shadow volumes i can also post the sourcecode which renders the shadow. thanks for any help!

Share this post


Link to post
Share on other sites
Advertisement
I've noticed the same thing with my sample project too (3rd item), but I guess it's a 'natural' byproduct of the stensil volume technique. Since you'll typically extrude the shadow volumes to infinity (or rather your far clipping plane), they should be hidden by the geometry on which they cast the shadows. For my terrain renderer this worked out perfectly.

You might be able to do something using clipping planes, but I think this would actually break the technique. I'm not sure, but since the 'near plane clipping' seems to be the main issue for the ZPass technique, I didn't think it would be smart to add additional clipping planes ;) If someone can give the definite word on this, please do.

Anyway, I also notice you have the same strange 'artifacts' in your shadow, the little unshaded pixels as I have in my sample. Can this be completely attributed to 'difficult' faces in the mesh? Turning on anti-aliassing seemed the fix the problem for me though, so I haven't investigated this further.

Hope this helps and we'll get some definite answers :)

Share this post


Link to post
Share on other sites
Hi guys,

The artifacts you mention seem to have something to do with the way the GPU calculates which pixels to fill. When using scaling, some inaccuracies come into play, which might cause very slight gaps between 2 polygons sharing one border. The artifacts in the image do look like that case.

Yeah, AA would help with those, since it's likely the gap would only be 1 pixel, so AA would fill it with a pretty dark color, since it's in a dark environment.

As for the big shadow in the background, I see three options:

1) Shorten how long you extrude vertices. If you don't take them past the z-far, you shouldn't see that shadow.
2) Make the floor a shadow caster. This would block out the airplane shadow, but you'd still have a shadow of the floor to deal with.
3) Switch shadowing methods. I can't remember off the top of my head - but one has problems with z-near, the other with z-far. remigius said Z-Pass had problems with z-near, and I can't think of any reason not to trust him on that :p.

Or, theres always shadow mapping :).

Hope this helps.

Share this post


Link to post
Share on other sites
@remigius
hehe, just some minutes after i created my posting i found the shadow volume application from your great site and noticed that your app has the same "bug".
its good to see that even DirectX experts like u have the same problems :)

@sirub:
i tried to solve the problem by shorten the extrude length and increasing the distance of the far clipping plane. but even if i set the extrude length to 2 and the far clipping plane value to 10.000 i still see the shadow in the background. i really have no idea why =/

Share this post


Link to post
Share on other sites
Does your shadow volume have a back cap then? If it doesn't have a back cap, that would cause it's back to show up as a shadow...

Share this post


Link to post
Share on other sites
Quote:
Original post by sirob
Does your shadow volume have a back cap then? If it doesn't have a back cap, that would cause it's back to show up as a shadow...


do you mean if i close the shadow volume? i just extrude the edges of the occluder so the shadow volume is open at the end.

if i think about it... u are really right! i guess this is the reason for the bug. i will now read the gamedev shadow volume article. maybe it will tell me how to close the end of the shadow volume:)

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!