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 global lightmap texel size multiplier in LightmapGI to speed up preview baking #3893

Closed
Tracked by #56033
Calinou opened this issue Jan 29, 2022 · 2 comments · Fixed by godotengine/godot#64908

Comments

@Calinou
Copy link
Member

Calinou commented Jan 29, 2022

Related to #2029 and #3233.

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

There is currently no way to quickly override lightmap resolution by a global factor before the lightmap is baked. The main use case for doing this is for "preview" baking while iterating on lighting. A lower resolution can be used to speed up baking by a significant amount (often a factor of 3×-4×, if not more).

Godot 3.x has a Default Texels Per Unit property, but it only affects meshes that do not specify their own density. Most imported 3D scenes do define a lightmap texel density, as the Import dock will do so for you.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a property that multiplies the global lightmap texel size before baking lightmaps.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add a Texel Scale property to LightmapGI which scales the lightmap texel density of all meshes for the current bake. This is a multiplier that builds upon the existing lightmap texel size defined in each imported 3D scene, along with the per-mesh density multiplier (which is designed to be used when the same mesh is used at different scales).

This feature is relevant for both the GPU lightmapper master and the CPU lightmapper in 3.x. While baking lightmaps is quite fast on master already, there are opportunities to make preview baking even faster, so let's seize the opportunity 🙂

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, but it requires reimporting all 3D scenes used in the current scene with a higher texel size value. Reimporting takes a lot of time to do in a complex scene, and it requires a lot of clicks throughout the day if you spend a lot of time iterating on lighting.

Is there a reason why this should be core and not an add-on in the asset library?

See above.

@Calinou Calinou added this to the 4.x milestone Jan 29, 2022
@Calinou Calinou changed the title Add a lightmap texel size multiplier in LightmapGI to speed up preview baking Add a global lightmap texel size multiplier in LightmapGI to speed up preview baking Jan 29, 2022
@marcinn
Copy link

marcinn commented Aug 25, 2022

Hi.

Here is a possible patch: https://gist.github.com/marcinn/703a0c7bb94f3bbfd4156fbc378eb5d5

Seems to be working as expected, but I would like to talk about details like hint range or additional error messages (before submitting a PR). I decided to add a new BakeError for a case, when width or height of a lightmap_size is zero. In this case the editor will show quite precise error message.

Also this case may be related with godotengine/godot#63423. The patch will not solve the issue, but should show the error message instead of hang.

@Calinou
Copy link
Member Author

Calinou commented Aug 25, 2022

but I would like to talk about details like hint range or additional error messages

I think the hint string should be 0.01,100.0,0.01 (between 100 times more precise than default and 100 times less precise than default, with adjustments by 1%).

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

Successfully merging a pull request may close this issue.

3 participants