Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Problem with stencil shadows; looks like z fighting
Topic Started: Sep 29 2012, 12:01 AM (295 Views)
Venomous
Member Avatar
Newbie
[ * ]
I'm trying to use stencil shadows, and they work, except I get strange jittery spots everywhere.
Here's a screenshot of my problem.
Posted Image

Here's the code I'm using.
light object:
Spoiler: click to toggle


terrain object:
Spoiler: click to toggle


blocks model object:
Spoiler: click to toggle


Also, in case it matters, the camera's min_range is 8 and the max_range is 2000.
Offline Profile Quote Post Goto Top
 
luenardi
Member Avatar
Cofee Machines Rock
[ *  *  *  *  *  * ]
Venomous
Sep 29 2012, 12:01 AM
I'm trying to use stencil shadows, and they work, except I get strange jittery spots everywhere.
Here's a screenshot of my problem.
Posted Image

Here's the code I'm using.
light object:
Spoiler: click to toggle


terrain object:
Spoiler: click to toggle


blocks model object:
Spoiler: click to toggle


Also, in case it matters, the camera's min_range is 8 and the max_range is 2000.
This is a well known issue documented in u3d's manual under stencil shadows.

Posted Image

For your perception no.
But my universe has no such limits.


www.recall.co.nr
Offline Profile Quote Post Goto Top
 
Venomous
Member Avatar
Newbie
[ * ]
I went through that part of the the documentation before posting here and did so again now, but I see nothing there that relates to my issue.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Venomous
Sep 29 2012, 03:04 PM
I went through that part of the the documentation before posting here and did so again now, but I see nothing there that relates to my issue.
It is an undocumented issue indeed. It is hard to do anything against it. One thing you can do is to adjust the distance of the near clipping plane and the far clipping plane in the camera. This can increase the precision of the z-buffer.

An even more effective countermeasure is to avoid smooth normals near sharp edges. Your box models seem to have smooth normals and this is the only reason, why the z-fighting can be seen on their back. If the back would not receive light anyway, wrong shadows would be invisible.
Offline Profile Quote Post Goto Top
 
Venomous
Member Avatar
Newbie
[ * ]
I tried to use boxes without smoothed normals. It helped a bit, but the zfighting was still visible at a distance. I already made the near plane as high as I could and the max_range as low as I could without making noticeable clipping, but the issue is still noticeable. I tried it with a higher polygon sphere, ambient lighting set to black, and adjusted the light direction. I still get this.
Posted Image

Seems like stencil shadows are more trouble than they're worth.
Offline Profile Quote Post Goto Top
 
luenardi
Member Avatar
Cofee Machines Rock
[ *  *  *  *  *  * ]
Sorry I thought it was in the documentation.
My bad.

Sorry if I wasted your time.
Posted Image

For your perception no.
But my universe has no such limits.


www.recall.co.nr
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Venomous
Sep 29 2012, 03:56 PM
I already made the near plane as high as I could and the max_range as low as I could
I think you should actually do the opposite, set the min range as low as possible and leave the max range at whatever range you have.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Despellanion
Sep 29 2012, 04:27 PM
Venomous
Sep 29 2012, 03:56 PM
I already made the near plane as high as I could and the max_range as low as I could
I think you should actually do the opposite, set the min range as low as possible and leave the max range at whatever range you have.
Setting min_range to a very small value compared to max_range gives you great z-precision at small depth at the cost of low precision at large depth. max_range is actually not that significant, but lower values give slightly higher precision everywhere.

As a background knowledge on this issue. There is one parameter, which can be tweaked to reduce z-fighting issues, namely the amount by which the shadow volumes are offset to avoid z-fighting. A too small value gives you z-fighting whereas a too large value detaches shadows from the objects. I tweaked it carefully for the current version of Ultimate 3D, but there is no interface to set it from an application. Sorry about that.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply