Skip to main content
1 of 4
Markus von Broady
  • 42.6k
  • 3
  • 37
  • 107

Building on top of other answers, and especially theStandard's idea, I came up with Texture Atlas approach.

  1. Put all textures into one file (in this example I put them vertically, each texture below another) and name it base.png (for Node Wrangler to recognize it).

  2. Create a default material, select Principled BSDF node, press CTRL + SHIFT + T for default setup (you need to have Node Wrangler enabled in preferences->addons).

1

  1. UV map the mesh to the first texture in the file:

2

  1. Changing the Y location in mapping will now scroll through the texture atlas:

3

You can notice that 0.33 m will point to the 2nd texture, and 0.66 m will point to the last one. That's because there are 3 textures, and each takes 1/(number of textures) m height.

  1. Add a Value node, rename it to Number of textures for future reference and set the value to 3 (as in this example there's 3 textures in the atlas)

4

  1. As in Greg Zaal's answer, add Object Info node for the "Random" value.

  2. Add Math node and multiply Random by number of textures, to convert our random range from 0 <= x < 1 to (in this example) 0 <= x < 3:

5

  1. Add another Math node, to Floor the previous value, converting it from 0 <= x < 3 to x ∈ {0, 1, 2}. The following node setup simply converts a value in range 0..1 (excluding 1) to a non-negative integer lower than the integer we provided (marked red on the screenshot).

6

It's a standard node setup for snapping.

  1. As mentioned in p. 4. The offset for each texture is 0.33 or 1/3 m. We could just input it as another value, but it's better to calculate it automatically, so we don't have to manually update it, when we change the number of textures in the atlas (and so only the node added in p. 5. will have to be manually updated):

7

  1. Now let's multiply one by another to convert x ∈ {0, 1, 2} to x ∈ {0, 0.33, 0.66}, and then use Combine XYZ node, as we can't put our Y directly to Mapping node [I also rearranged the nodes visually a little].

8

Final node setup:

9

And their effect:

10

Markus von Broady
  • 42.6k
  • 3
  • 37
  • 107