What does 'Cube Size' mean when using Cube Projection UV unwrapping?

I don't understand how Cube Size is handled when doing a Cube Projection. Here is my example scene: my cube is 1m by 1m, applied rotation & scale, so its just a clean, perfect and beautiful 1m cube.

Let's say we have a perfect tiling texture where the correct mapping scale is 1m.

So I apply my cube projection... but I must set 2 to have the correct scale. Why not 1, like 1m?

• here the .blend if someone wants it pasteall.org/blend/index.php?id=44724 Commented Dec 20, 2016 at 11:27
• blend-exchange.giantcowfilms.com is the preferred upload method for blends as the links won't expire. You can then add the embed code to your question using the edit link below it. Commented Dec 20, 2016 at 12:06

Cube projection iterates over the mesh faces and for each does the following:

• It considers the dominant normal axis of the face, and keeps the coordinates around this axis. For example if the dominant normal axis is X, the considered coordinates will be Y and Z. This is the 'cube/cube projection' aspect and this cube is fixed along the global axis (we'll have a flat projection on the world's axis).

• Then it calculates U and V from the center of the UV Map (0.5) and adds 0.5 * (the parameter 'cube size') * (the object's location + the corresponding vertex location)

The code is the following:

luv->uv[0] = 0.5f + 0.5f * cube_size * (loc[cox] + l->v->co[cox]);
luv->uv[1] = 0.5f + 0.5f * cube_size * (loc[coy] + l->v->co[coy]);


So the result will depend on: the cube size parameter, the object's location (at 'object level') and the vertices location (at 'edit level').

• BUT for the first vertex of the face, it calculates a rounding which will offset all the vertices of the mesh, using:

if (first) {
dx = floor(luv->uv[0]);
dy = floor(luv->uv[1]);
first = 0;
}

• And after that using the following for all the vertices of the face:

luv->uv[0] -= dx;
luv->uv[1] -= dy;


So the result may appear erratic as the way the rounding of the first vertex works does so, depending on the way the faces are organized (shared vertices between faces), some UV faces will overlap or not.

Once this calculation is done, the operator considers the two other parameters which are 'clip to bounds' and 'scale to bounds'.