Skip to content

LightmapGI Environment lighting is polluting closed spaces #92174

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

Open
patwork opened this issue May 20, 2024 · 2 comments
Open

LightmapGI Environment lighting is polluting closed spaces #92174

patwork opened this issue May 20, 2024 · 2 comments

Comments

@patwork
Copy link
Contributor

patwork commented May 20, 2024

Tested versions

  • Reproducible in: v4.3.beta.custom_build.daa81bbb7d

System information

Windows 10 - Godot v4.3.beta.custom_build.daa81bbb7d - Vulcan (Forward+) - Geforce GTX 960

Issue description

Info

It seems that when baking lightmaps, random rays miss the geometry and cause the interior of closed spaces to be illuminated by environment light.

Godot with DEBUG_TEXTURES enabled in lightmapper_rd.cpp.

Example scene

a) basic 3D scene with solid color for background, ambient and reflected turned off for clarity

world

b) lightmap gi node with different solid color for environment, denoiser off, use texture off

lmgi

c) omnilight with yet another color in the center

d) basic blender cube with normals pointing inside

Results

Before bake:

direct

After bake:

with

Although the geometry is closed on all sides, a lot of light from the environment gets in and hits the faces. This only happens in the “light_secondary” step. The green color of the environment is set from LightmapGI settings.

2_light_primary_0.exr

with_primary

4_light_secondary_0.exr

with_secondary

Box inside box

The situation changes a bit when the above cube is placed inside a larger one. In Blender, it looks as follows:

boxes

After bake:

inside

You can see that fewer rays missed the geometry, but despite the thick walls surrounding the cube, environment leaks still occur (green).

Switching Environment in LightmapGI to “Scene” gives this result: environment still appears, but consistent with the WorldEnvironment setting (blue).

inside_scene

Increased exposure:

inside_scene_up

Source

This section of lm_compute.glsl is most likely responsible for adding color of the environment:

} else if (trace_result == RAY_MISS) {
// Look for the environment color and stop bouncing.
light += throughput * trace_environment_color(ray_dir);
break;

When you turn off the line 534 all the green environment from baked ligtmap disappears. Naturally, this causes the environment to be completely ignored, so it is not a solution. The question remains why and in what cases trace_result == RAY_MISS, if we are talking about closed spaces (and even closed spaces inside other closed spaces).

No green dots anywhere:

without

4_light_secondary_0.exr after commenting line 534:

without_secondary

Steps to reproduce

Minimal reproduction project below.

Minimal reproduction project (MRP)

environment-pollute.zip

@Geometror
Copy link
Member

I think this was fixed with #99538, can you confirm?

@Felipe-Sena
Copy link

Can still replicate light leakage but with less noise

boxa:
Image

boxb:
Image

Note: boxb has backface culling enabled on the larger outside wall for some reason, I didn't modify the models and am running a freshly built Godot editor from the master branch.

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

4 participants