godotengine / godotengine/godot

Gridmap mesh custom data is removed when baking lightmaps

Open
#89,254 4 comments 1 reaction 0 assignees View on GitHub
bug topic:3d topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in v4.3.dev4.official [df78c0636]
- Did not test any other versions

### System information

Godot v4.3.dev4 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (NVIDIA; 31.0.15.4665) - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 Threads)

### Issue description

When baking lightmaps, meshes in gridmaps lose their custom data (`CUSTOM0`-`CUSTOM3`).

https://github.com/godotengine/godot/assets/42372774/bac9cd06-7b60-48b1-8520-d2bcc504be20

Edit: At least `MODEL_MATRIX` is also incorrect, and likely many other properties, though uniforms seem ok.

### Steps to reproduce

1. Open the MRP
2. Bake Lightmaps
3. Custom data disappears
4. Modifying the GridMap brings back the custom data, but clears the baked meshes resulting in `modules/gridmap/grid_map.cpp:1315 - Index p_idx = 0 is out of bounds (baked_meshes.size() = 0).`; baking them again makes the custom data disappear again.

### Minimal reproduction project (MRP)

[repro.zip](https://github.com/godotengine/godot/files/14528076/repro.zip)

Contributor guide

Open the contributing guide

Research direction

Open the attached repro.zip project in Godot v4.3.dev4 and reproduce the loss of GridMap custom data after baking lightmaps. Then inspect modules/gridmap/grid_map.cpp around line 1315 and trace the baked-mesh path. Done means baking preserves CUSTOM0-CUSTOM3 and MODEL_MATRIX without the reported out-of-bounds error.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.