# Face map We can do our own UV mapping in shader nodes, considering every change of face direction is a seam. We just need some math with the face normals and the global axes. ## Main nodes Here we just connect your Voronoii setup with the said mapping for faces: [![Shader nodes][1]][1] ## Face map non Z - This is a subgroup inside the "Face map" group This maps every face, making their local Y be the projection of the given global Z onto the face (fails when face normal = global z) The principle is simple: - Crossproduct from global Z to Normal gives us local X - Crossproduct from Normal to Local X gives us Local Y - Dot products of position by each local axis gives us the projected position onto these axes [![Face mapping non Z][2]][2] ## Face mapping 2 (general) - this is shown in the main nodes Because the crossproduct is zero when normal equals global Z, we need exceptional treatment for faces that are flat on XY. [![Face map general][3]][3] Based on these questions: - https://blender.stackexchange.com/questions/326305/how-to-map-a-texture-to-faces-using-geometry-normals/326315#326315 - https://blender.stackexchange.com/questions/326768/rotate-texture-per-instance/326772#326772 -------------------- # Sphere map (using normals - require shade smooth) This is a simple map that takes the normals of the object and map these normals to coordinates similar to a UV sphere. If the object is sphere-like, there will be some distortions, but it might be good enough. It also requires the object to be shade-smooth. [![Sphere map with normals][4]][4] ## The node group For a sphere of radius 1, its normals are equal to its coordinates. All this node does is to transform these normals/coordinates into spherical coordinates and map the angles from 0 to 1, the same way a UV Sphere has its UV map. [![Convert normals to UV map][5]][5] # Sphere map (using position - require geometry nodes) [![Sphere map using position][6]][6] One quirk that can happen with normals is if you have concave objects, the concavity will have inverted texture. To avoid this, we can use a position-wise map (does the exact same thing as the previous map, but using positions). Advantages: - Can deal with concavities - Can be improved to have a displaced center (don't know if it would be useful) - Object can be rotated and texture will follow (to achieve this in shader, one would probably need to attach a driver to the rotation of the map taking the rotation of the object) Caveats: - Since shaders don't understand local geometry position (if it does, please teach me), I had to resort to geometry nodes. - The only attribute that gets interpolated by the shader is the one added to points, this means that the seam will have either the start or the end value, not both. So faces connected to the seam get funny mapping (I'll probably take some time later to think about a solution to this... vague ideas are forming). ## The geometry nodes [![Geometry nodes for sphere map][7]][7] # File [<img src="https://blend-exchange.com/embedImage.png?bid=Od0PDySk" />](https://blend-exchange.com/b/Od0PDySk/) [1]: https://i.sstatic.net/2fiSqxlM.png [2]: https://i.sstatic.net/53PWOsUH.png [3]: https://i.sstatic.net/xF7OmDqi.png [4]: https://i.sstatic.net/nScFyIuP.png [5]: https://i.sstatic.net/Z4XYZ46m.png [6]: https://i.sstatic.net/65kafbYB.png [7]: https://i.sstatic.net/7A8Kpcue.png