Assigning a random material to multiple objects

Assigning a random material to multiple objects

adam_deakin
Participant Participant
1,230 Views
2 Replies
Message 1 of 3

Assigning a random material to multiple objects

adam_deakin
Participant
Participant

Is there a way assign a random material (from a set group of materials) to lots of different 3ds max objects?

 

All I can find online is the MaterialByElement modifier and that's not what I'm looking for because that requires all elements to be merged into one object which I don't want. 

 

This seems like it should be an easy thing in theory but I can't for the life of me figure it out. Any help appreciated.

0 Likes
1,231 Views
2 Replies
Replies (2)
Message 2 of 3

wernienst
Collaborator
Collaborator

When using Arnold Renderer you could put a Color Jitter map to the Base Color (or any other) map slot. This however would only randomly change that color.

Next, there is the Switch shader. You put up to 20 materials in its material slots and create randomly an index which of them to apply (so far I haven't found a way how to do this. Maybe an Arnold expert could help us).

And finally, of course, you could do it by scripting. Assuming the materials are in slots 2 to 5 of the Material Editor, a simple script would look like this:

MatFrom = 2
MatTo = 5
if selection.count != undefined do (
  for i in selection do (
    MatRandom = random MatFrom MatTo
    i.material = meditMaterials[MatRandom]
  )
)

0 Likes
Message 3 of 3

CAMedeck
Advisor
Advisor

The best method will depend a little on what render engine you're using, and if it truly needs to be a different MATERIAL, or just a different COLOR.  

 

Regardless, you could put all the materials you're using into one Multi/Sub-Object material and assign random Material IDs to the objects.  There are scripts out there to do that for you.  

 

If it is just changing the color, and all other material properties can be the same, V-Ray has the VRayMultiSubTex that let's you assign multiple colors or Bitmaps into the Diffuse slot of a material, and then set 'Get ID from' to Random and check boxes below to determine the method.
Actually, as long as maps are used in all material slots, you could use the VRayMultiSubTex for all slot and they'll randomize the same if all values in the map are identical.  One material, and VMST varies the maps for Diffuse, Bump, etc.

Chris Medeck
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes