Jittery Shadows From Day and Night Cycle

Godot Version

Godot 4.3

Question

How to fix jittery shadows from the day and night cycle?

Hi! I’m back again with another lighting issue. This time with the new day and night cycle I implemented. I did end up splitting my giant procedurally generated world into chunks by mesh instead of having the entire world into one big mesh. That seems to have fixed all of my previous lighting woes except this one.

I have a video to share. I’m pretty sure it is either my day and night cycle calculations causing this or I need to tweak settings in Godot. I’ve messed around with bias but if I turn bias up too much only the large shadows show and I’d prefer to have all the shadows visible if possible.

I found another post about this issue and the solution was related to how the sun’s rotation angle was specifically the linear interpolation. I can share my code of how I’m doing it and you can leave your suggestions.

func _process(delta: float) -> void:
	time_of_day += delta / day_length
	if time_of_day > 1.0:
		time_of_day = 0
	var sun_angle = lerp(0, 360, time_of_day) - 180
	
	rotation_degrees.x = sun_angle

I’m new to the forum and also Godot itself, so if I messed up on formatting the code, let me know how to do it properly in the future.

Here is a link to an unlisted YouTube video about the problem.

[https://www.youtube.com/watch?v=TXGBhv_9_5s](Jittery Shadows Bug Video)

I would check the remote tab while the game is running to determine all possible light factors. Right now I believe two light bodies are processing at the same time, each are producing different shadows on the same objects.

If you set a breakpoint that stops the program, does the flickering still happen? The result may determine if the fault lies in the render pipeline or the processing pipeline.

1 Like

Hmm, interesting. I’d have to see that. I’ll take a look at the remote tab and get back to you when I get the chance.

Okay, so no extra lights are being created in the remote tab. Also, once the sun stops moving the jittering goes away. There is only one DirectionalLight 3D.

I think I may have found one of the potential culprits. In certain areas, there may be light leaking specifically giant hills and mountains. I could mess around with the amount of surface layers it generates to see if that fixes it or introduce double-sided meshes. The weird this is that I have cull disabled. That being said I only generate faces that are visible.