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:
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 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.
Based on these questions:
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.
Important:
If you intend to rotate the object, you need to "invert" the rotate vector inside the node group, then you need to copy each rotation value of the sphere as a "driver" and add each driver value to the rotation of the "Sphere Map" group
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.
Sphere map (using position - require geometry nodes)
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
- Does not require shade smooth
- 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
File