I'm hoping someone can explain the logic behind how UV island margins are handled in Blender. As far as I can tell there are 3 locations where island margins can be set to affect UV packing: Pack Islands, Smart UV Project, and Lightmap Pack. All three of these handle the user entered margin value differently.
I'm still working my way through the code to understand exactly how it works but Pack Islands seems to use a different margin for each island based on the diagonal of the island's bounding box, the user entered margin, and a fudge factor. The final gutter between islands also depends on the size of the surrounding islands as they all have their own unique margins as well. Smart UV Project has its own implementation of a similar scheme, however, in its implementations all margins end up scaled relative to the size of the largest UV island. In contrast, Lightmap Pack interprets the user entered margin value as a fixed percentage of the UV area dimensions. The first two approaches seem extremely counter intuitive. I don't particularly care how big my island margins are relative to the size of the islands but I do care how big they are relative to the texture space. In that regard, Lightmap seems like it is doing the right thing. If I'm planning to use a 2K texture map and know I want a 16 pixel margin I would like to be able to enter 16/2048 as the margin and know that is what I'll get. You can almost do this with Lightmap Pack, although you have to enter 1600/2048 because the input margin is divided by 100. I'm not sure if this is bug, most other parts of Blenders UI seem to consider values in the range 0-1 as representing the range 0-100%, not 0-1% like Lightmap does. One simple change that would start to unify this area would be replacing Smart UV Project's packing code with a call to Pack Islands, I have a patch that already does this. One downside to this change is that although Smart UV's current packing is very inefficient in terms of texture space it is much faster than Pack Islands, something like a factor of 10 in a few quick tests I ran. In practice I'm not sure if this is really an issue. I usually end up running Smart UV Project, then running Pack Islands, then running Pack Islands again because the default margin is not what I wanted; so getting a more efficient pack directly out of Smart UV would speed things up. After that changes to Pack Islands could be looked at. I'm certainly not an expert on these matters so hopefully someone who is can correct me if I've made any mistakes or bad assumptions. Given that none of this behavior is really documented it seems like it would be helpful to make it more consistent and predictable. Best, -- Jed Frechette _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers