[MDX] Stencil Shadows

Started by
4 comments, last by compiler 18 years, 2 months ago
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!
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 :)
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
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.
Sirob Yes.» - status: Work-O-Rama.
@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 =/
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...
Sirob Yes.» - status: Work-O-Rama.
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:)

This topic is closed to new replies.

Advertisement