Managed DX Stencil Shadow Problems

Started by
12 comments, last by StoneDevil 15 years, 11 months ago

The capping of both ends should be correct. With my zpass implementation I had to offset (move/translate) the volumes a small distance along the light vector, so the front caps were effectively covered by the visible geometry. From what I've read about zfail, this offset is also needed there. This could also be done with zbias, but that's tricky.

Looking at the pictures, there seems to be something strange going on when the 'light ray' intersects the mesh 4 times. This would also be consistent with the spere working well, since it would only pass through that twice. But I'm probably reading to much in these pictures, so I guess we're back to checking the renderstates and shadow volume again.

Each article I came across uses 0xffffffff for the stencil mask and write mask and from my understanding that would be the correct way. The 0x1 you're using might be cause for the latest shadow strangeness and could indicate something is going wrong with your previous approach when the stencil gets (or should get) values > 1. Reviewing your renderstates, I think they were correct, so if nothing is going wrong with the actual rendering, there might be something off with the volumes.

I really wish I could be more specific, but the best thing I can come up with is to have you check again if the shadow volumes aren't getting clipped by the far plane of your view frustum (more info, 2nd paragraph).
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Advertisement
hi again,

ive been trying track down the problem with my renderstates...ive come across a problem though that i cant set my stencilmask or stencilwritemask to 0xFFFFFFFF.

device.RenderState.StencilMask = 0xFFFFFFFF

will complain about cast to unsigned int. i can get it to set with

device.SetRenderState(RenderState.StencilMask, 0xFFFFFFFF)

if i set the stencilmask and stencilwritemask to 0xFFFFFFFF i dont get anything drawn to my stencil buffer though. from what i can tell by debugging in PIX for windows.

could this be the problem. thanks again for the help.
It just might be... I'm a bit rusty, but I think you can tell C# to just trust your cast with this:

device.RenderState.StencilMask = unchecked((int)0xFFFFFFFF);
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
i think i finally got it....or atleast good enough for now...i had to change my shadow volume code because i was swapping edge points to check for duplicate edges faster, and now when im extuding the edges i am swappping them back to the original way....this fixed the problem....

Free Image Hosting at www.ImageShack.usFree Image Hosting at www.ImageShack.us

thanks for all the help...a few pictures to show it working....

This topic is closed to new replies.

Advertisement