Skip to content
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

Lightmap bake freezes the editor at "Determining optimal atlas size" when trying to bake certain geometry #94216

Closed
passivestar opened this issue Jul 11, 2024 · 3 comments · Fixed by #94236

Comments

@passivestar
Copy link
Contributor

Tested versions

v4.3.beta3.official [82cedc8]

System information

Godot v4.3.beta3 - macOS 14.5.0 - Vulkan (Forward+) - integrated Apple M1 Max - Apple M1 Max (10 Threads)

Issue description

Editor freezes at "Determining optimal atlas size" completely and can only be closed by killing the process. The cube in this scene is missing its bottom face. Such geometry is fine in general (i.e the platform is missing the bottom face too, and it bakes fine on its own), however in this particular configuration where there's also a cube above it crashes. Note that the cube doesn't have to touch the platform for it to crash

image

Steps to reproduce

Open the MRP and bake

Minimal reproduction project (MRP)

MRP_determining_optimal_atlas_size.zip

@SpockBauru
Copy link

SpockBauru commented Jul 11, 2024

Tested here and the MRP also freezes on Windows 11:
Godot v4.3.beta3 - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 32.0.15.5612) - 12th Gen Intel(R) Core(TM) i7-12700KF (20 Threads)

Edit: Reproducible since 4.3 Beta1, not reproducible in 4.3 dev6

@BlueCube3310
Copy link
Contributor

BlueCube3310 commented Jul 11, 2024

Possibly related to #63423.

Edit - The code gets infinitely stuck in this loop:

while (source_sizes.size() > 0) {
Vector<Vector3i> offsets = Geometry2D::partial_pack_rects(source_sizes, atlas_size);
Vector<int> new_indices;
Vector<Vector2i> new_sources;
for (int i = 0; i < offsets.size(); i++) {
Vector3i ofs = offsets[i];
int sidx = source_indices[i];
if (ofs.z > 0) {
//valid
ofs.z = slices;
atlas_offsets.write[sidx] = ofs + Vector3i(1, 1, 0); // Center lightmap in the reserved oversized region
} else {
new_indices.push_back(sidx);
new_sources.push_back(source_sizes[i]);
}
}

@BlueCube3310
Copy link
Contributor

This seems to have been a hidden issue, only triggered in specific cases (Usually when the size of a single mesh's UV map was usable to fit into the whole atlas - the algorithm would try to add infinite layers to the image to have a clean layer to pack the mesh's UVs, but the layer would always turn out too small). #91601 exaggerated this issue since it padded smaller images and made them too big to fit into the atlas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants