Random Texture from arrays?

I was curious if there is a way to have one shader that can pick a random texture from an array, or if i have to just make a bunch of material instances with each one set to a different texture?

1 Like

I think you might be looking for a texture atlas

I don’t remember seeing an array texture in shader file, but I can imagine what you mean done by additional script to the shader, have you tried that?

never used them. are there any good resources i could use to learn how?

No idea how to do that. would appreciate some pointers

Easiest way is to subdivide your texture like you would for a flipbook then select the texture you need like you select a random frame of a flipbook.
Only real downsides are that it obviously loads the entire texture even if you don’t use the whole thing, and tiling might not work perfectly

simply by making 2 variable :
textures array and material
with a function that generate a random number that doesn’t exceed the length of the textures array
and then setting this material texture property or something to this randomized texture

I’m not sure exactly how the communication between scripts and material works in unreal (I guess that what you are using)

1 Like