godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.55k stars 21.27k forks source link

Changing horizon or top color of Procedural Sky causes lag spikes #54397

Open Miziziziz opened 3 years ago

Miziziziz commented 3 years ago

Godot version

3.3.mono.stable and v3.4.rc2.mono.official

System information

Windows 10

Issue description

If you try modifying the horizon or top color of a ProceduralSky in a WorldEnvironment node you get random lag spikes. This happens both when modifying through scripts and animations. I would expect this to not cause issues as I want to change sky color for weather effects or day/night cycles

Steps to reproduce

create a scene with a WorldEnvironment and a ProceduralSky, then have a script that runs this code:

func _process(delta):
    $WorldEnvironment.environment.background_sky.sky_horizon_color = Color.white

run the profiler and you'll see lag spikes

Minimal reproduction project

AnimatedSkyLagTest.zip

Calinou commented 3 years ago

This is expected in 3.x, since the radiance map needs to be regenerated every time a sky property is changed. In 4.0, you can set the sky update mode to Real-Time which makes changes apply much faster.

In the meantime, you can add a MeshInstance with a large SphereMesh that's parented to the camera. The sphere's size should be slightly smaller than your camera's Far distance. Add a material with the cull mode set to Front, and texture it accordingly. This sphere won't be reflected in the radiance map, but you'll be able to rotate the mesh and update its texture at no cost.

@clayjohn Should we add a boolean property to temporarily freeze radiance map updates in 3.x? This would let people update the sky in a smoother fashion, at the cost of reflections being incorrect until you unfreeze the radiance map updates.

Zireael07 commented 3 years ago

@Calinou: Nice trick, can it get documented somewhere?