Foreach node and variable increment

   4069   2   1
User Avatar
Member
7 posts
Joined: May 2015
Offline
Hello,
I am struggling to make a proper randomization. I followed the procedural library tutorial, which ends up having N lines primitives with X points which are used to spawn books.

A foreach loops through the primitives, and using $PT to create random values doesn't work, every point is unique to its own primitive so it will return the same value, ending up with the same randomization every primitive.

ex.


So I thought about creating a detail float attribute (FORVALUE) before the foreach.
Every loop in the foreach I use the attribrandomize to add 1.0 to it each loop, so I can use it in the copy node, in this way I would have a different FORVALUE attribute per primitive.
I access the FORVALUE attribute in the copy node using

rand(detail(“../attribrandomize1”, “FORVALUE”, 0))




But something seems not to be working, I guess why? It seems like it's creating just the same value and not adding to it. I tried to see it in the geometry spreadsheet, even if I use the single pass in foreach_end it doesn't change every loop.

Also, if you have a better way to do this, I thought also about using Y pos, wouldn't be so different from the FORVALUE solution tho.

Thanks
Edited by ginwakeup - Jan. 25, 2019 16:47:18

Attachments:
Capture.JPG (39.8 KB)
Capture2.JPG (32.5 KB)

User Avatar
Member
359 posts
Joined: April 2017
Offline
Use the “iteration” detail attribute that's accessible from the ForEach loop metadata. You could multiply this by some scalar (like 1000) and then add it to $PT.

To add the metadata node, just select the ForEach start node and click “Create Meta Import Node”. You can then pull the detail attribute “iteration” from this node and use it in your expressions.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
7 posts
Joined: May 2015
Offline
toadstorm
Use the “iteration” detail attribute that's accessible from the ForEach loop metadata. You could multiply this by some scalar (like 1000) and then add it to $PT.

To add the metadata node, just select the ForEach start node and click “Create Meta Import Node”. You can then pull the detail attribute “iteration” from this node and use it in your expressions.

That worked thank you very much.
  • Quick Links