Randomize Texture For Group Instance

Hi Guys,

I have created the cityscape. In that scene the buildings are arranged in both sides of the street. I have used this buildings as collection instances. Is it possible to differentiate the instanced buildings using randomize textures?

Thanks,
Vasanth

1 Like

It is! Using the Object Info node, you can have a Random input that will input a random value from 0 to 1 per object sharing the material. Put this through a Color Ramp to split it into two values, use that as an input for a Mix with two textures, and it will pick one of the two at random. For more than two, you can use a logical AND array. Give me a second to show you how that would work.


This shows four cubes that all have the same material. You’ll notice they can either be blue or pink, and which it is is random. Notice also how the AND works: a Greater Than and a Less Than going into a Minimum.

Now, by combining more of this setup, you can get more options:


It’s the same thing, just with TWO Ands and corresponding RGBs (which could be image textures or anything else.) The first And works with random values from 0 to .4, and the second works with .4 to .8. Then, a Greater Than .5 is the factor for the final Mix- essentially, the random input is picking one of the two sets.

Finally, some why. I’m collapsing it, it’s a bit not-related to the question, I just want you to understand the nodes.

Summary

I’m using an AND operation because it gives one of two values- 0 or 1. This way, you never have to worry about the textures blending, it will always be one or the other. For context, one of those AND statements written out would look like this:

If Random value is Greater Than 0 and Less Than .4, return 1. Otherwise, return 0. 

The Minimum is the key to the AND operation. If a Number is Greater Than 0, for example, the Greater Than node will return 1. However, even if the number was 1254380, the Greater Than node will still return 1. Likewise, if the number is less than .4, the Less Than will return 1, even if the number is -54379354. In order to find a value that matches both operators, you need to use the SMALLEST value as the result. If one test returns 1 and one returns 0, the And result should be 0. The Minimum checks these tests and determines if they are both 1 (which will return 1) or if one is 0 (returns 0.) Incidentally, using Maximum instead allows you to create an OR operator. This will take the LARGEST value, and will return 1 if either test returns 1.

If you’re wondering how well this works at a full scale implementation, like you’re describing, check this out:


This is just duplication, they all have the same material.

1 Like

Fantastic Joseph Hanson!

Thanks for the input. You are provided the clear explanation and it’s works well for my project.

Regards,
Vasanth

1 Like