Download

Randomise a texture slot within a material?

Hi is it possible to create a material that randomises between 4 different diffuse maps, whilst at the same time choosing the matching normal map?

if so could someone please show a screenshot of how this would work?

ive tried to find answers but all i can see is things like generating a colour from a multi-coloured single texture or selecting one of 4 splat maps from within the same texture.
i could so it this way, but if i want a 4k texture for example, it would require a 16k texture file?!

any help greatly appreciated

cheers, J

A texture can be a parameter so this is pretty simple straightforward.

First, obviously create a blueprint for the item - if you cannot, then multiple textures, custom material IF branch nodes, and per instance random - but I would do this as a last resort if you cannot use blueprint at all for the item.

Second, create a dynamic material instance and set it up.

You’ll want the texture you can choose form to be in an array so you can assign the texture(s) in editor, and you can use the Get function with a random in range integer to select the texture to use.

That its the node you want, disable context sensitive, spawn it in, and drag out from the texture to create the variable, then change it to be an array. Compile and save.
fill up the array.

Use a get on it. Drag from it, type get (context sensitive on). The node that comes in will want an integer.

Create a random integer withhttps://docs.unrealengine.com/en-US/BlueprintAPI/Math/Random/RandomInteger/index.html

Drag from the array and type lenght. Subtract 1 from it. Plug it into the random max.
put thepain from random to the Get.

Thats that. The texute is setup to be used.
now you just need to deal with the dynamic mateiral.
stolen from the docs;