I would like to bake lightmaps after creating a map with a runtime level editor. I understand that it is not possible to call the Bake function at runtime. I can't use VoxelGI or dynamic lighting for technical reasons.
So my question is:
Is it possible to save the map made with the level editor, use a headless godot editor to bake the lightmaps of the saved scene and then reload the map back in the runtime level editor?
Unfortunately, it’s not technically possible to achieve this since LightmapGI.bake() is currently not exposed to scripting, not even in editor builds. Since it is possible for headless mode to make use of local RenderingDevices (and therefore access the GPU for compute), it should be possible to achieve what you desire if this is exposed.
Additionally, remember that you need a GPU to bake lightmaps in 4.x. While this won’t impact your particular use case (since the player’s machine will always have a GPU), a server will generally not have a GPU to use. You could install software Vulkan emulation (Lavapipe) to remedy this, but it will be very slow and probably take 10+ minutes to bake a small lightmap.
No issue for the GPU requirement in my case indeed.
If I understand well, I will have to ship the editor with the level editor, compiled from source code with Bake() exposed. Is it possible to only compile what’s needed for lights baking?