Making a 3D triplanar stochastic texture shader for tiles

Godot Version

4.2.1

Question

I made a shader intended to tile a texture over a mesh, and rotate each tile randomly in multiples of 90

Currently it’s working, although the scaling is off depending on the mesh, I’m guessing because of the UVs being different size. Making the shader triplanar somehow sounds like it’d fix the issue

Here’s an example of what it does:

3D mesh with tiled arrow texture, no shader:

Same mesh after shader applied:
image

(some clear noise patterns are visible, but it’s good enough for me and fixing it sounds like a pain)

File in drive

Messy screenshot of the current working shader (not messy in the uploaded file above):