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 property to control emissive material energy in LightmapGI #82839

Open
Tracked by #56033
sandsalamand opened this issue Oct 5, 2023 · 8 comments
Open
Tracked by #56033

Add a property to control emissive material energy in LightmapGI #82839

sandsalamand opened this issue Oct 5, 2023 · 8 comments

Comments

@sandsalamand
Copy link

Godot version

4.1.2 stable mono

System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 30.0.15.1123) - Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 Threads)

Issue description

Weak_Emissive_Godot_4

Even with the Energy Multiplier in the StandardMaterial3D turned up to 100, well past the max for the slider, the light produced by the material is extremely weak. It also doesn't seem to be emitting from the correct location. I don't believe it's a problem of the textures, since the albedo and emission map are lined up properly in the material.

Steps to reproduce

  1. Bake the Lightmap in the reproduction project.
  2. Look at the light produced around the lantern.

Minimal reproduction project

Emissive+Lightmap Issue.zip

@sandsalamand
Copy link
Author

Sorry, I just realized that there are FBX models in the reproduction project. Let me know if I need to convert them to GLTF.

@Calinou
Copy link
Member

Calinou commented Oct 5, 2023

Sorry, I just realized that there are FBX models in the reproduction project. Let me know if I need to convert them to GLTF.

Please convert them to glTF to make the issue easier to reproduce locally.

Also, please test this with a box PrimitiveMesh in a MeshInstance that has a bright emissive material.

@sandsalamand
Copy link
Author

So after some testing, I realize that the problem is not with the lightmaps themselves, but simply the inability to adjust external emission intensity independently of the texture self-lighting.

image

In the above photo, the yellow emissive map looks great, but the lantern texture cannot be made to light its surroundings properly, because increasing the Energy Multiplier also ruins the color of the material.

image

@Calinou
Copy link
Member

Calinou commented Oct 7, 2023

This is something I've noticed in my own projects. Physical accuracy doesn't always lend itself well to good-looking results.

#82068 can likely help address this, although it currently only adds a parameter to multiply the energy of indirect bounces. Even without that PR, it shouldn't be too difficult to add an emission energy parameter in LightmapGI that multiplies the emission energy while baking lightmaps.

#49968 could also address this, but it's a global multiplier that affects the appearance of the entire lightmap.

@Calinou Calinou changed the title Emissive Materials Are Extremely Weak and Inaccurate when Baked in Lightmap Add a property to control emissive material energy in LightmapGI Oct 7, 2023
@sandsalamand
Copy link
Author

Hmm, both of those proposals seem difficult to use to fine-tune a scene with multiple emissive materials. I know you can have multiple Lightmap GI nodes, but how would you go about making one emissive cast light on a floor with a different intensity to another emissive casting light on the same floor?

@Calinou
Copy link
Member

Calinou commented Oct 7, 2023

I know you can have multiple Lightmap GI nodes, but how would you go about making one emissive cast light on a floor with a different intensity to another emissive casting light on the same floor?

There's currently no way to define per-material properties for the lightmapper (and only the lightmapper) to read. There is probably a way to figure this out, but it sounds complex for something that is quite situational. Remember that it should be able to work with custom shaders as well, not just built-in material shaders.

As a workaround, display an emissive object before baking that you hide after baking lightmaps. This can also be used to fake area lights in general. You can also add a OmniLight3D near the emissive material with its bake mode set to Static.

@sandsalamand
Copy link
Author

Can the StandardMaterial3D Resource file be modified to have an "Emission Indirect Multiplier" field which would store that data, and which the lightmapper can read from? Or is there a concern with backwards compatibility for Resources?

@Calinou
Copy link
Member

Calinou commented Oct 7, 2023

Can the StandardMaterial3D Resource file be modified to have an "Emission Indirect Multiplier" field which would store that data, and which the lightmapper can read from? Or is there a concern with backwards compatibility for Resources?

This isn't an issue with backwards compatibility. The issue is that if we add this property to BaseMaterial3D (the base class of StandardMaterial3D and ORMMaterial3D), there would be no way for custom shaders to overwrite this value.

We can add a new shader global that can be overwritten (like EMISSION can already be), but this means adding one more uniform for a feature that only impacts lightmap baking. This has a small performance impact even if you don't use the feature.

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

No branches or pull requests

2 participants