3
$\begingroup$

I'm building a game asset and want to keep an eye on equal mapping aspect ratio.

So my question is: how can I unwrap my object so that blender keeps a fixed ratio of 1 unit = 20px in the UV map. It doesn't matter if the UV mesh extends the UV texture, I will rearrange and scale manually.

Google or Stack Exchange didn't give me a good answer.

$\endgroup$
2
  • 5
    $\begingroup$ Check out the Texel Density tool in the TexTools addon. $\endgroup$
    – David
    Commented Mar 17, 2018 at 16:50
  • $\begingroup$ Thx David, TexTools is the solution. It offers an option to scale the UV Islands to a desired Pixel per unit size. :) $\endgroup$
    – Der_Fab
    Commented Apr 8, 2018 at 6:04

2 Answers 2

4
$\begingroup$

David's comment was the answer I was looking for.

TexTools is perfect for that. While in UV Editing mode it allows you to calculate the actual Texel-per-Unit-Ratio. You can also set a specific texel density manually which scales the UV islands to that specific size. It also offers many more options for UV editing.

A smaller version only to change the texel density ist the Texel Density Checker on Gumroad.

Both tools work together without interfering each other.

$\endgroup$
1
  • $\begingroup$ Do you mind explaining in detail why? $\endgroup$
    – brockmann
    Commented Dec 14, 2020 at 13:51
2
$\begingroup$

1. Load texture with desired size

First note that UV coordinates are relative to the width and height of the loaded texture. So in order to define your UVs in pixel-units especially if your texture isn't square you should first load the image-texture and use the option "correct aspect" that some unwrapping methods have.

If no image is selected, blender will assume 256x256.

2. Evaluate Stretching

To get an even pixel-per-blenderunit ratio across the asset your unwrap should have no stretching in angle and area. No stretch means if you print the UVs on paper and cut out you should be able to build the 3d modell out of it.

To evaluate stretching activate Display->stretch:

Display stretch in Blender UV Editor

Note the concave/convex parts of the model in the screenshot: More seams need to be added or a method like "Smart UV Project" could be used. In addition the function "minimize stretch" can optimize the result.

3. Find out the pixel-per-blenderunit ratio

There might be other methods/addons for this but it's not so hard to calculate by hand:

  1. Messure the length of an edge in 3d viewport by calculating the distance between the two vertices:
    $d_{3D} = \sqrt{(x_{v1}-x_{v2})^2+(y_{v1}-y_{v2})^2+(z_{v1}-z_{v2})^2}$
  2. Messure the length of the same edge in UV-Map by calculating the distance of the two UV-vertices:
    $d_{UV} = \sqrt{(x_{v1}-x_{v2})^2+(y_{v1}-y_{v2})^2}$
  3. Calculate the pixel-per-blenderunit ratio with:
    $currentratio = {d_{UV} \over d_{3D}}$

In a UV without stretching this ratio should be the same for every edge.

4. Scale UV

Having found out the current px/bu ratio you can scale your UV by a factor s to get the desired ratio:

$currentratio \cdot s = desiredratio$

This leads to:

$s = {desiredratio \over currentratio}$.

Alternatives to UV

Also have a look at the other texture coordinate methods in blender although I'm not sure wether you can use them in a game.

$\endgroup$
1
  • $\begingroup$ One very convenient way to find distance with vectors is (v1.co - v2.co).length (where v1 is a vertex, and v1.co its vector coordinate) Vector math pretty much removes the need to use Euclidean distance formula. $\endgroup$
    – batFINGER
    Commented Mar 17, 2018 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .