I was thinking of implementing a triplanar shader node, but am running into a problem. When I project onto the X plane, instead of looking up uvs based on a point’s x and y coordinates, I need to look it up based on y and z. This would be straightforward if I were upstream of the texture image node and could plug something into its Vector parameter, but I don’t have access to that inside my node group. Is there some other way to use the (y, z) of the position to do the lookup for the incoming Base Color X parameter?
Edit:
To put that another way, I want to be able to select my textures outside of the node group and have them be input parameters, but I want to generate the UV coordinates inside of the group.
Here is what I’m using for triplanar mapping, also supporting blend. This is a simple version, meaning it will fail if the blend gets too small. Old version, I have a newer one that allows me to also mix shaders, which is mostly used for blending out the edges of linear anisotropic shaders.
I’m typically using three planar mappings based on object coordinates XZ, YZ, and XY.
Don’t bother outputting a complete shader, it just makes the setup less flexible. Instead use one triplanar mapping nodegroup per value you want to map.
I try to avoid having to deal with UVs as much as possible, but yes, this system blends three differently oriented textures driven by three combinations of object texture coordinates on the outside.
XZ → Texture → Color1
YZ → Texture → Color2
XY → Texture → Color3
That is a requirement if you want smooth transitions over normals, like on box mapping on texture node itself supports, but on that one you can’t do any significant amount of rotations to the coordinates.
Just noticed something in that nodetree…In this case, you could replace all those ‘Dot Product’ nodes with a simple ‘Separate XYZ’, and reduce the computation by 9 multiplications and 6 additions…
The ‘Dot Product’ would only be necessary if the second vector isn’t any of the base axis, otherwise, it results in: dot( A, vector(0,0,1) ) => A.x*0 + A.y*0 + A.z*1 == A.z