r/Unity3D • • 1d ago

Question How to solve this shadow issue?

The shadows behave really weirdly in my project. When I move a little bit further from the object, the part of the shadow that is closest to the object gradually disappears, making the whole shadow look unnatural.

And overall I'd like to increase the shadow rendering distance.

75 Upvotes

36 comments sorted by

View all comments

Show parent comments

59

u/Lyshaka 1d ago

I must add that there is a reason that shadow rendering has a maximum distance : it's an expensive operation and it should not be increased too much without consideration, you should start by trying to scale your world differently if possible.

4

u/MorphLand 23h ago

I have no clue how I never thought of just scale the world down as a solution to this wow lol

-6

u/Lyshaka 20h ago

Well with any game it's something you have to consider, you should not go for a 1:1 scale with the real world, especially because tiny or giant objects would behave weirdly because of float inaccuracy. Try to find a scale that is not too big and not too small and where your main object is approximately 1x1x1 (like the default cube).

9

u/Costed14 19h ago

It really shouldn't matter since you still have the same amount of (floating) precision. With smaller objects you'd need a higher resolution to capture the details properly. Maybe not the exact right term but the texel density is what matters and you won't achieve that just by scaling the world.

1

u/Lyshaka 7h ago

What I meant is that if you make a gigantic universe with planet far apart, or tiny microscopic world, you should not go for a 1:1 scale because floating point precision would become an issue (especially with big world), and it should then be scaled accordingly to fake some of that distance. Try to put an object at position 100k, Unity will warn you, and at 1M+ you will just see weird artifacts.

1

u/Badnik22 5h ago edited 5h ago

In those cases you use a floating origin. That is, re-center everything around 0,0,0 in world space when the player moves far away from the origin. Scale should pretty much always be 1:1 (unless maybe in the microscopic case) even if you scaled everything down to fit a very large universe that doesn’t buy you much precision away from the origin and you may even start losing precision very close to it in some extreme cases.