Page MenuHome

Fix T53997: [bug] island_margin in bpy.ops.uv.smart_project seems to have no effect
ClosedPublic

Authored by Sebastian Parborg (zeddb) on Mar 14 2019, 9:11 PM.

Details

Summary

Now island margin acts as a percentage instead of being the actual distance.
So the margin distance will always be the same regardless of the actual size of the geometry.

Diff Detail

Repository
rB Blender

Event Timeline

I'm a bit torn on how to make the solution more elegant. I guess we could take the median width and height of the islands and use that as the margin base.
Right now the margin will be non-uniform.

The only other way I can think of requires us to pack two times. First to determine the total width and height of the packed islands and then adjust the margin using this total width as a base.

It seems I reverted the change from T53678 that caused this bug in rB33750e8abbad: Fix T58006: smart UV project island margin should not use length units.. It's not clear to me why further changes are needed, or why it even made sense to use scene units to begin with.

I think islands margins should be a fixed size in UV space, not be relative to the size of the islands or scene. The purpose of the margin to have texture interpolation + some number of mipmap levels without being affected by neighboring islands. For that you need a fixed size in UV space or pixels.

Further changes are needed because the current code is still not scale independent.

For example just take the default cube, duplicate it, scale the dup up to 10 times the size of the original, and apply scale.
Now if you unwrap both the original cube and the scaled cube you will see that the margin is scale dependent.

I have updated this patch to now still have a uniform margin while now begin object scale independent.

I'm unsure how we should make the gap size not be relative to the total packed island size. Because the range of valid gap sizes changes depending on the amount of islands.
For example the maximum gap size (in UV coords) for a single quad is 0.5 while for two quads it will be 0.25.
All of this will change wildly depending on the amount of islands and the size of the bounding boxes of the islands.

I'm not saying that this couldn't be solved better, I just can't figure out how to do this more elegantly at the moment.

@Brecht Van Lommel (brecht) do you have any ideas how to proceed?

Looking at this closer, I think your original patch is actually the right one to user here. Sorry for that.

Indeed for packing it's very hard to use a fixed size and know in advance if there will be enough space. We seem to do the same thing for the builtin Pack Islands function.

So I think you can go ahead and commit the original fix.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 28 2019, 12:57 PM
This revision was automatically updated to reflect the committed changes.