I might have found a great way to determine the MARGIN value for UVs / pixel padding

Hey blenditos,

I am working on a complex texturing tutorial for quite a while now. Today I wanted to investigate a bit further on how to calculate the margin space for pixel padding when baking textures down with Tex Tools for example. First I thought the 0 to 1 margin space (available right after unwrapping or packing UV islands) would be percentage but that’s obviously not the case. Other people on Blender stack exchange seemed to be just as puzzled as I was.

So I created a 100 px by 100 px texture in Gimp, ran a filter → artistic → cubism → 1 tile → to make it easier for me to count the pixels in the UV coordinate system, pluged it in on a cube unwrap (each face seperately) and amped up the UV margin to 1. I counted [roughly of course!] 18 pixels and applied that value to other texture presets.

So I took the next step: 128x128. I multiplied 128 by 0.18 and got 23,04.
To get the UV margin input for blender for 4 pixels for example I then just divided 4 by 23,04. And it worked!

Until it didn’t for higher values than 4 in regards to 128x128. (but you don’t need more than 2px padding for 128 anyways)

I went higher up: 4096 and made some reverse calculations. And right now, I got 0.19 as a pretty solid value to get an almost perfect margin space for any texture preset from 1024 to 4096.

Just another example:

Goal: 16 pixel padding from each Island (32 pixels total margin space)
→ 4096 x 0.19 = 778.24

=> 16 / 778.24 = 0.02055992…

Of course it’s nothing too precise here. That wasn’t even my intention as it’s a coordinate system anyways. But after pluging in a 4096 texture i counted the pixel space between the Islands and it worked great. For more complex UVs you might wanna increase the final output value an itsy bitsy but it should provide a solid base which doesn’t require counting the pixels.

You can get the pixel textures here on my website if you want to try it out yourself, or recreate them as mentioned above: https://www.moonman-pictures.com/mmp-marketplace.html#scroll-to-resources

The tutorial (lengthy, close to one hour, was a lot of work) will go online probably 27th / 28th of April 2019.

hope this helps some people out there! If you want to add anything, I am looking forward to talking to you,
if my math is bs, just hit me :stuck_out_tongue:

Jojo.

4 Likes

Thanks a lot for sharing this information :slight_smile:
blender margin values was pretty confusing.

1 Like

Hey, awesome to hear that it helped you out.

I have actually released the tutorial video today, including the margin math, etc. :

https://www.youtube.com/watch?v=eh3pNZ9RpBw

Am super nervous :smiley: was a lot of work, so I hope you like it!