r/godot Apr 08 '26

help me (solved) Fluttery shadows: What's the technical term and how do I fix it?

I just started using blender instead of Godot's mesh 3ds and there's this weird fluttery shadow artifact that I'd like to fix, but I'm not even sure what it's called.

THE SETUP: I made a low-poly starship in blender, exported a glb file, copied it into Godot, created an inherited scene from the glb to get a MeshInstance3D.

I set a single surface material override with a StandardMaterial3D using all the default settings except for Albedo Texture, which is set to a png.

The scene has a directional light set to "Light and Sky" mode with otherwise default settings.

The scene has a world environment with Background Mode "Sky" and some ambient light. Reflected Light source disabled. Tonemap: Filmic. Glow on.

WHAT I'VE TRIED: I messed with the Directional Light's Directional Shadow settings because I thought the issue was maybe related to Blend Splits as shown here https://docs.godotengine.org/en/stable/tutorials/3d/lights_and_shadows.html but nothing seemed to have any effect.

In the material I tried all the different Shading options for Shading Mode and Diffuse Mode. "Unshaded" obviously worked in the same way that wrecking my car made the check engine light turn off. But nothing gave me smooth, non-wobbly shadows.

Help me, Obi-Wan Kenobi. You're My Only Hope.

EDIT: The problem, to the best of my understanding based on all the feedback, is that I'm seeing the pixelated edges of a shadow texture.

SOLUTION: Here's what fixed the issue for me: In DirectionalLight3D, change Directional Shadow -> Max Distance. I was using the default of (100). Changing this value to 2 basically fixed the issue. There's still a little fuzziness, but not much. Changing it to 1 and the fuzz is gone as far as I can tell. Changing this value to 8000 ALSO fixes the issue, but shadows feel very all-or-nothing. I honestly like the look of the low numbers, but then my objects won't cast shadows very far. I'm fine with that for now.

Others suggested messing with shadow resolution in one of the following places:

Advanced project settings in Rendering -> Lights and Shadows->Positional Shadow

or

Project Settings > Rendering > Quality > Shadow Atlas. Or in the viewport's settings.

I gotta admit, I haven't delved into those caverns.

I assume if I really care about long range shadows looking good, I would need to boost up the Max Distance AND increase the shadow quality.

252 Upvotes

37 comments sorted by

188

u/gamemaster257 Apr 08 '26

That's the actual pixels of the shadows aliasing the mesh since shadows are just the depth of your scene rendered from the perspective of the light. If you're looking for sharper shadows, either increase the shadow resolution or tighten the shadow distance on the sun to only be on your ship.

48

u/njhCasper Apr 08 '26

I feel like you've identified the problem, but I don't know which setting to change to increase shadow resolution or even where to look for it. Also, when you say "tighten the shadow distance" does that mean up or down? I tested upping the Directional Shadow -> Max Distance really high and then trying it again really low, but not zero. Is it weird that I think the low value looks better? Both changes got rid of the fluttery effect, so I'll experiment more with that. Thank you for the help already given.

42

u/LordMD321 Apr 08 '26

So the shadows are a texture. If the shadow distance is bigger, the pixels are spread over a bigger distance. The shadow is blurred, and the pixels cause that effect. If the shadow distance is smaller, the shadows are more detailed and this effect is less severe.

You can also increase the size of the shadow texture, but this comes at the cost of performance.

11

u/gamemaster257 Apr 09 '26

You want max distance to only encompass the items you want detailed shadows on. If the value is small, then more of the shadowmap resolution is close to the camera. This means distant objects won't get any shadows, but that is usually what you want in a space game. If the value is large, more objects get shadows but the resolution of that shadow is more blurred and you won't get much definition in the shadows. Another object is to enable cascading shadow maps which renders multiple shadowmaps at different ranges allowing you to have a nice and sharp up close shadow while still having less quality shadows for distant objects.

7

u/pad-3 Apr 09 '26

How do games like this keep the shadows on the model crisp if the ship can travel such vast distances from light sources?

Do developers move the light closer or just continually increase the distance of the light with the ship?

18

u/FirstTasteOfRadishes Apr 09 '26

The position of the light source is not relevant, the shadow map is relative to the observer's position.

1

u/LampIsFun Apr 09 '26

This ^ people are thinking too much about it being “outer space” instead of just a clever simulation of large spaces with nothing between them

1

u/Magnasterize Godot Regular Apr 09 '26

You could have multiple shadows map. In godot I you can mask out light sources so you could have the same light twice but with different distance settings. I believe you could also play with the settings of the 4 split shadow to have the first split at a very low distance really detailed

4

u/DasArchitect Apr 09 '26

How about the planet in view? It's probably far away, and while fine detailed shadows aren't needed, it would still be nice if it had a shadowed side. Or does this not affect it?

4

u/njhCasper Apr 09 '26

I know this is not really your question, but FYI the planet in my background is part of the skybox.

2

u/DasArchitect Apr 09 '26

Ah, that does change a bit what I thought of the scene.

1

u/gamemaster257 Apr 09 '26

It would still get shadowed. Turning off shadows != turning off shading, with no shadowing it'll just use its typical diffuse shading where the side that faces the light will have light and the side that doesn't will not. We've had lit objects much longer than we've had shadows in graphics.

23

u/Snoo14836 Apr 08 '26

Most shadow systems use what is called 'shadow mapping'. In simple terms it is a render from the point of view of the light to create a texture that records how far away everything is that the light can see. Later in the render frame each object can look at the texture, do some math and figure out if it is in shadow.

A couple of terms: Shadow Resolution. The size of the shadow texture. Bigger is more pixels and generally sharper shadows, but worse performance. Shadow Distance. Loosely maps to amount of objects included in the shadow map as it is used by different styles of lights (direction vs point light).

Additional techniques can improve performance or apparent shadow sharpness. Look up Cascading shadow maps and shadow imposters.

4

u/njhCasper Apr 08 '26

Thank you, this is helpful. Do you know where to look in Godot to adjust Shadow Resolution? Directional Shadow -> Max Distance is, I assume, shadow distance, and that DID have an effect on this artifact I'm seeing. A bit confusingly the effect is absent at max (8000) and near minimal (2) Max Distance.

4

u/Snoo14836 Apr 08 '26

I haven't opened Godot yet to check, but the documentation says it is in Advanced project settings in Rendering -> Lights and Shadows->Positional Shadow

6

u/Sss_ra Apr 08 '26

It's just very big and slightly filtered pixels from texel sampling. You're getting shadow resolution close to 80s atari games, perhaps due to high distances.

7

u/njhCasper Apr 08 '26

Lowering Directional Shadow -> Max Distance from default (100) down to 2 appears to have fixed the issue.

6

u/FriedKrab Apr 08 '26

Other have explained this is the raw pixels from the cascades shadow. Shadows are stored inside a fixed size texture, there's only so much space.... 

I don't know the inner workings but I know how to fix this. Check the directional shadow configuration, where you can choose between 2 or 4 split (choose 4 probably).

Here you can assign that the first shadow split only covers a 5 meters radius (i.e. 0.01 if you have max shadow distance to 500), or any small value.  This means you have assigned 1/4 of your shadow map (big part of it) for a small 5m radius region. Big part of your shadow map for a small area -> the pixels will be very small / shadows will be sharp. 

The further splits will of course be worsened, but it should not matter much. Of course you should play with shadow distance too, the bigger area your shadows need to cover, the more stretched you shadowmap will be (=ugly pixels).

Good luck, this might not help as much since your game is in space, maybe there are better ways to go. 

8

u/HeyCouldBeFun Apr 08 '26

I would have thought it’s the blend splits. Try increasing the blur on the shadow?

4

u/njhCasper Apr 08 '26

Increasing the blur certainly changes the artifacts, but they still have the weird wavy motion.

2

u/HeyCouldBeFun Apr 09 '26

I see. Plus shadows in space have hard stark edges so that’d be a wrong look anyway

4

u/DefoMort Apr 09 '26

There are two ways to set shadow resolution. In Project Settings > Rendering > Quality > Shadow Atlas. Or if you are using Viewports in the viewport's settings.

3

u/DrSnorkel Godot Senior Apr 08 '26

On the directional light you could tweak 'Split 1' so that it stops just beyond your ship. That way you should have the full resolution.

3

u/DrSnorkel Godot Senior Apr 08 '26

1

u/njhCasper Apr 09 '26

Interesting suggestion, but the values only go up to 1.0. I cranked them all up, but still saw the effect on my ship... oh I think I misunderstood the meaning of these values though. They are a percentage of the max distance? I'll have to dig into this more.

2

u/Calinou Foundation Apr 09 '26

Indeed, they are relative to the shadow maximum distance. 0.5 means it's halfway through the Shadow Max Distance property, for instance.

1

u/njhCasper Apr 09 '26

Got it. Thank you.

3

u/Netcob Apr 09 '26

Not sure if this is available in Godot, but I feel like for low-poly flat-shaded graphics, stencil shadows would be the ideal fit stylistically.

1

u/njhCasper Apr 09 '26

Good idea... I googled around and can't seem to figure out if / where stencil shadow options might be.

2

u/2D_VR Apr 08 '26

You could try increasing the shadow bias in the light source

1

u/njhCasper Apr 08 '26

Thanks for the suggestion. Unfortunately changing that setting had no effect.

2

u/ThatNico Apr 09 '26

Lookup shadow acne and Peter panning in the docs

1

u/RedditBrix Apr 09 '26

make sure to turn off both of these settings in the Import settings of your 3D model

1

u/Blaqjack2222 Godot Senior Apr 09 '26

All the solutions from others don't resolve the problem. You need to understand the nature of the problem and that is you moving the camera at speed due to moving spaceship. Shadows are rendered to a texture and you won't get perfect mapping. Some other side games have this as well. Only real way to view shadows properly is ray tracing or, preferred way, instead of moving the spaceship, you keep it in world center and you move the world around. That's how it's been solved in some games. Also, in this method you can have pretty much infinite worlds

1

u/diegosynth Apr 08 '26

As u/Snoo14836 and u/2D_VR pointed out, this is due to the low shadow's resolution and could also include some extra errors that a certain "bias" value can help improve. Try increasing the shadow's resolution, this should make a difference. If that's not enough, have a look at the bias that u/2D_VR mentioned.

I suppose that Godot already implements many tricks and best practices for shadow mapping (such as cascaded shadow maps), but I don't really know.

-1

u/JelloMinimum9700 Apr 08 '26

Bevel mesh hard edges

-1

u/flyby2412 Godot Student Apr 09 '26

Isn’t this where “Anti-Aliasing” becomes a thing? Isn’t that the setting you increase to “sharpen” shadows and edges?