Jump to content

change sort seed for each copy in one sort node


Recommended Posts

You are on the right path.
You need the seed to change for each sphere.
The question is, what is different on each spheres ? You said it, copynum.

Sadly, you cannot simply put in copynum into the seed and expect it to work - the parameters are cooked only once, meaning they cannot have different values for different parts of the geometry.
So, if one geometry cannot have different parameter values for it, how about multiple geometries ?

The solution is to use the for each node.
There is a mode where it takes in an attribute, and splits the geometry in batches where the attribute matches. So all copynum of value 0 will be in one batch, value 1 in the next batch, and so on.
All the nodes contained within the for each will be cooked as many times as there are batches (iterations).

NOTE
Luckily, the copynum attribute is on the primitives. If it was on the points, you would have lost the primitives inside the for each. As a workaround, you'd have had to promote copynum from points to primitives.
Not applicable here, but a good thing to know.

Then, since we have "multiple geometries" (thanks to the different batches), the nodes in the for each loop will cook once for each of these batches, allowing to change any parameters as we see fit between each iterations.

We have two choices here.
1. Use the copynum attribute. This will work because we KNOW it is different for each iteration, and the parameter will pick up a different value on each iteration.
2. Use the iteration number. The for each loop keeps track of which iteration it is on, and we can refer to it.

There's not really a better solution, use what you like.
You can even make your own attribute as a seed, to be able to tweak it to your liking, if you need.

For 1), you'll want to use the prim() expression. It requires the geometry to look into (0 being the connected input), which primitive to fetch the attribute (since the attributes often differs and because the parameters can only have one value, we have to choose which one to take. In our case, the value is the same on all primitives WITHIN THE LOOP, so we can take the first primitive, 0), which attribute to fetch (copynum), and which index to fetch (for vectors and arrays, for integers and floats just use 0).

For 2), you'll want to use the detail() expression. Specify which geometry to fetch the attribute from (foreach_begin1_metadata1 is the node which stores the iteration value), which attribute to fetch (iteration), and again which index (it's an integer, so we just specify 0).

image.thumb.png.73226051309d96504495dfdc77a6e4ea.png

change_sort_seed_for_each_copy_solution_1.hipnc

Edited by Alain2131
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...