How do I create a material that rotates its textures in random 90 degree increments?

I am trying out methods of reducing texture tiling with a damaged tile floor. So far I have tried:

Texture Bombing - Looks okay but the tiles don’t overlap at the grout which creates some rectangular tiles.

Macro Variation - Doesn’t work well for tiles because the texture does not contain almost uniform color; the damaged part of the tile is significantly darker than the title itself.

I have not tried distance tiling yet, but I think I have a method that would work great for tile. Check out the gif below:

This is a setting called natural textures from the Minecraft Optifine mod. As you can see, it simply rotates each instance of the texture a random amount in 90 degree increments (the 90 degree part is important or the tiles won’t be aligned). How would I go about recreating this in the material editor? I’ve played around with the custom rotator node, but I can’t get each instance of the texture to rotate on its own, they all rotate together.

Any help is much appreciated.

Hi! Did you ever find a solution to this?

Every time a texture tiles, it enters a new UV range. This means you can isolate a tile based upon its UV coordinates. X 0-1 will be the first column, X 1-2 will be the second and so on. Y will be the rows.
It’s difficult to get true random values, but you can use a noise node, and scale it until each value covers one full tile.
Make sure the noise has only 4 levels (one for each rotation. The noise can now be used to control the amount of rotation of any given tile.

You will also need to manually provide DDX and DDY for mipmaps as the rotated UVs will create seams on the edge of tiles if you use automatic mip derivatives.