Im trying to make a "simple" shader that tiles and rotates a texture atlas ramdomly to avoid visual repetition, it works fine when used in a normal material, but when I try to implement it on a world triplanar I can't get the uv's to rotate on their own position instead of the world origin so the overall texture gets a little skewed.

```
vec2 rotateUV(vec2 uv, vec2 pivot, float rotation)
{
rotation = radians(rotation);
float cosa = cos(rotation);
float sina = sin(rotation);
uv -= pivot;
return vec2(
cosa * uv.x - sina * uv.y,
cosa * uv.y + sina * uv.x
) + pivot;
}
vec2 rand_tiled_uv(vec2 uv)
{
vec2 seed = floor(uv);
vec2 r_uv;
if (rotate)
{
r_uv = rotateUV( uv, vec2(.5), rotation_d * floor( rand_range(seed + rng, 0,4) ));
}
else
{
r_uv = uv;
}
lowp float x = rand_range(seed + rng, 0, tiles);
lowp float y = rand_range(seed + rng + 1., 0, tiles);
vec2 rand_offset = vec2(1.) - ( vec2(1. / tiles) * ceil(vec2(x,y)) );
return (r_uv ) + rand_offset;
}
vec4 triplanar_texture(sampler2D p_sampler,vec3 p_weights,vec3 p_triplanar_pos)
{
vec4 samp=vec4(0.0);
samp+= texture( p_sampler, rand_tiled_uv(p_triplanar_pos.xy) ) * p_weights.z;
samp+= texture( p_sampler, rand_tiled_uv(p_triplanar_pos.xz) ) * p_weights.y;
samp+= texture( p_sampler, rand_tiled_uv(p_triplanar_pos.zy) * vec2(-1.0,1.0) ) * p_weights.x;
return samp;
}
```

(the rest of the shader is just a normal converted spatial material)

normal texture

randomly rotated by 90 (some lines are bigger or misaligned)

randomly rotated by 95 (the crosses aren't centered)

rotated normally by 100

This is what I want:

I googled and tried all similar questions on here (I think I should use this somehow) and even on the unity forums but I just distort the texture beyond recognition. Any help?