UV packing

Am I the only one having trouble with pack by selection working? im using the latest builds

I recently aquired this invaluable addon and wanted to post a few shots of the difference it made on my UVs compared to Blender’s UV packing.

Generally, I always pre-align and square-ify islands which takes an hour or two, but it always yields a better result in the end. The most time consuming work has always been the manual packing, and I’m so happy that something like this now exists.

Already at 50 iterations Shotpacker far surpassed Blender own packing by 5% extra coverage. At maximum, while still retaining a fair margin of around 4px, Shotpacker managed 75% coverage using only 90 degree rotations.

Thank you for making this.

I mean, I do enjoy a nice UV session with a few cups of coffee, but this will save me a few years.

@danoman, @MACHIN3: Indeed, setting rotation to 0 (and flip to off) should not rotate anything. If it is, something is going wrong.

@nixin: Could you describe your problem in more detail? Windows 10? Blender 2.79? What is going wrong? Is the algorithm working in general? If you unwrap Suzanne and select some islands and try out various options in the island selection behavior, what happens?

@iceythe: Thanks!

It does not even pretend to keep a margin, once 1 pixel once 5-10…

edit//
new version fix that problem

Added new version to Gumroad. The island margin should now never go below the set boundary. Improved performance in some edge cases 2-100x (faster annealing option).

I downloaded the latest version and tried importing it in Blender but I don’t think it worked. I copy-pasted the unzipped latest Shotpacker folder into the addons directory of my blender folder (C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons) and it told me I had multiple versions of the same addon. So I removed the version I had prior.

Is 1.1.9 the latest version?

It’s best to always remove the add-on before re-install by either deleting the folder or from Blender add-on panel by clicking remove. After that installing normally. The version number isn’t always updated, it’s something I really should automate not to always forget about it, but that date should always be accurate on Gumroad. 1.1.9 is the latest version number, yes.

I see. In that case I must’ve done it correctly. Thank you!

They tal;ked about this on Blender Meetup day and I got to see this - and I will get it next week asap, this is a nice addon!

I’m the only one that since last update obtain bad solutions with a lot of free space?

now it is fast as hell !!!
@DcVertice for a lot free space you can scale the uv islands up and recalculate it again…it usually works;)

@DcVertice: You can turn off the faster annealing option to have the old style algorithm. More accurate island margins can’t be currently turned off. If there is significant perfomance issue, I can include the old style as an option. I’m still trying to improve the algorithm. If there are any regressions I would be happy to look at any .blends that have issues.

edit: There is one obvious issue in the packing with faster annealing, when there are long and thin islands. That should be fixed in the next update.

I also get quite a bit of wasted space using “Faster annealing” on default settings. It produces a sizeable 1/4th of empty space on the right side.

I’ve found a somewhat quick fix while still being able to reap the benefits of Faster annealing:

Start scale: 0.10
Turn off “User texture dimension”
Specify width/height of 0.1
Scale the result (Scale pivot to 2D cursor to 0,0)

Apart from manual scaling, this has consistently given me a completely square packed result, with the speed benefits of Faster annealing. In fact, it’s so fast I’ve had to edit the script to allow 1200 iterations.

Uploaded a new build on Gumroad. Bugfix on the faster annealing option. It might not always be as good as the default one but in some cases it should be a lot faster. It’s now disabled by default. Added option for island margin precision (slower and more accurate vs. faster and less accurate). Can affect performance for up to ~50%. Removed the start scale option as it shouldn’t be necessary anymore.

@iceythe: I have no idea how that even works. :smiley:
It would be really surprising and interesting if that is actually improving your packing rate.

edit: Here’s how the island margin quality setting works (left to right: low, med, high)

Thank you very much. This has been extremely useful to me and I’m glad I bought it.

I had a very situational issue once where I packed the islands with scaling enabled.
The islands were shrunk to an extremely small size and all placed near 0/0, aligned vertically and travelling upwards along the leftmost edge of the texture bounds.
I believe the issue may have been due to me removing the texture’s references and then using the scaling feature without switching to a new texture.
More of a quirk than anything to worry about though.

UPDATE: New version on Gumroad


Pruning: Should improve packing big UV sets quite a bit. Smaller prune ratio = tighter pack, slower. Higher prune ratio = less tight, faster.

Shotpacker Tools:

Select broken UV islands: Selects all UV islands that the packing algorithm reverts to its bounding box. Good for fixing stuff before you start long packing.

Remove unconnected and unlooped: Removes UV seams that aren’t loops

Merge small islands: Merges islands that are less than size, or less than polycount. Note: Affects only seams. You need to unwrap manually if you want the islands to change.

Shotpacker Stats:
Merged the UV area tool into this addon for easier development

@Friedslick6: Thanks! :slight_smile: Do you mean faster annealing option? That bug should have been fixed in the previous release.

Just bought it, and the results on UVs with multiple islands is much better (from 50% used area to 70%!), but with few and bigger islands (4 in my example), the results are comparable to Blender’s packing, sometimes being even a little worse (Addon: 38.62% x Blender: 38.75%). Sure when the number of islands is small, packing by hand isn’t that difficult, but I think an algorithm can do better than I do :P.

Any tips on using the addon on UVs with few islands? Or better yet, a guide explaining all its functionalities (some tooltips on the addon would also be highly appreciated)? Thx a lot!

@RaphaelBarros: There’s a bug that might not always pack using the best available ratio directly after using unwrap. You have to first CTRL-P (and possibly CTRL-A to average island scale) to pack using the Blender packing algorithm, then use the addon.

I have purchased this addon but I get tracebacks from it. After update it does not work for me anymore.

First issue is easy to solve, it happens when I try to reenable addon:

Traceback (most recent call last):
  File "/usr/share/blender/2.79/scripts/modules/addon_utils.py", line 331, in enable
    mod = __import__(module_name)
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/__init__.py", line 36, in <module>
    from . import island
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/island.py", line 11, in <module>
    from . import settings
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/settings.py", line 2
    json_out = 'D:\code\
fp\json_islands.txt'
              ^
SyntaxError: invalid escape sequence \c

Using hardcoded paths is very bad idea. And you should never use slashes or backshashed in the path, or there are will be issues one one platform or another. I replaced the string with json_out = ‘json_islands.txt’, then I could enable the addon.

But when I have tried to use it, I got another traceback, and this one I do not know how to solve:

Traceback (most recent call last):
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/__init__.py", line 349, in execute
    self.init_run()
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/__init__.py", line 329, in init_run
    self.packer = packer.Packing(uv.UV(bpy.context.object))
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/packer.py", line 19, in __init__
    self.isles, self.groups = self.uv_hnd.generate_isle_set(bpy.context.scene.s_packing_margin/100.0)
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/uv.py", line 248, in generate_isle_set
    valid = isle.format_for_packing()
  File "/home/lissanro/.config/blender/2.79/scripts/addons/shotpacker/island.py", line 66, in format_for_packing
    self.chains[i] = cgeo.prune_chain(self.chains[i], self.margin * self.prune_ratio)
AttributeError: module 'shotpacker.cgeo' has no attribute 'prune_chain'

EDIT: I have deleted shotpacker directory and reinstalled the addon from scratch, the above traceback does not happen anymore. I leave it anyway in case it means something.

However, first traceback still DOES happen when I try to reenable addon, even after clean reinstall I had to fix settings.py to make it work.

@Lissanro: Thank you for the report. Did you try and remove all of the old addon files before installing the new one? It might be that there are old files that are causing trouble or the folder structure is incorrect.

I tried the new version on both fresh installs of Windows and Linux with Blender and couldn’t reproduce your problem.

shotpacker.cgeo definitely does have prune_chain (it’s a new addition) so it would seem it’s trying to read from the old files.

edit: You’re using Mac? Unfortunately it’s something I can’t test at the moment. Going to fix that json_out in the future releases as it’s just a personal debug thing that really shouldn’t be in the release versions.