Repository: godot
Issue: Vulkan: LightmapGI exhibits light bleeding through occluded areas after denoising due to occluded pixels still receiving light
Labels: bug,topic:rendering,topic:3d

### Tested versions

v4.2.1.stable.official [b09f793f5]


### System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 31.0.15.3758) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

### Issue description

Continuation on/Reopening of #63437

Pixels inside intersecting or overlapping geometry still receive light. This is an issue when:
- baking at any lightmap texel density, but the effect is more prominent at lower texel densities.
- "Use textures for bounces" is enabled, because the effect of light-bounces happening within occluded geometry gets intensified.

Both those situations are fine without denoising, but cause light leaking/bleeding after the rendered result is denoised.


![image](https://github.com/godotengine/godot/assets/31851431/d2e1a5d5-85ed-4718-83d9-0ad623cad5e9)
**Before denoising (left) and after (right) with a relatively high texel density and "use textures for bounces" enabled in both.** The visible seams between the flat modular meshes is related to #82607


![image](https://github.com/godotengine/godot/assets/31851431/cf63a2fb-3ee8-4e4b-bdb7-2240ded14cd6)
**Inside a wall section with "use textures for bounces" enabled (left) and disabled (right).** Note that when disabled there are still pixels visible within the occluded areas that are receiving light.


![image](https://github.com/godotengine/godot/assets/31851431/4343cd1c-a948-4d01-8b5c-4117d274b8ab)
**Light leaking at a 'reduced' texel density, "use textures for bounces" disabled in both, with denoising disabled (left) and enabled (right).** Note the various light leaks, not only on the walls near the ceilings, but on the wall next to the door mesh, and several corners of individual wall-meshes on the far wall.

In this last example I had raised the ceiling meshes slightly to ensure there should be no ambiguity for the lightmapper on whether the interior-side face of the wall should be entirely occluded or not. This did not make a difference in the resulting lightbake.


![image](https://github.com/godotengine/godot/assets/31851431/56b44ed2-0cd0-4b34-be1d-122284131b23)
**Raised ceiling mesh to completely occlude the interior facing side of the wall (left), view from inside the ceiling mesh showing that light is reaching the top of the wall which is expected to be occluded.**


Increasing the texel density can unreliably (slightly) alleviate the issue, but is not a legitimate solution since the texel densities used in these tests should be more than sufficient and are representative of what should be expected to work and used in the average project. Also worth noting is that these meshes are imported with a reduced texel size of 0.05 in the first 4 screenshots, and 0.1 in the last 4 screenshots, compared to the default texel size of 0.2

Using custom lightmap UVs with more padding has not made a difference in my tests.

Compared to the average modular game environment (anecdotally, but coming from a professional background in both AAA and indie development as a point of reference), the meshes used in these tests provide a forgiving scenario for the lightmapper to deal with: The meshes are manifold, there is no intricate geometry, and all meshes have plenty of thickness to cover a decent amount of pixels on the lightmap when intersecting or overlapping with other geometry.
Taking possible light leaking at the borders of the occluded areas in account (i.e. single pixels bleeding through at intersections), an artist should be able to expect the resolution, overlap and thickness in this scenario to provide a sufficient buffer for the lightmapper to avoid leaking.

This issue is also discussed in #75440 

### Steps to reproduce

- Create a scene with intersecting geometry
- Bake LightmapGI

The MRP has "use texture for bounces" disabled, since this seems to just worsen the existing issue and does not seem like the cause.

### Minimal reproduction project (MRP)

[LightmapGiLeaking.zip](https://github.com/godotengine/godot/files/14122213/LightmapGiLeaking.zip)