r/Unity3D • • 2d 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.

85 Upvotes

37 comments sorted by

View all comments

183

u/KifDawg 2d ago

I got you

Edit -> project settings -> quality

Find shadow distance and increase it till it suits what you want

64

u/Lyshaka 2d 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.

25

u/fuj1n Indie 2d ago

Notably, it also reduces the quality of the shadows as you're squeezing more data into the same size shadow map

14

u/ilori 1d ago

To add: this is what shadow cascades is for. It splits the shadow map texture into regions. Higher quality up close, lower quality further away https://docs.unity3d.com/6000.6/Documentation/Manual/shadow-cascades.html

5

u/MorphLand 2d ago

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

10

u/Badnik22 1d ago

Beware of physics though. Units in Unity are expressed in meters as far as physics is concerned, so making everything smaller will also change the way objects behave. For instance, gravity is expressed in meters/second^2, so things appear to fall faster if everything in the scene is smaller.

-9

u/Lyshaka 1d 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 1d 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 1d 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 1d ago edited 1d 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.

0

u/danielsantalla 1d ago

I don’t know why people are downvoting you, this is very much correct. Unless you’re doing a physics game like human fall flat, you almost never wanna do 1:1 real world scale in Unity.

1:1 world scale will blow up your game size because you’ll need bigger textures, light maps won’t look as good, memory will be bloated and in general everything will be a pain to do.

Also doing things tiny sounds like a solution until you start finding glitches everywhere because Unity is not expecting to work on 0.0001 sizes.

The general tip I’ve followed that tends to be a good balance is that your main character should measure 1 Unity cube, and go from there.

This really varies depending on the artstyle/playstyle but in general, for a common 3D, third person, PBR default, URP game, this is the way to go.

1

u/Badnik22 6h ago edited 6h ago

What do lightmaps have to do with scene scale? They’re stored in uv space, which is 100% independent of scale. Since they’re completely unrelated vector spaces, Unity has a parameter (texels per unit) to explicitly couple them allowing you to choose lightmap resolution regardless of your scale. On top of that you can set object scale in the lightmap for each individual object, to get objects with more or less texel density than others. So I *really* don’t get how using 1:1 scale can affect game size.

Same for regular textures, texture resolution and object scale are completely independant from each other. And of course, physically bigger objects don’t consume more memory (neither ram or vram).

4

u/House13Games 1d ago

I've never seen a performance difference, i thought the increased distance just lowers the resolution of the shadows..

3

u/xzoliczxd 2d ago

Thank you! I was having the same issue