1
$\begingroup$

The Vector of a UV map consists of 3 channels as for any vector in 3D space (whether Generated, Object, World, etc.) and as can be accessed via the Separte XYZ node. The 'U' and 'V' correspond to the 'X' and 'Y' outputs but the 'Z' ('W' in UVW space) is always zero.

Is there any way of assigning values other than zero to that 'W' channel? Obviously not via the standard 'UV unwrap' functions (since those only deal with the surface mesh so W is always zero) - but is this possible via Python?

I have tried using BMesh to assign the UV coordinates as in this answer but that only assigns uv[0] and uv[1] but doesn't seem to allow uv[2].

I have tried using Vertex Colors as an alternative (as they do allow 3 channels) but those are only to 8-bit precision (ie, 0.0 to 1.0 in 256 distinct steps) and so are far from ideal. The other potential solution would be to store the vertex points in another data structure such as pixels in a 32-bit color image (similar to this answer but storing vertex data rather than object data), referenced via an Image Texture from a vertex ID assigned using Vertex Colors but that's just plain messy - it would be far simpler to be able to use a 3-channel UV map to store 3 channels of float-32bit data.

Any ideas as to how the 3rd UV channel can be assigned or does the code behind the scenes not even store it?

$\endgroup$
  • 1
    $\begingroup$ Using a second UV map where U may be used as W? $\endgroup$ – lemon May 9 '17 at 10:58
  • $\begingroup$ Good suggestion for a workaround. It wouldn't be ideal but should certainly work. $\endgroup$ – Rich Sedman May 9 '17 at 11:04
1
$\begingroup$

Looking into the Blender source code, the UV processing does not account for the third channel - so this is not possible within a single standard UV map. In order to store an additional (W) channel you could use an additional UV map - eg, 'UVMap1' could hold U and V while the 'U' channel of 'UVMap2' could hold the 'W' channel. However, this method does not provide a simple method of manipulating the UVW map (since the W channel needs to be manipulated separately.

That said, by considering the two UV maps as a 'front view' and a 'side view' of UVW space we can achieve a similar effect - but you need to be careful when manipulating the UV maps to ensure they stay consistent.

To demonstrate, start with your initially unwrapped mesh - a standard UV map :

uvmap

Copy the UV map (click the '+' alongside the list of UV maps in Edit mode) and rename them to make it clear that one is the UV "front" view and the other is the 'WV' "side" view. 'Select all' (A), scale to zero in the X-axis (SX0Enter) and select everything and move it to the size (GX then drag to the side). You should now have something like this :

uv maps (front and side) animated

Now to move points into the W dimension you can simply select them (or select a whole face) and drag them along the X (U) axis with GX.

uv edited into w

To combine the separate 'front' and 'side' UV maps into a UVW map you simply need to separate the channels and re-combine into a single UVW vector :

using uvw

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.