Improve UV packing to pack more tightly (not just considering bounding boxes) #68889
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Overlay
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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 Milestone
No project
No Assignees
22 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#68889
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. 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!
Just a quick note on the difficulty
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
Hello!
First, I really love the improvements on the packer tool.
Here are the most important issues I feel need addressing in future:
It doesn't the ability to force packing vertically or horizontally. It will bias the rotation to whatever is closest to the X or Y axis. This is problematic as 95% of the time, you want to align islands on a single axis (wood planks for example). Currently, you will have to manually rotate any islands that don't match your desired axis.
Multi-UDIM packing
Ability to change the packing shape - bottom to top/top to bottom/square (current implementation)
Thanks!
Hi Seithr, Welcome!
I'm glad you love the new packer :D
Those seem like some great ideas.
It feels like maybe the first one is more closely related to unwrapping rather than packing? Perhaps take a look at this one for some similar ideas : #109906
The third idea shares some similarity with #78408 .. I wonder if we could merge those somehow?
And then the second idea might need a bit more detail, but yeah, that's one thats requested fairly regularly, but doesn't yet have an open issue.
In any case, this particular issue ( #68889 ) is already 4 years old and very long. I'd be pretty surprised if it gets re-opened. I think the best path forward might be to open a new issue (or three!) or add to some of the existing UV issues where appropriate.
Awesome,
--Chris
Oh, and have a look on https://blender.community/c/rightclickselect ... there might be more there too...
Hey Chris,
Thanks for the response and links.
I have to disagree about the suggestion of the X/Y packing alignment being an unwrap issue. I agree the unwrap should have this option by default. But its also very important to expose this to the packer as well as you are not always unwrapping in blender. Often In a studio environment we have to worth with other peoples models or ingest models from other studios and have to redo the UVs on a regular basis. Having to unwrap everything again just to have the correct orientation isn't a viable solution.
I'll open a few issues.
Looking forward to seeing how the packer comes along, you are a true hero tackling UVs in blender.
Cheers,
-Nick
1. Align rotation of uv islands
This is already possible. Before packing, align the rotation of the uv islands with uv > align rotation. The operator has multiple options. For example using world space geometry alignment for aligning uv islands. After the uv islands are aligned - pack the uv's with
rotate = False
2. Multi UDIM packing
This is already possible. Increase the number of udim tiles in uv editor > overlay > tiles X/Y. Then you position the uv islands you want to pack to a specific udim and then pack to closest udim.
3. Packing horizontally/vertically,
This is a planned task #78408 (as @Chris_Blackbourn mentioned). The plan is to have this as a separate operators than putting too many options in the packing operator, This way you don't need to switch packing options back and forth all of the time, You can also use the current packing option "Pack to original bounding box" if you position the uv islands in a min x/y max x/y bounding box before packing.
Hey Daniel, thanks for the detailed reply.
1) Unfortunately the current implementation of align rotation doesn't solve the issue. It seems using the "geometry" method of the tool only takes into consideration the objects local orientation. If we have objects at different angles in world space with transforms applied we have no way of orienting the UVs in one direction.
The other option in the tool is setting it to "auto" however this has the same issue as the packer, where it randomly aligns things to X and Y. So if I align a hundred pipes, many of them will be aligned in the wrong axis and I have no way of fixing that without manually rotating them 90 degrees.
Instead I think we need to have the option in the packer to force the orientation in X/Y based on the longest dimension of the UV bounding box.
2) This also isn't a viable solution. I work in VFX we often have to layout geometry that takes up 10-100+ UDIMs. Manually moving every single island to a individual UDIMs and hoping it fills the UDIM efficiently isn't a great solution especially when dealing with thousands of UV islands (I should mention that I tested using the technique you suggested and it seems to still only pack to the 1 UDIM closest to where the UV islands are in UV space, not multi UDIMs)
Proposed functionality:
-If you disabled "scale UVs", the packer should be smart enough to know that once 1 UDIM is filled, to move onto the next and continue packing until all islands are finished.
-If you enable "scale UVs", then you should be able to set a grid size (eg, 1x1, 2x2, 1x10, 10x10 etc) And it will automatically scale the UVs to fit into the desired tile count.
I hope that makes sense.
Cheers,
-Nick
I think all of it worths at least mentioning and taking into account during long-term UV development, since there are indeed lots of aspects that forms workflow-dependent demands picture.