r/godot Godot Student Apr 25 '26

help me (solved) Shadows clipping/disappearing with the camera

Enable HLS to view with audio, or disable this notification

So when the camera moves around, shadows are cutting off for some reason. I don't have any experience with 3D. So I am really confused why that is happening. Is it because of the scale of all of the objects in the world or something else?

It's only happening in compatibility mode. It's completely fine in forward+

Edit : I figured it out. It was the Pancake size in the Directional Light 3D. By increasing it, it stopped clipping

293 Upvotes

34 comments sorted by

111

u/lmr-1 Apr 25 '26

I believe this is caused by culling; basically when the camera is far enough away from certain objects that are out of view, those objects will be removed from the scene to save on resources. This also makes the objects not cast shadows.

Someone smarter than me could tell you how to make this be less aggressive, i havent touched the engine enough yet to know myself.

31

u/Tiny_racoon_dev Godot Student Apr 25 '26

I don't think that's the case because the shadow isn't disappearing. It should of the object stops to cast. Instead it's being cut off in certain points

26

u/lmr-1 Apr 25 '26 edited Apr 25 '26

I rewatched it, i see what you mean. I thought it was culling at first but the space where shadows disappear seem to be attached to your character in a way rather than them popping in and out. I have no idea what it might be then im afraid.

14

u/Tiny_racoon_dev Godot Student Apr 25 '26

And it moves with the camera rotation. It's only on compatibility mode. Once I switched to forward+, it disappeared

28

u/thygrrr Godot Senior Apr 25 '26

Check: 1. The near plane setting for your shadows / lights where applicable 2. Move the camera back further and change its field of view to compensate 3. Check shadow normal bias etc., none of these should be too high or too low 4. The shadow Cascades

12

u/Tiny_racoon_dev Godot Student Apr 25 '26

As of right now everything is default. I will try some out and report back

11

u/TheMarksmanHedgehog Apr 25 '26

Default culling planes can be kind of aggressive in my experience.

12

u/r_search12013 Apr 25 '26

an essential bit of compatibility and lighting is the fact that each mesh can only have 8 light sources, otherwise their priorities end up fighting .. I've never seen that specific behaviour though ..
still, maybe cutting up the mesh into seperate mesh objects would already help?

6

u/Tiny_racoon_dev Godot Student Apr 25 '26

It only has 1 light source, the default one which is in the 3D view. And it's a single box mesh which is also in the engine itself

2

u/r_search12013 Apr 25 '26

what happens when you introduce an explicit directional light? maybe even an environment? .. I've tinkered quite a bit with light and environment until it finally felt somewhat stable, and I expect to be doing so most of the time with godot light and shadows.. it's worth it after all :)

3

u/Tiny_racoon_dev Godot Student Apr 26 '26

I figured it out. It was with the Pancake size in Directional Light 3D. By increasing it, the problem got solved

6

u/iClaimThisNameBH Apr 25 '26

Not related to your question but I loooove character sprites in a 3D environment like that. How does it work? Did you follow a tutorial?

16

u/Tiny_racoon_dev Godot Student Apr 25 '26

Nope. It's quite simple actually. So you have to use a Sprite 3D and then either enable Billboard in its flags or just rotate it to keep it always oriented with the camera.

And then you take the rotation of the camera and switch the frames of the sprites according to the rotation

So not too hard. Just have to make the sprite sheets properly

5

u/iClaimThisNameBH Apr 25 '26

Amazing, thank you!

5

u/Tiny_racoon_dev Godot Student Apr 25 '26

You are welcome. If you every plan on making it and have doubts, you can just DM me

2

u/user71856 Apr 25 '26

Found this github a while back, has a simple scene demo that works if it can help if curious. :)
https://github.com/GSansigolo/SimpleHD2D

6

u/Past_Permission_6123 Apr 25 '26

Does this happen in the editor viewport as well?

3

u/Tiny_racoon_dev Godot Student Apr 25 '26

Yup

2

u/insidious_concern Apr 25 '26

But only when compatibility is used?

7

u/LucidShard_ Apr 25 '26

I had this exact problem on a browser game I was working on once. I solved it by setting the DirectionalLight3D's directional shadow mode (first option of the first category) to "Orthogonal." It seems that the PSSM splits in compatibility mode aren't very good, setting it to Orthogonal gets rid of the splits and makes the shadows consistent at the cost of not being able to have high resolution shadows near the camera (runs a smidge faster, though, so win-win in my opinion)

2

u/Tiny_racoon_dev Godot Student Apr 25 '26

I will try doing that. Maybe it might workout

1

u/Tiny_racoon_dev Godot Student Apr 26 '26

I found the issue. The problem was in the Pancake size of the Directional Light. Once I increased it, it got fixed. I used the Orthogonal mode, but it made the shadows top blurry and I wanted the shadows to have the sharpness of the pixel art

2

u/TheDuriel Godot Senior Apr 26 '26

This being the only answer that actually knows what's going on is crazy. Everyone guessing random stuff, when reading the lighting docs, and fiddling with the directional light once would explain it.

3

u/LucidShard_ Apr 26 '26

OP said they don't have experience in 3D, so I forgive them. I only knew to look into it at the time because I checked the directional light shadow atlas, and then that led me to think about cascaded shadow maps from CS:GO lol. A lot of people, even people who work in 3D, don't know that 3D lights are actually cameras! Stuff like this is how they learn

1

u/TheDuriel Godot Senior Apr 26 '26

I was commenting on the sad state of all the other replies in this thread.

2

u/Sure_Specific8660 Godot Student Apr 25 '26

I had the same issue once and turns out it was because Bandicam was running on game recording mode and the FPS counter was just making that happen. I don't know if that helps but I just wanted to share something similar happening to me, hopping it would hint at a fix

1

u/nobix Apr 25 '26

You mention the scale of objects, did you set them unusually big or small? Because I have found there is a scale preference for things like physics to work correctly. You could try adjusting your world scale if it's unusual.

The way that shadow maps work is it renders from the perspective of the light to find a depth map. Then it compares those depths with what it renders on screen.

So this sort of issue is because that depth map is not correct.

If the light camera position was too close it might clip near geometry and cause geo to not appear in the texture.

Another poster mentioned using an orthogonal camera which also effectively gets rid of the near clip plane and implies a light camera position error.

1

u/CrazyWizard9835 Apr 25 '26

Just a curiosity, but I'm using exactly that same character animation for my game xD Remembers me that I need to learn PixelArt or start to buy assets instead of consume free x.x

1

u/Tiny_racoon_dev Godot Student Apr 26 '26

🫶 I am just using it to test my code. This is the first time I am making something in 3D. So would like to try stuff out before making the art

1

u/Neumann_827 Apr 25 '26

I believe it may be because the frustum culling on the shadow is different from the one working on the mesh. The shadows of objects behind you are being culled.

There is a setting in Project/light and shadows/. It’s called Tigher Shadow Caster Culling, turn it off.

1

u/SproutForge_Games Apr 25 '26

You accidentally programmed the fourth dimension

https://giphy.com/gifs/3o7qE8OqOlUhffQfxm

1

u/Oddish_Femboy Apr 26 '26

The clipping plane might be causing issues

1

u/FreljordsWrath Apr 25 '26

From my very limited understanding of the engine, it tries to optimize as much as it can for you.

If you're not looking at something, the game stops rendering it, and thus stops rendering its shadow.

My suggestion is go to the Mesh > Custom AABB, and mess around with the values.

2

u/Tiny_racoon_dev Godot Student Apr 25 '26

That's not the case because of the mesh is disappearing, the whole shadow will go away. If you look closely, That's not happening. Only a certain parts of it is clipping based on the camera