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

Change LightmapGI Global Texel Scale to Texels Per Unit #9116

Open
WickedInsignia opened this issue Feb 17, 2024 · 4 comments
Open

Change LightmapGI Global Texel Scale to Texels Per Unit #9116

WickedInsignia opened this issue Feb 17, 2024 · 4 comments
Labels
breaks compat Proposal will inevitably break compatibility topic:rendering topic:3d

Comments

@WickedInsignia
Copy link

WickedInsignia commented Feb 17, 2024

Describe the project you are working on

Graphics-intensive demo scenes

Describe the problem or limitation you are having in your project

Right now Godot doesn't have any way to define Texels Per Unit.
This format of measurement is essential to obtaining reliable and predictable lightmap quality/scale results.

All methods to define lightmap texel density rely on arbitrary units.
Lightmap Texel Size in the import dialgoue is an arbitrary decimal:
GodotImportTexelSize

Global Illumination Settings in a Mesh Instance's properties is a multiplier based on that arbitrary decimal:
GodotMeshGIPrompt

The global Texel Scale in Lightmap GI is an arbitrary multiplier based on that arbitrary decimal again:
GodotGlobalTexelScale

It makes no sense to use these undefined and unrecognized units of measurements in lightmapping. Nowhere in the interface nor the manual does it state how these decimals relate to the standard Texels Per Unit or how they precisely relate to the lightmap image itself.

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

Unity lets the user define a Texels Per Unit size globally in the lightmapping dialogue. In this case "unit" refers to meter, so if you input 40 you will get 40 pixels in lightmap space per meter on each mesh surface:
Unity_TexelsPerUnit

This is predictable, efficient and easily visualized. In the below image each checkerboard tile represents 1 pixel in the lightmap. This is for a scene with 5 texels per unit:
Unity_TexelDensity

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

  • Remove the option to set texel scale in the Import dialogue. This is not needed if a global setting is available in LightmapGI and each individual mesh instance's size can be further refined individually with a multiplier based on this global scale.
  • Instead of users defining texel density on import, they should only define the minimum expected resolution that mesh will use so that padding and island positioning during lightmap unwrap is suitable. A reasonable default should be used (such as 10 texels per unit) to prevent users needing to adjust this property frequently.
  • Change the global Texel Scale in LightmapGI to use Texels Per Unit instead. Since Godot's unit of measurement is meters, this would be Texels Per Meter.

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

Will be used often.

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

Core functionality.

@Calinou
Copy link
Member

Calinou commented Feb 18, 2024

Switching to texels per unit sounds good to me. It can be done without breaking compatibility by adding compatibility handlers that automatically set the new property to the correct value (1.0 / texel_size).

Lightmap unwrapping should occur at bake time, taking the Global Texel Scale into account and padding islands accordingly.

A single mesh can be featured in several LightmapGI instances in several scenes at different scales, so this approach is unfortunately not viable with the 1:1 mapping expected between the source mesh and the imported mesh (including its UV2).

@WickedInsignia
Copy link
Author

A single mesh can be featured in several LightmapGI instances in several scenes at different scales, so this approach is unfortunately not viable with the 1:1 mapping expected between the source mesh and the imported mesh (including its UV2).

I considered this incorrectly: unwrapping should happen on import but island positioning should happen at bake time, for the reason you mentioned. Which is how it's handled in other engines and I assume already happens in Godot. My mistake!

What would be useful is a Min Lightmap Res and Min Object Scale prompt on import, which tells the unwrapper to pad and position islands upon unwrap to suit the minimum lightmap res and scale expected by the user. Or an island padding prompt to a reasonable default (for say, 10 texels per unit or whichever is a somewhat standard quality level). Unity currently uses the former, and used the latter in earlier iterations.

UnityMinLightmapRes

Either option would prevent defining the texel resolution on import, since defining it then is a major inconvenience in a lightmapping workflow and requires an arbitrary multiplier to be used in LightmapGI rather than a global Texels Per Unit setting. Removing the need to multiply on top of what's defined on import would allow for Texels Per Unit to be used instead.

@passivestar
Copy link

I also found these options to be limiting, is there a reason it can't go below 100%?

image

Can it be an arbitrary number instead?

image

@Calinou
Copy link
Member

Calinou commented Mar 4, 2024

I also found these options to be limiting, is there a reason it can't go below 100%?

It's mostly a historical decision (also because these power-of-two values allow for optimal usage of the lightmap UV space). This is being tracked in #3233.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks compat Proposal will inevitably break compatibility topic:rendering topic:3d
Projects
None yet
Development

No branches or pull requests

3 participants