Skip to content
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

Add a Preview Bake button for quick iteration with LightmapGI #80518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 11, 2023

When using the Preview Bake button instead of Bake Lightmaps, low quality settings will be used instead of settings from the LightmapGI node. A node configuration warning will be displayed
besides the LightmapGI node to inform the user that the bake was done in preview mode. This preview bake warning is persisted to storage to make teamwork easier.

This helps iterate quicker on a scene's lighting since you don't need to wait as much time to see results.

On a simple test scene, Preview Bake is about 3 times faster than a "final" bake with the default LightmapGI settings (if denoising is not the bottleneck). This metric will vary depending on CPU and GPU speed, as the baking process is performed on the GPU but denoising is performed on the CPU.

The preview bake settings can be adjusted in the Project Settings.

This also prints a message with the effective quality settings before beginning the lightmapping process.

Testing project: test_lightmap_preview_bake_4.x.zip

Preview Bake

image

Preview bake result

Note

Tangents are a bit broken on this scene, so there are artifacts that would usually not appear.

4 seconds to bake.

Screenshot_20240118_203800 webp

"Final" bake result

16 seconds to bake.

Screenshot_20240118_203828 webp

@Zireael07
Copy link
Contributor

Note that as mentioned on the 3.x PR, you can use the preview bake in your projects if your computer is too weak to handle the full bake.

@Calinou Calinou force-pushed the editor-add-lightmapgi-preview-bake branch 2 times, most recently from f6148ed to 4691061 Compare August 18, 2023 09:49
@verypleasentusername
Copy link

is this implemented?

@YuriSizov
Copy link
Contributor

@verypleasentusername No, this PR is still very much open.

@Calinou Calinou force-pushed the editor-add-lightmapgi-preview-bake branch from 4691061 to 28e5f04 Compare January 18, 2024 19:38
@Calinou
Copy link
Member Author

Calinou commented Jan 18, 2024

Rebased and tested again, it works as expected.

  • Add support for texel scale multiplier, which defaults to 0.5 (half resolution on each axis for preview bakes). This speeds up bakes a lot without having to disable denoising or directional baking.
  • Change the default maximum number of bounces for preview bakes to 2, which looks significantly closer to high bounce counts compared to 1. The reduced texel scale makes it more viable.
  • Removed toggle for denoiser and directional, as denoising is now very fast and directional impacts visuals too much to be worth toggling for preview bakes.

@Calinou Calinou force-pushed the editor-add-lightmapgi-preview-bake branch from 28e5f04 to 0b22b12 Compare January 24, 2024 15:16
@ARez2
Copy link
Contributor

ARez2 commented Aug 13, 2024

Could this be merged?

@Calinou
Copy link
Member Author

Calinou commented Aug 13, 2024

Could this be merged?

4.3 is currently in release freeze, so new features can only be merged in 4.4 at the earliest.

In the meantime, you can decrease Texel Scale before baking and increase it again after baking. This is the single largest contributing factor to bake times in my experience.

@ARez2
Copy link
Contributor

ARez2 commented Aug 13, 2024

Yep! That's what I am doing. Good to hear that this will be considered for 4.4 though!

@badsectoracula
Copy link
Contributor

I fixed the conflicts and tested this (with some quick perusal of the source code). It is very useful as it allows for quick previewing of lighting (though some way to bake everything in the map is also needed).

I put the fixes here as the conflicts are actually straightforward even if they did confuse git somewhat: https://github.com/badsectoracula/godot/tree/lightmapping-preview-bake

@Calinou
Copy link
Member Author

Calinou commented Dec 5, 2024

Thanks for rebasing this PR! I'll incorporate the changes shortly.

(though some way to bake everything in the map is also needed).

See godotengine/godot-proposals#10323.

When using the Preview Bake button instead of Bake Lightmaps,
low quality settings will be used instead of settings from the
LightmapGI node. A node configuration warning will be displayed
besides the LightmapGI node to inform the user that the bake
was done in preview mode. This preview bake warning is persisted
to storage to make teamwork easier.

This helps iterate quicker on a scene's lighting since you don't
need to wait as much time to see results.

On a simple test scene, Preview Bake is about 3 times faster
than a "final" bake with the default LightmapGI settings
(if denoising is not the bottleneck). This metric will vary depending
on CPU and GPU speed, as the baking process is performed on the GPU
but denoising is performedon the CPU.

The preview bake settings can be adjusted in the Project Settings.

This also prints a message with the effective quality settings
before beginning the lightmapping process.
@Calinou Calinou force-pushed the editor-add-lightmapgi-preview-bake branch from 0b22b12 to 27f792e Compare December 5, 2024 16:45
@Calinou Calinou requested a review from a team as a code owner December 5, 2024 16:45
@Calinou
Copy link
Member Author

Calinou commented Dec 5, 2024

Rebased and tested again (with @badsectoracula's help), it works as expected.

There was some discussion recently about making baking and saving lightmaps separate operations, so that the preview bake could bake lightmaps without saving them. While this would be slightly faster (especially when developing on a device with slow I/O), it would also prevent using the preview lightmaps when playtesting a project, which can be problematic for some use cases. Sometimes, you want to be able to run the project with some kind of baked lightmaps, even if you don't have the time to do a full lightmap bake.

@badsectoracula
Copy link
Contributor

There was some discussion recently about making baking and saving lightmaps separate operations, so that the preview bake could bake lightmaps without saving them. While this would be slightly faster (especially when developing on a device with slow I/O), it would also prevent using the preview lightmaps when playtesting a project, which can be problematic for some use cases. Sometimes, you want to be able to run the project with some kind of baked lightmaps, even if you don't have the time to do a full lightmap bake.

The editor already autosaves any modified scenes when you press the play button so it could also autosave the lightmaps when you want to play. I think overall being able to playtest without saving would be a good idea as you may want to try out things without saving - and could probably be implemented via some sort of saving any unsaved modified resources to a temporary file and then passing mappings like "map all loads for foo.tscn to /tmp/blahblah/foo.tscn" or something like that to the launched game process.

But i think this is something for a different topic/proposal than this and could be implemented in the future regardless of having preview bakes or not (which i find very useful) as i don't see any reason to not save (automatically like now or as a separate step in a future change) the preview lightmaps for gameplay testing. At the end it is just different settings for the lightmapper and you may even want to distribute builds with preview lightmaps (e.g. testers who could be testing your gameplay but not necessarily the final graphics will probably still need to know where there are shadows but not care about light leaks or noisy lightmaps).

@KoBeWi
Copy link
Member

KoBeWi commented Dec 30, 2024

Needs another rebase .-.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a "Preview Bake" button for LightmapGI for quick preview bakes
7 participants