| 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: |
| Problem with stencil shadows; looks like z fighting | |
|---|---|
| Tweet Topic Started: Sep 29 2012, 12:01 AM (295 Views) | |
| Venomous | Sep 29 2012, 12:01 AM Post #1 |
|
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. ![]() 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. |
![]() |
|
| luenardi | Sep 29 2012, 10:46 AM Post #2 |
|
Cofee Machines Rock
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
This is a well known issue documented in u3d's manual under stencil shadows. |
![]() For your perception no. But my universe has no such limits. www.recall.co.nr | |
![]() |
|
| Venomous | Sep 29 2012, 03:04 PM Post #3 |
|
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. |
![]() |
|
| Dr. Best | Sep 29 2012, 03:18 PM Post #4 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
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. |
![]() |
|
| Venomous | Sep 29 2012, 03:56 PM Post #5 |
|
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.![]() Seems like stencil shadows are more trouble than they're worth. |
![]() |
|
| luenardi | Sep 29 2012, 04:17 PM Post #6 |
|
Cofee Machines Rock
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Sorry I thought it was in the documentation. My bad. Sorry if I wasted your time. |
![]() For your perception no. But my universe has no such limits. www.recall.co.nr | |
![]() |
|
| Despellanion | Sep 29 2012, 04:27 PM Post #7 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
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. |
![]() |
|
| Dr. Best | Sep 29 2012, 06:14 PM Post #8 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
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. |
![]() |
|
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |





![]](http://z1.ifrm.com/static/1/pip_r.png)






2:22 AM Jul 11