# UV cubic map procedurally

## Recommended Posts

It seems simple but I couldn't figure out how to procedurally create a cubic UV map fora a simple 6 sides cube, Any tips?

Thanks.

##### Share on other sites

Not sure what you mean. Have you tried the UVUnwrap SOP?

##### Share on other sites

Thanks for the feedback.

Is about the way the uvs are layed, it needs to be layed follow a cubic vertical environment cube.

UV unwrap works for texturing but it doesn´t position the uv´s right away with the cross cubic env image you have to do it by hand. Does it make sense?

##### Share on other sites

You can do this by doing 6 separate projections (UV texture or UV project) for each side to the cube and move them in position.

If you simply do that upfront, you can afterwards change the cube and the UVs should remain intact.

You could even morph this cube in a quad sphere if that is what you are looking for.

Shameless self plug is shameless:

http://www.twandegraaf.nl/Art/Documents/Procedural%20planets%20into%20detail,%20Twan%20de%20Graaf%202012.pdf

see page 6.

• 1

##### Share on other sites

Here is a vertexwrangle method for projecting cubic UVs on any kind of mesh:

```vector bbox = relbbox(0, @P);
vector side = sign(@N);
vector nml  = abs(@N);

vector size  = getbbox_size(0);
vector ratio = size / max(size);
vector scale = bbox * ratio;

if      (nml.x == max(nml)) { @uv = set(scale.y * side.x, scale.z, 0);             }
else if (nml.y == max(nml)) { @uv = set(scale.x * side.y, scale.z, 0); @uv.y += 1; }
else                        { @uv = set(scale.x * side.z, scale.y, 0); @uv.y += 2; }

@uv *= 0.3333;
@uv.x += 0.5;```

Edited by konstantin magnus
• 7

##### Share on other sites

I tried a similar thing a while back, its a fair amount of script to position the uv projections on each side of the box

Hope it helps

##### Share on other sites

Thanks Konstantin, it seems to work well for spaceship parts.

Now I can finally paint my ships in Mari!

Edited by Atom

##### Share on other sites
20 minutes ago, Atom said:

Thanks Konstantin, it seems to work well for spaceship parts.

Hehe cool, makes me proud to see it´s of any use!

##### Share on other sites

Loved that one, very usefull, thank you !

## Create an account

Register a new account