# Generating a UV map from object generated texture coordinates

I'm trying to map planet textures on spheres, and the maps are Equirectangular. I'm initially mapping the textures to the spheres by using "object" generated texture coordinate input as the vector for and "environment texture" node instead of "image texture" since environment texture node has a equirectangular projection setting and image node does not. This is currently the only way I've found it possible to map equirectangular textures to spheres without distortion.

Now that I'm ready to paint on the textures and add mountains and valleys to the planets, I have to UV unwrap the spheres. Is there a way to bake or generate a UV map from the object generated texture coordinates?

Spherical Coordinates

The pictured above part of node setup from https://blender.stackexchange.com/a/148354/15543 (refined from https://blender.stackexchange.com/a/159492/15543)

produces spherical coordnates (r, theta, phi) from object texture coordinate (x, y, z) Equirectangular coordinates map latitude to U and longitude to V .. (or is it vice versa) and are recognizable from their 2 x 1 aspect ratio image.

The latitude is mapped to [-pi/2, pi/2] the longitude [-pi, pi] mapping both to [0, 1] by dividing by range (pi for latitude and 2 * pi for longitude) and adding 0.5 will produce Equirectangular UV coordinates to plug into a texture node.

Note the mapping node is not required, but can be used to alter the meridian for example.

Alternatively could use vector maths and input up and zero meridian vectors.

Texture Painting

If we set up a sphere from a grid, or plane as described here

How to animate morphing a rectangular plane into a sphere in particular using method for 2.8 used here https://blender.stackexchange.com/a/24053/15543

poles are nicely collapsed to a point, and the UV is a perfect quad. Hence can texture paint on our sphere to an Equirectangular projection image.

First time texture painting.. but in the right spots

Note: Made the grid 2x in x dimension. Empty rotated (90, 0, 90) the simple deforms -180 in z on top of -360 in x.

• thank you so so much this eliminates the problem of environment texture nodes not being recognized in the texture paint, but i still need to somehow bake this mapping into actual UVs so that i can paint on the sphere in 3D. I think that it uses the UVs to project the paint in 3d to the 2d textures. – zander Dec 15 '19 at 6:14
• Thanks layering the generated coordinates with a uv texture definitely helps. I'm working with icospheres and I've since opted to baking the textures to the default ico unwrap since it has the most even pixel distribution across equilateral triangles. Now I've run into a little blending issue across the UV seams and made a new question for it here: blender.stackexchange.com/questions/161359/… – zander Dec 19 '19 at 9:15

I've probably missed the point, so sorry, delete coming... but isn't Equirectangular the default unwrap, that comes with a UV Sphere?

(Image courtesy Wikipedia)

• Unfortunately it gets a bit gnarly at the poles. Each pole maps to top and bottom line of UV to a point, whereas UVMap has the sawtooth. Using wrap wrap.. or is it warp warp on a grid is another way to do it. – batFINGER Dec 15 '19 at 15:04
• blender.stackexchange.com/questions/24043/… – batFINGER Dec 15 '19 at 15:09
• ahh. OK... I'll leave this up, it may help make the problem a little clearer. – Robin Betts Dec 15 '19 at 15:33