-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved lightmap baking performance and workflow #7900
Comments
In terms of probes, also would it be helpful to have a way to distribute them in the scene. The subdivision works great in small scenes but doesn't do much in large scene. Also you don't need proves everywhere. A node where you can define an area and a separation of probes will be ideal for this. Also, having the lightmap not saved could help to rebake probes only if they where move or distributed diferently. Is this posible? |
There are a lot of tips in this GDC talk about improvement the bake time, runtime and UX/workflow of lightmapper that could be useful for Godot too: |
For many types of games, you only need lightprobes to be present near the ground, so I suppose there could be a property to control how far above solid meshes lightprobes should be present. |
But not all solid meshes need it. Imagine for example the TPS demo. You only need probes where the player can go |
@reduz does it make sense to separate the lightmap in diferente texture files for large scenes to make it more stable when baking? |
Describe the project you are working on
Godot
Describe the problem or limitation you are having in your project
Despite the process of baking lightmaps itself in Godot 4 being really fast thanks to the GPU based lightmapper, the rest of the experience is cumbersome and slow on the usability side.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
This is a combination of proposals, both technical and usability related to make the baking process much more comfortable.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Utilize a BSP cache
After finishing lighting, Godot needs to generate a BSP tree from the probes so the probe interpolation process can be efficient. This consisting of:
This is slow and its done every frame. The code is here:
https://github.com/godotengine/godot/blob/master/scene/3d/lightmap_gi.cpp#L1129C2-L1129C2
And ends with a call to
gi_data->set_capture_data(bounds, interior, points, sh, tetrahedrons, bsp_array, exposure_normalization);
My suggestion here is to do as follows:
Pseudocode:
In this part of the code:
https://github.com/godotengine/godot/blob/master/scene/3d/lightmap_gi.cpp#L1129C2-L1129C2
Do:
Keep in mind the hash now needs to be serialized in LightmapGIData. you can do by modifiying these functions like this:
Split the UI in Bake and Save
Currently the UI looks like this:
Ideally, it should look like this:
The idea is that there are 3 selectable modes:
How are each implemented?
Separating Bake and Save
Baking should happen as now, but the actual references to textures resources inside LightmapGIData should not be
overriden until the save step happens. After baking, they should be overriden in RenderingServer but not the resource. Likewise the LightmapGIData should not be saved untl Save is pressed.
Pressing the revert button will restore in RenderingServer the textures inside LightmapGIData.
The code now is hacky AF:
https://github.com/godotengine/godot/blob/master/scene/3d/lightmap_gi.cpp#L123C1-L123C3
This function should be moved to something like:
Its important that currently, baking happens WITH NO VRAM COMPRESSION, this needs to be corrected in the new workflow, so we always use VRAM Compression (BC6H on PC, ASTC on Mobile).
When saving, saving textures and saving LightmapGIData should happen at the same time.
If this enhancement will not be used often, can it be worked around with a few lines of script?
N/A
Is there a reason why this should be core and not an add-on in the asset library?
N/A
The text was updated successfully, but these errors were encountered: