Hi, it is possible what i try to show in this picture?
I want to randomize the material of a mesh, but i dont want to create many materials, if can randomize texture sample inside a material.
Through blueprints, you could make an array of the various textures. Then make a master material with a texture input parameter. The blueprint would then need to make it a material instance dynamic. From there, you could randomly pick from the array and that texture would be piped into the material.
Yes, thanks, but its not possible to do it inside a material?
That material will be very inefficient. It would sample from all textures and then just use one. It can be done by using per object random(or object position as seed).
use the construction script in blueprint for this task
If I recall correctly, this only works with instances meshes, but you could definitely use object position as a seed with some randomizing math to sort it out.
Again, this would be HIGHLY inefficient to perform within the single material. Just use my suggestion from earlier with MID+array.
Yeah thanks. I just hoped in material way. Then do with BP.
It would be nice if we could use texture arrays for this. One could probably code them in, but it would be a big project.
Were you able to randomize the materials?
If you create a texture-parameter in a material, you can randomize the material by using outside logic to set whatever texture(s) you want in those parameters. such a material only has to know about the 1 texture will ultimately be using.
if you want to randomize INSIDE the material then that material has to know about all the POSSIBLE choices you might want it to take. this is likely very expensive and extremely inefficient.
you are likely best served with the former method, make one master-material and use outside logic (blueprints for example) to make changes to the material-instance as you need them
Essentially, yes.
To my eyes it looks like you have material-instances in an array and you are changing between them as needed?
That should be fine. I would caution that overall, change as little as you need to. If it’s just a texture that’s changing vs a whole material, don’t swap materials, just update the texture-parameter.
For those of you like me searching for this on google but found no answer, this is how you can do it.
I use the world position to select a “Seed” (random number) and multiples that by the number of options, then floor it to round it to the nearest whole number, and plug it into a switch - then plug the switch into the diffuse color (ignore I am using “Emissive color” its just for my instance I am using this to generate random parallax exterior windows that emit light.)
Now every option color/texture is based on its location, which appears random enough for static meshes.
If you want more control over it and not have the material be a dynamic material, use the primitive custom data.