Jump to content

[help]Create groups of random instanced objects


Recommended Posts

Hi,

I am scattering a bunch of torus on a grid and the total number shown is 110 primitives. I want to create a bunch of groups so that I can assign materials to those specific groups. Right now, I can manually create groups in my material node ( group : 1-20, 21-40 ) and so on..

I was wondering if there is a way of doing :  "create one group out of 40% of the total objects" .. this was it will randomly select some objects and create a group for them.

I hope i was clear in explaining.

Thanks~
~N

Link to comment
Share on other sites

16 hours ago, f1480187 said:

Group SOP can do it out of the box.

select_part.png

select_part.hipnc

Thanks for the file! :)

I am, however, unable to create multiple groups. In the first group, it says "Select 20 of 100" but if i create another group underneath it and say "Select 30 of 100" it combines both the groups. I am trying to assign different materials to different groups of primitives.

 

Link to comment
Share on other sites

You could have a primitive attribute between 0 and 3, and use the attribute group syntax to assign materials. eg, the first slot would use the group @materialid=0, the second @materialid=1, etc.

An advantage of doing it this way is you can create that attribute using a point wrangle, and use a ramp to easily adjust the distribution.

Here I'm generating a random number between 0 and 1 per torus, remapping it with a ramp, then multiplying it by 4 and converting to an integer. With that setup, and a material sop setup as mentioned earlier, if all the torii have a materialid of 0 (ie, the ramp is flat and at the bottom of the graph), they all get the first material (which here is red). if they're between 0.25 and 0.5, they get the second material, 0.5>0.75 the third...

If you add more points in the graph, you can make just 2 materials be assigned evenly, or weighted 80% towards 1, or have all 4 materials in various distributions.

Channel ramps are awesome. :)

material_distribution.hipnc

material_distribution.gif

Edited by mestela
Link to comment
Share on other sites

2 hours ago, mestela said:

You could have a primitive attribute between 0 and 3, and use the attribute group syntax to assign materials. eg, the first slot would use the group @materialid=0, the second @materialid=1, etc.

An advantage of doing it this way is you can create that attribute using a point wrangle, and use a ramp to easily adjust the distribution.

Here I'm generating a random number between 0 and 1 per torus, remapping it with a ramp, then multiplying it by 4 and converting to an integer. With that setup, and a material sop setup as mentioned earlier, if all the torii have a materialid of 0 (ie, the ramp is flat and at the bottom of the graph), they all get the first material (which here is red). if they're between 0.25 and 0.5, they get the second material, 0.5>0.75 the third...

If you add more points in the graph, you can make just 2 materials be assigned evenly, or weighted 80% towards 1, or have all 4 materials in various distributions.

Channel ramps are awesome. :)

material_distribution.hipnc

material_distribution.gif

holy whoah! This helps a lot! Thanks so much! :):)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...