Jump to content
CaptainAhoy

[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 this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
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! :):)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×