godotengine / godotengine/godot
LightmapGI does not recognise cull mode in the material
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in: v4.3.dev4.official [df78c0636]
### System information
Windows 10 - Godot v4.3.dev4.official [df78c0636] - Vulcan (Forward+) - Geforce GTX 960
### Issue description
It appears that LightmapGI does not take into account the Cull Mode of materials when generating lightmaps. Objects made up of single walls that have double-sided materials only accept lighting from one side.

In the example above, only the first box on the left is correctly lit (not counting the light leakage at the edges). In this case, the material is one-sided and the normals point inwards. This makes the walls on the outside invisible.
The second and third boxes have double-sided materials and normals pointing outwards. Although for the renderer the walls are visible from both sides, lightmapgi treats them as one-sided and does not illuminate them with the objects inside with emission on. In addition, for some reason the top faces are bright (light leakage from above from DirectLight3D?).
When lightmaps are turned off, the scene is lit only by DirectLight3D and, not counting inaccuracies in the shadows, the Cull Mode support in the materials looks correct.

### Steps to reproduce
- create a cube
- remove one of the walls
- set normals to point outwards
- add material to the cube and set Cull Mode to disabled
- place a light source inside the cube
- generate lightmap
### Minimal reproduction project (MRP)
Test 04 in https://github.com/patwork/Godot-LightmapGI-Tests
Contributor guide
Research direction
Reproduce the issue with Test 04 in the linked Godot-LightmapGI-Tests project, following the cube, normals, Cull Mode, interior light, and lightmap steps. Trace LightmapGI's lightmap generation behavior for double-sided materials and compare it with the lightmap-disabled result. Done means a double-sided material illuminates the interior correctly when lightmaps are generated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100