Open Favkis opened 1 year ago
I can reproduce the issue on Linux with 3.5.2.rc1.
Here's a more minimal reproduction project extracted from the above, removing the mesh, materials, navigation, DirectionalLight and WorldEnvironment.
Just rotating cubes on top of the ground mesh, which is the only one used in lightmap, is enough to trigger the performance issue.
What's interesting is that simply ticking BakedLight off fixes FPS issue and doesnt really disabled backed lights lol, so it basically works but you just tick visibility in editor or from script.
Try disabling Capture in the BakedLightmap node then bake lightmaps again. I suspect dynamic object capture is too slow to handle lots of objects (among its visual issues).
After doing this, re-enable Capture, bake lightmaps again and check if the bottleneck is on the CPU or GPU. You can use the Windows task manager for this purpose, or external tools such as RTSS.
Try disabling Capture in the BakedLightmap node then bake lightmaps again. I suspect dynamic object capture is too slow to handle lots of objects (among its visual issues).
After doing this, re-enable Capture, bake lightmaps again and check if the bottleneck is on the CPU or GPU. You can use the Windows task manager for this purpose, or external tools such as RTSS.
I think I might be wrong about ticking .visibility makes bakedlight still be in scene, Im not sure, maybe I confued it with my dynamic shadows, Im confused by baked mods for shadows... Anyways I tried rebakign without .capture, now even with BakedLightmap visible I have very high FPS.
Hi, it seems _light_capture_sample_octree is the slowest part of the process, based on these profiler's results:
@lawnjelly do you have any suggestions to optimize it?
Alas I know next to nothing about the core Lightmapper dynamic lighting. More @JFonS area.
Alternatively you may be able to use https://github.com/lawnjelly/godot-llightmap (but beware it requires custom shaders). The light probes are super cheap and cheerful (and work in gdscript).
I tested godot-llightmap weeks ago but it has its problems like sometimes in unwrapping stage some parts of geometry will be destroyed or because of using custom shaders I wasn't able to use direct and indirect lighting together.
This is the expensive function: https://github.com/godotengine/godot/blob/7722461dc5a679379a1d13aec8747b7669ce81be/servers/visual/visual_server_scene.cpp#L2206-L2360
Maybe we should get rid of anisotropy, as it's known to be very expensive when sampling this kind of data. It will result in lower indirect lighting quality on dynamic objects, but it should be better than not using any kind of dynamic object capture.
For reference, VoxelGI optionally used anisotropy in early 4.0 (before alpha1) and it was removed as it was too expensive.
https://github.com/godotengine/godot/pull/80764 improves performance significantly, but it's still not enough to reach 60 FPS in all scenarios on slower CPUs. As a result, I'll leave this open.
I think https://github.com/godotengine/godot/issues/71162#issuecomment-1421581025 is still worth pursuing :slightly_smiling_face:
Godot version
3.5.stable
System information
Windows 10, GLES3
Issue description
Having BakedLightmap enabled makes your FPS fall down drastically if you change rotation, traslation or play animation for mesh.
Steps to reproduce
Bake lightmap, move objects around.
Minimal reproduction project
https://files.catbox.moe/iqn644.zip