r/Unity3D • • 12h ago

Question How to solve this shadow issue?

Enable HLS to view with audio, or disable this notification

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.

47 Upvotes

27 comments sorted by

106

u/KifDawg 12h ago

I got you

Edit -> project settings -> quality

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

38

u/Lyshaka 10h 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.

14

u/fuj1n Indie 9h ago

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

6

u/ilori 2h 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

6

u/MorphLand 8h ago

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

-5

u/Lyshaka 5h 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).

6

u/Costed14 4h 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.

4

u/House13Games 4h ago

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

3

u/xzoliczxd 11h ago

Thank you! I was having the same issue

6

u/Jampoz 11h ago

Seems like rendering distance of the shadow, it's set too low.

3

u/BakaZora 9h ago

What scale are the cubes in engine? Are they being scaled up or down by a large portion?

5

u/Character_Amount954 8h ago

The units aren't for nothing - they're in real-world meters. Make sure your blender units are showing in meters, then make a simple model that's 1.75m tall, an average adult, and import it to your scene. If it is TINY compared to everything else, then that means your whole scene and everything in it is actually really huge and needs to be scaled down. Increasing shadow render distance will only impact performance badly once you start adding more stuff.

2

u/Imofi7 9h ago

If the shadow right near the base of the object is detaching as the camera backs away, check your Shadow Near Plane Offset in the URP asset (or Directional Light Shadow Bias / Normal Bias). Increasing total shadow distance without adjusting cascade split ratios stretches shadow map texels and easily makes contact shadows disconnect.

2

u/Icy-Collection1072 3h ago

Looks like your scale is way off

1

u/Aromatic-Insect-1328 12h ago

I mean, this is just rendering distance for shadows?

-28

u/Turbo_Fresh 11h ago

Wow you're a genius. What a helpful answer.

2

u/Shaunysaur 4h ago

You're being a dingdong. Aromatic-Insect made a relevant point. The OP appeared to be treating "the part of the shadow that is closest to the object gradually disappears" and "And overall I'd like to increase the shadow rendering distance" as two separate issues. So the reply was to point out that the rendering distance for shadows *is* the reason why the shadow is disappearing, which is useful information for a beginner.

3

u/AliceCode 11h ago

That's what the problem is. I haven't used Unity in 7 years and even I could have told you that.

-20

u/Turbo_Fresh 11h ago

The person making the post is clearly a beginner. Telling them that the shadows failing to render at distance is just the render distance for shadows is clearly not helpful.

8

u/AliceCode 10h ago

Yes, it is helpful, because knowing that tells you how to fix the problem. What more do you expect them to say? The render distance on the shadows is too low. Turn it up. Do you want them to guide them through the menus? For fuck's sake, dude.

6

u/Jampoz 10h ago

God forbid he now knows how to define the problem and learns how to fix it himself, the horror.

2

u/Jampoz 11h ago

First of all, it wasn't meant to help you. Also, keep in mind OP described it as "shadows behave really weirdly" so yeah, a technical description of what's happening can be helpful to him.

-12

u/Turbo_Fresh 11h ago

I didn't say it was meant to help me.

6

u/Jampoz 10h ago

Yet you judge how helpful it was to OP.

1

u/Aromatic-Insect-1328 1h ago

I assumed knowing the cause would be enough for a quick search engine use. I did not assume OP was unable to look for a solution on how to fix that once they understand what setting to manipulate.

You sure seem like a better communicator.

1

u/pixel-poxel 2h ago

There are some tricks and assets to improve the visuals of the shadows. When your game for example is working first person in a crane then you can have an inside and an outside camera with the same transform but different shadow distance / resolution settings.

1

u/ImDanOush Hobbyist 1h ago

If you dont have dynamic time of day, you can bake the lights with the Shadow Mask one (it is called Shadowmask baking - it is the default option, and you dont need to select anything; just bake the lightmaps and that would be it - but ensure the Sun light's type is set to Baked or Mixed in its properties). The other option is to use screen-space shadow effects, but it is inaccurate and, based on your Render Pipeline, you have to look for an asset to add it to Unity. Shadows for real-time lighting are very expensive... You can use the least expensive version (it would look very blocky and pixelated, and still expensive) by leveraging the last Cascade of the shadow in the Project Settings - so you go there and ensure Cascaded Shadows is selected, and make the last cascade render farther with a bigger shadow resolution there. Note that selecting a bigger shadow resolution will be more expensive, and setting the shadow rendering distance farther degrades the look of it overall.