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

LightmapGI ignores ambient light when using the Scene environment mode #83485

Open
tbillington opened this issue Oct 17, 2023 · 6 comments
Open

Comments

@tbillington
Copy link

tbillington commented Oct 17, 2023

Godot version

v4.1.1.stable.mono.official [bd6af8e]

System information

Godot v4.1.1.stable.mono - macOS 14.0.0 - Vulkan (Forward+) - integrated Apple M1 Pro - Apple M1 Pro (10 Threads)

Issue description

The LightmapGI node does not seem to pick up on ambient light set in the environment.

As a result, when using LightmapGI for baked lighting the scene is extra dark compared to dynamic, non-baked lighting.

LightmapGI Hidden (Ambient light is showing)

image

LightmapGI Shown (Clicked Bake lightmaps, Environment=Scene, Ambient light not present)

image

The issue seems possible related to this previous issue #56138.


Steps to reproduce

  1. Open project
  2. Open main.tscn
  3. Observe bright ambient light shown in viewport coming from WorldEnvironment node
  4. Toggle visibility of LightmapGI node
  5. Bake lightmap of LightmapGI node to make sure it's up to date
  6. Observe much darker visuals in viewport

Visual difference also observable in play mode.

Minimal reproduction project

I couldn't upload the repro here because the environment file I'm using pushed the filesize over 25MB allowed by github.

I uploaded it to the open source send.vis.ee service instead, please let me know if there is a better option. The only downside is the file will only be available for 10 downloads or 3 days, so if someone needs access I will need to re-upload it.

https://send.vis.ee/download/2925d81f52da8f12/#V6Ibyn2eYMGJDelxWsIneQ

@atirut-w
Copy link
Contributor

atirut-w commented Oct 23, 2023

I can confirm and reproduce this bug., I think? I encountered this some times ago but thought it was by design. It seems that LightmapGI will only take skybox contributions into account and completely ignore ambient settings.

@permelin
Copy link
Contributor

From what I can gather from the code, this is intentional. The lightmapper doesn't use the ambient light from the WorldEnvironment in the bake, and then the renderer explicitly skips over ambient light when lightmapping is active.

To enable dynamic ambient light again, all you have to do is remove this #ifndef:
https://github.com/godotengine/godot/blob/4.2/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl#L1290

I did a quick Google search and it seems that both UE5 and Unity behaves in the same way for baked light.

For realistic lighting this makes sense to me, but you don't always want realism. Maybe there is some other consideration that I'm not aware of.

It's worth mentioning that with both SDFGI and VoxelGI, ambient light is still used.

I've found that I can kind of fake ambient light in a room with an OmniLight3D with high range, zero attenuation, very low energy, very low indirect multiplier and no shadows.

@Calinou
Copy link
Member

Calinou commented Feb 29, 2024

I get a feeling this issue doesn't have anything to do with #56138, and is actually requesting what was known as Min Light in 3.x. There's a PR reimplementing it for 4.x, but it didn't get much community support: #50572

@permelin The issue here is that the custom ambient light color should be baked. It shouldn't be applied in real-time, otherwise your lightmap will look washed out and you'll be applying two ambient light sources at once (sky baked onto lightmap + your custom color).

Also, if you are baking lightmaps, it's because you want ambient light to behave correctly. In real life, ambient light doesn't apply uniformly on all surfaces – this would make things glow in the dark 🙂

If you want "minimum lighting" to be applied everywhere, something like #50572 is more suited. I really don't recommend using it though, as using any kind of minimum lighting will result in the impossibility of having truly black light levels anywhere in your game world (leading to reduced contrast). Most of the time, it's preferable to increase your lights' range or add more lights instead (known as "unmotivated light sources").

It's worth mentioning that with both SDFGI and VoxelGI, ambient light is still used.

Actually, SDFGI doesn't take custom ambient light colors into account. VoxelGI has significant light leaking issues too, even in indoor scenes.


@tbillington The link has expired, can you upload the reproduction project again?

@atirut-w
Copy link
Contributor

atirut-w commented Mar 1, 2024

Mine is probably a slightly different issue, then, because I expect custom ambient color to replace sky contributions.

@Calinou
Copy link
Member

Calinou commented Mar 1, 2024

Mine is probably a slightly different issue, then, because I expect custom ambient color to replace sky contributions.

This is only the case if sky contribution is exactly 0.0. Otherwise, sky contribution is blended with the custom ambient color. If sky contribution is 1.0, then the custom ambient light color won't be visible at all.

@atirut-w
Copy link
Contributor

atirut-w commented Mar 2, 2024

That should definitely be documented or changed. Also, setting ambient source to Color does not behave as expected. It seems to only use sky as source in that mode.

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

5 participants