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

UV Unwrap freezes exponencially while trying to unwrap a big object #2428

Closed
caioraphael1 opened this issue Jul 17, 2024 · 1 comment
Closed

Comments

@caioraphael1
Copy link

caioraphael1 commented Jul 17, 2024

While working on my new PR (#2427 ) for changes to the UV system, I noticed that big objects take longer to Create Texture, or just simply unwrap.

The video below shows 2 identical objects with different sizes, the second one took so long to unwrap that i stopped recording.

2024-07-17.18-49-22.mp4

texture_generator.js / generateFaceTemplate()

The face_group.matrix = getPolygonOccupationMatrix(face_uvs, face_group.width, face_group.height); takes a LOT of time to do, and it's not a big deal to disable it completely in many cases.

face_list.forEach(face_group => {
if (!face_group.mesh) return;
let face_uvs = face_group.faces.map((face, i) => {
return face.getSortedVertices().map(vkey => {
return face_group.vertex_uvs[face_group.keys[i]][vkey];
})
});
face_group.matrix = getPolygonOccupationMatrix(face_uvs, face_group.width, face_group.height);
})

The real problem tho happens when trying to allocate an empty slot for the faces

face_list.forEach(tpl => {
//Scan for empty spot
for (var line = 0; line < 2e3; line++) {
for (var space = 0; space <= line; space++) {
if (place(tpl, space, line)) return;
if (space == line) continue;
if (place(tpl, line, space)) return;
}
}
})

The bigger the area occupied by each face, the more it takes to run through the space.

Disabling Combined Islands also improves a lot the time it takes to unwrap.

Considering all this, I had the idea to do one of the following:

  • First, make the projection really small -> Auto UV -> scale to the pixel density.
  • Or, improve the code so it can avoid wasting so much time running through so many coordinates.

Tho, I don't know how to make the project small, or how to improve the math so it goes faster for bigger objects.

Model format in which the issue occurs

Generic

Blockbench variant

Program

Blockbench version

4.10.4

Operating System

Win10

Installed Blockbench plugins

No response

@JannisX11
Copy link
Owner

In 4.11 there will be a progress bar so you can see how long it takes and it doesn't feel like it's stuck. Plus you'll be able to cancel it anytime.

@JannisX11 JannisX11 moved this to Unreleased in Blockbench Planning Jul 21, 2024
@JannisX11 JannisX11 closed this as completed by moving to Done in Blockbench Planning Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants