godotengine / godotengine/godot
LightmapGI leaks on box PrimitiveMeshes due to poor UV2 generation quality
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in: 4.4.dev https://github.com/godotengine/godot/commit/7187c251da3fabbfe1dbc87d2c33692bb6d9823b
### System information
Godot v4.4.dev (7187c251d) - Fedora Linux 41 (KDE Plasma) on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (nvidia; 560.35.03) - 13th Gen Intel(R) Core(TM) i9-13900K (32 threads)
### Issue description
LightmapGI leaks on box PrimitiveMeshes due to poor UV2 generation quality. This does not occur when using scenes imported from glTF files (created using Blender), regardless of whether multiple cubes were assembled together in Godot or the scene design was done in Blender entirely as a single object. This occurs even at Ultra quality with the denoiser disabled, and bicubic sampling disabled in the Project Settings.
The issue is less noticeable at higher texel scales, since this is resolution-dependent.
The geometry on all scenes is 100% identical, down to the triangulation order for the *Multiple Imported Scenes* example. The *Single Imported Scene* has a different triangulation order for its boxes, but that shouldn't affect UV2 generation quality noticeably.
I haven't tested whether this occurs with other PrimitiveMeshes, but BoxMesh is likely the most prominent example.

cc @BastiaanOlij
### Scene assembled using box PrimitiveMeshes
*Notice the light leaking on boxes' edges, or overly dark edges.*

### Scene assembled using boxes exported from Blender
*Notice the lack of light leaking or overly dark edges.*

### Steps to reproduce
- Create a MeshInstance3D with a BoxMesh and enable **Add UV2** in the BoxMesh resource's properties.
- Duplicate the MeshInstance3D a few times to create a basic layout.
- Create a Cube in Blender and export it to glTF. Import it in Godot, with its global illumination mode set to **Static Lightmaps** in the Import dock.
- Duplicate the imported cube a few times to create the same basic layout as above.
- Create a LightmapGI node and bake lightmaps.
### Minimal reproduction project (MRP)
[test_lightmap_uv2.zip](https://github.com/user-attachments/files/17581023/test_lightmap_uv2.zip)
Contributor guide
Assessment
This issue has not been assessed yet.