Improve UV packing to pack more tightly (not just considering bounding boxes)
#68889
Closed
opened
No Branch/Tag Specified
main
blender-v3.6-release
temp-sculpt-dyntopo-hive-alloc
temp-sculpt-dyntopo
asset-shelf
cycles-light-linking
tmp-usd-python-mtl
brush-assets-project
blender-v2.93-release
blender-v3.3-release
universal-scene-description
node-group-operators
asset-browser-frontend-split
temp-sculpt-attr-api
blender-v3.5-release
realtime-clock
sculpt-dev
gpencil-next
bevelv2
microfacet_hair
blender-projects-basics
principled-v2
v3.3.7
v2.93.18
v3.5.1
v3.3.6
v2.93.17
v3.5.0
v2.93.16
v3.3.5
v3.3.4
v2.93.15
v2.93.14
v3.3.3
v2.93.13
v2.93.12
v3.4.1
v3.3.2
v3.4.0
v3.3.1
v2.93.11
v3.3.0
v3.2.2
v2.93.10
v3.2.1
v3.2.0
v2.83.20
v2.93.9
v3.1.2
v3.1.1
v3.1.0
v2.83.19
v2.93.8
v3.0.1
v2.93.7
v3.0.0
v2.93.6
v2.93.5
v2.83.18
v2.93.4
v2.93.3
v2.83.17
v2.93.2
v2.93.1
v2.83.16
v2.93.0
v2.83.15
v2.83.14
v2.83.13
v2.92.0
v2.83.12
v2.91.2
v2.83.10
v2.91.0
v2.83.9
v2.83.8
v2.83.7
v2.90.1
v2.83.6.1
v2.83.6
v2.90.0
v2.83.5
v2.83.4
v2.83.3
v2.83.2
v2.83.1
v2.83
v2.82a
v2.82
v2.81a
v2.81
v2.80
v2.80-rc3
v2.80-rc2
v2.80-rc1
v2.79b
v2.79a
v2.79
v2.79-rc2
v2.79-rc1
v2.78c
v2.78b
v2.78a
v2.78
v2.78-rc2
v2.78-rc1
v2.77a
v2.77
v2.77-rc2
v2.77-rc1
v2.76b
v2.76a
v2.76
v2.76-rc3
v2.76-rc2
v2.76-rc1
v2.75a
v2.75
v2.75-rc2
v2.75-rc1
v2.74
v2.74-rc4
v2.74-rc3
v2.74-rc2
v2.74-rc1
v2.73a
v2.73
v2.73-rc1
v2.72b
2.72b
v2.72a
v2.72
v2.72-rc1
v2.71
v2.71-rc2
v2.71-rc1
v2.70a
v2.70
v2.70-rc2
v2.70-rc
v2.69
v2.68a
v2.68
v2.67b
v2.67a
v2.67
v2.66a
v2.66
v2.65a
v2.65
v2.64a
v2.64
v2.63a
v2.63
v2.61
v2.60a
v2.60
v2.59
v2.58a
v2.58
v2.57b
v2.57a
v2.57
v2.56a
v2.56
v2.55
v2.54
v2.53
v2.52
v2.51
v2.50
v2.49b
v2.49a
v2.49
v2.48a
v2.48
v2.47
v2.46
v2.45
v2.44
v2.43
v2.42a
v2.42
v2.41
v2.40
v2.37a
v2.37
v2.36
v2.35a
v2.35
v2.34
v2.33a
v2.33
v2.32
v2.31a
v2.31
v2.30
v2.28c
v2.28a
v2.28
v2.27
v2.26
v2.25
Labels
Clear labels
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
Eevee & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest/Import
Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Eevee & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
Eevee & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest/Import
Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Eevee & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
21 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#68889
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. It CANNOT be undone. Continue?
Better UV island packing algorithm that does not only consider bounding boxes of islands and packs more tightly (even if slower).
Possible algorithms:
We'd likely want to take the implementation from those libraries and adapt it rather than adding the library as a dependency.
Added subscriber: @dfelinto
Added subscriber: @LukasS
Removed subscriber: @LukasS
Added subscriber: @item412
Added subscriber: @Zuorion-4
Added subscriber: @SecuoyaEx
In terms of UV packing and UV unwrapping, it's common in other software to have a progressive heuristic solver. Something that you let run for a couple of seconds until you're satisfied with the result.
Added subscriber: @0o00o0oo
Added subscriber: @giakaama
Added subscriber: @moisessalvador
Is there a task for to improve the UV editor itself? Right now it still has remnamts of the image editor and it could be improved. I made a couple of proposals about it [here ]] and [ https:*blender.community/c/rightclickselect/cQdbbc/ | here
Added subscriber: @mrlemonyfresh
UV Mapping Improvementsto Improve UV packing to pack more tightly (not just considering bounding boxes)Added subscriber: @ideasman42
Split out tasks #71958 (Automatic UV seam creation tool), #71959 (Improve UV unwrapping balance between angle and area preservation) since merged tasks are harder to manage.
Added subscriber: @1D_Inc
Do you mean Packmaster / Shotpacker addons?
Changed status from 'Needs User Info' to: 'Confirmed'
Also, please, remember, that current packing behavior is good because it is fast, that is suitable for the most cases and especially nice for heavy meshes.
If to completely replace it with heuristics instead of adding it, it is possible to get the same problem as with the undo - low perfomance for every use case instead of when it's really needed.
Removed subscriber: @moisessalvador
Added subscriber: @muhuk
Removed subscriber: @SecuoyaEx
Added subscribers: @Chris_Blackbourn, @DanielBystedt
@Chris_Blackbourn Asked me to give some feedback and provide a diagnostic test scene as an example of how uv packing could be improved in Blender.
In the attached image you can see how there is a lot of waisted space that is not utilized during packing.
Blender file example
bad packing from Bystedt 220920.blend
Comparison with Packmaster addon, in case if it will be useful.
The default packing: fast, but lots of unused space since islands proceeded as convex shapes.

Islands rotation is disabled (sometimes it is needed).
The result - 46.4% of the area is used:
The default packing.

Islands rotation is enabled.
The result - 48.2% of the area is used:
Packmaster (3 seconds heuristics): islands are proceeded as concave shapes

Islands rotation is disabled.
The result - 59.4% of the area is used:
Packmaster (3 seconds heuristics).

90 degrees islands rotation is enabled.
The result - 68.5% of the area is used:
Added subscriber: @Dangry
@1D_Inc Can you share that geometry in a .blend file?
I checked legal notices - and, actually, yes, I can share this one. After all, if even Google and Nvidia use my models for their datasets, why not use them for Blender developers.
However, I have to do this clearly so I uploaded it to Blendswap, it's awaiting moderation, which usually takes a few days.
It will be available at this link - https://blendswap.com/blend/30606
The model is available.
Hi Chris!
I made version of my earlier file, but this time with good packing so that you can compare if needed.
good packing from Bystedt 220927.blend
Nice! Loving the fireplace! I've got both models in the debugger, should be a good challenge :D
Here is a problem with my model - it is very polished.
There are no self-intersecting islands contours, non-unwrapped mesh chunks, overlapping islands that are used to save UV area, or other possible threats or hints. It doesnot even contain tris or ngons, since it is an onlyquads model.
That usually means that such a model is good as a result, but is quite bad as a test subject, since provides sterile conditions that are very uncommon for realword production process.
This better be taken into account at some point.
I used Texel density checker addon to calculate UV filling precentage, can be useful.
https://github.com/mrven/Blender-Texel-Density-Checker
Also I want to mention that the default (convex shapes) method is more useful during cutting UV seams and unwrapping process, because it gives a clearer picture how your resulting islands looks like (individual shapes of islets after a convex packing are better humanly recognizable than after a concave one). So it is reasonable to use the default convex packing during UV unwrapping process to check islands shapes and use concave packing at the end to form the final result.
Since they are all useful and have their own benefits, I would like to suggest calling packings "convex/concave" rather than "good/bad".
Added subscriber: @Metrons
Hi @Chris_Blackbourn Thank you for working on better packing. Is there any hope that we can have group packing at some point in the future? I'm wondering if that's on your mind at all. For example, my character's hands, fingers i could assign to group 1 and the arms and torso, group 2 etc and when i pack it keeps my groups together. This way when i'm texturing i'm not looking all over my uvs for fingers or something.
Hi @Metrons ! Welcome :D
"Group Packing" isn't really on my radar at the moment, as it needs a way to specify what makes a "group". I have access to materials, so maybe assign fingers to the finger material etc? Or perhaps there's a better way. In any case, I don't know of a Task for group packing. It might make sense to create one.
There might also be a partial solution in some of these tasks which are in the "Under Discussion" category:
Hope this helps!
I think time isn't an issue here.
Waiting 30 sec or 1 min until solver finishes the job is still better than spend an hour manually moving pieces back and forth looking for better coverage.
Added subscriber: @NahuelBelich
There are AFAIK curently 3 packing plugins for blender ( UVPackmaster, UVShotpack, UVPacking ).
All of them support Concave shapes with holes. And that good packing with Concave shapes is heavily requested, at least in gamedev community.
Here are examples of examples:
In terms of speed all of those addons were near instant at bysted example, and have some kind of performance-precision setting like "Good/Efficient" or number of iterations.
And on default settings with mesh FIREPLACE_MF_0018_A from 1D times they achieve: are around 3-7sec (and can ba cranked up) while Blender Packing is sub 1s. So i agree with 1D that there could be ultra-fast option for really heavy meshes if thats not too much duplicated work.
Also each addon have option: Allowable Island rotations: No rotation/90°/45°/etc. where with more steps they tend to be significantly slower.
Please let me know if you are working on this one.
Added subscriber: @AndyCuccaro
Added subscriber: @FDesimpel
For lightmaps and 3d painting and such these seem better, though i hope those will be additional choices, the former may seem wastefull though nicer for hand painting with the aligned circles for instance.
WIP: #105821
If you want a sneak-peek, first pass of this should be in the daily builds, https://builder.blender.org/download/daily/
There's still more work to be done improving packing efficiency, so please wait making direct comparisons with other packers until we can get the rest of the changes in.
@Chris_Blackbourn a colleague of mine that has being testint the last builds and he has a machine with a slower cpu, he brought my a situation, a monkey (suzzane) with the uv reseted (each face is an island), when all the island in that monkey are selected it takes a long time to do the first pack, in my machine eventually works but in his machine blender softlock, his solution was to run a phyton command bpy.ops.uv.pack_islands(shape_method="AABB") to start the first pack with AABB that its the fastest, then with all the island separated the softlock in his blender doesn't happend, and packs convex/concave properly
Probably the default packer for the moment should be Bounding box and not convex or lowering the margin value from 0.001 to 0.01 for us alpha tester.
I'm not too concerned if the daily build has problems. On a philosophical level, that's exactly what the daily builds are for, to shake out the problems before we make a release.
If there's a test-case which has poor performance on the daily build, can you send through a .blend and repro steps, highlighting the test case, and we'll try and address the performance issue first before applying work-arounds.
Blender should definitely be usable on slow machines too, so this is a use case we need to support.
sshould i tell him to do a conventional bug report or poke him to come here? since the PR of the xatlas packing was already merged
This issue is still open, so here is fine. A conventional bug report will work too, just be sure to mark which version it's on.
Amazing work @Chris_Blackbourn! I tested the new packing and it works great. I also compared to a uv packing addon that I have bought and the result of your algorithm got better result than the addon.
addon uv area ratio = 0.645
Chris cool packing area ration = 0.673
(Shape method = Exact shape, margin method = fraction)
idea: use operator_menu_enum instead of just operator in Pack Islands. According to @Chris_Blackbourn
Great stuff! There's still more efficiency improvements to be committed, exciting times :D
After doing some testing it seems like the current default settings for packing generates great results and is also fast
Current default:
Pack to: Closest UDIM
Rotate = True
Margin method = Scaled
Margin = 0.001
Shape method = Exact shape (Concave)
I tried some different settings. Margin_method = fraction was way slower, so 'scaled' seems like a good default setting.
Some thoughts on improving the user experience:
Progress bar
The packing process can potentially take a long time due to uv complexity and hardware. One thing that could improve the user experience is to add a progress bar
Interrupt packing with escape
It would be great if users could interrupt the process by pressing ESC on the keyboard or pressing the X next to the progress bar
Hey peeps!
Getting close to closing this issue as "complete".
There's still the progress bar to go, and a couple more bits'n'bobs that are open on my machine trying to make it in 3.6. Either way it won't be long now.
If there's any more changes you want, now is the time to shout out before I close it up!

Wonderful)
Is it planned "packing with grouping by material", or it better be a separate proposal/task?
How this one can be tested?
If I could request a feature, this would be great to add:
A usecase is this:
The artist is modeling a complex character with a suit. After the uv layout is done, and texturing has started the client/art director want to add some emblems to the suit. The artist wants to add the emblems without loosing existing texture and uv layout. By pinning the existing uv's and packing the new emblem geometry/uv to the existing uv layout, the existing uv's are kept and the emblems are packed to the free uv space.
it would be a good idea to add the ability to manually specify the UDIM in which to pack the islands, directly from the Redo panel

1 Variant:
2 Variant:

This concept can turn into something cooler, for example, a modal operator that will allow you to select the target UDIM/UDIM's with the mouse on the screen
We already have the functionality of choosing to
Therefore I don't think we need additional uv target options in the pack islands operator.
In order to target a specific udim, your active texture needs to be a udim texture, or you need to increase the tiles in the uv editors overlay options.
I also think that current realization in this area sounds workflow-complete and flexible enough.
Not sure about Shape method = Exact shape (Concave) though.
It is nice for the final result, but during unwrapping convex brings cleaner picture about islands shapes.
How it can be tested?
Can you expand on this a little? I'm not quite following the change you would like to see here?
I mean that Convex method better fits unwrapping process because it pack islands in a way that makes the shape of the separatare islands more recognisable (which is better for seams debugging process), and Concave method better fits packing of the final result.
So during unwrapping you usually do lots of Convex packing which ends with final Concave packing.
Don't have a strong opinion on this though, since Convex method is quite available.
Done !
5abb3c96cf
And after 4+ years, I am CLOSING this issue! :D :D :D