Tile a texture and randomly rotate it at 90 and 180 degrees only

Is there a way to set up material nodes such that I have a texture and after I tile it, I can then randomly rotate each square of the tiles 90 degrees in either direction and also 180 degrees in either direction?

You ll find tile stamper here a shading node i ve done for that few years ago…

Good luck

1 Like

Will check it out. Thanks so much :pray:

After testing the material node , I am not sure if rotates the uv tiles square randomly at fixed degrees. :slightly_smiling_face:

From this vid here, I am trying to randomly rotate each tile square limited to 90 degrees or 180 degrees.

From the timestamp om the vid here: https://youtu.be/VTw-IL2SgRQ?t=17

Its something along those lines. I have a texture I have painted in Krita such that I can rotate it 90 degrees in any direction, the edges match so I am trying to tile it and, all the individual squares in the tiled texture randomly rotate in different directions maintaining a 90 degree state.
Also 180 degrees as well.

I am not sure if I am explaining it well.

EDIT: Found this thread here: Random Tile Placement and Rotation in Cycles Material - #6 by anopheles
This is from one of the blend files posted there:

sample

How do I get each square rotation to always stop at a 90 or 180 degrees and the rotation placement is random?

Will really appreciate any help I can get. Thanks.

object info node random, math snap node, math degrees to radians node, combine xyz node, vector mapping node… maybe, I haven’t tried it yet

do you want the randomness to be per face or per object? I achieved this effect recently with geometry nodes but I can’t figure out a way to get it just in shader nodes.

1 Like

Thanks thinsoldier, :slightly_smiling_face:

I am trying to achieve this through the material using uvs, so the tiled uv square can rotate randomly and are always 90 degrees so, it can rotate randomly between 0, 90, 180 and 270, so that way the textures are always upright. So I am thinking of a way to have 4 parameters where I can enter the 4 vaules and the tiled uv squares rotate using those stepped vaules, no rotation vaule in between is used.

Is the randomness only possible using geometry? Is it possible with uvs?

If you want the UV map to align, definitely avoid using trig! It’s much more computationally efficient just to flip the channels of the UV map to get what you want.

If you apply modulo 1 to the X and Y channels of the UV map, you’ll get each tiles value between zero and one. You can then mirror the channels by using math nodes to subtract that value from one. Mirror twice for a 180 degree flip, swap the channels and mirror one channel for a 90 degree flip, and combine these four options back into an XYZ node.

For randomly picking, apply a floor node to the XY of the master UV map, which will give you an integer UV for each tile. Plug that into a noise texture to choose random values for each tile. However, notice that the brightness value for each tile will not be a flat distribution, with more values clumped around mid grey - so if you want an even chance to pick each of the four tiles, use a separate HSV node, and extract the “Hue” channel. Then you can use a series of “Greater Than” nodes to choose between your four UV maps. I tend to use MixRGB for this, although there’s probably a more sensible way. Then you can just plug the UV map into your image texture, and it should give you a random rotation for each tile.

This should allow you to use a texture mapping node to scale and translate your texture, as well as rotating around the Z axis, but bear in mind that it will break if you try to rotate on other axes. Also, if you remember to plug in the Z channel to your noise texture, moving the texture up and down the Z axis will allow you to change the seed of the randomisation.

rotate.blend (867.6 KB)

7 Likes

Thanks a ton :+1:

Here is another texture using your node setup. Thanks.
sample

I created it in Krita so all the edges match when randomly rotated. With your writeup, if I need it fixed at 0, and 180, I just need to delete some nodes from your setup. :slightly_smiling_face:

Also I noticed this doesn’t work for curved surfaces or cube. Is there anyway to make this work for more organic meshes?

Thank you so much, I am grateful.

Yeah, the approach I used assumes you’re using 2D UV coordinates, and in the file I linked I think I plugged it into the “generated” slot which 1) includes a Z dimension (which as mentioned, will adjust the noise texture but nothing else, which is why the sphere looks garbled), and 2) locks the texture coordinates to the orientation of the object (which is why it projects straight down onto the cube and ignores the sides).

If you swap the texture coordinate input to “UV” it should map onto 3D surfaces (assuming your object has a UV map assigned, which default cubes and spheres do these days).

2 Likes

Thanks a lot. Followed your direction. Looks perfect. :+1:

Marked as solution.

1 Like