[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

Share on other sites

Group SOP can do it out of the box.

select_part.hipnc

Share on other sites

You can also use connectivity to create primitive attribute and partition to create the group.

Share on other sites
16 hours ago, f1480187 said:

Group SOP can do it out of the box.

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.

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.

Edited by mestela

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.

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

Share on other sites

You could also subtract existing groups in the Combine tab of the Group SOP from new selection. Or use Split and Merge SOPs.

select_part2.hipnc