Jump to content
Sign in to follow this  
Fyre

Random switcher inside for each loop

Recommended Posts

I'm trying to make a random switch inside a for each loop to assign one of four different noises to the primitive in the current loop.

I cant access $PR from inside the for each loop as its just looking at one primitive at a time, how can I get each loop to choose a random node?

If it helps the objects are in separate primitive groups before the for each loop.

 

Cheers

Edited by Fyre

Share this post


Link to post
Share on other sites

you can use the stamp() expression of this, for example: round(rand(stamp("../","FORIDXVALUE",0))*3)

Edited by acey195
fixed typo
  • Like 1

Share this post


Link to post
Share on other sites

Stamp really does not show a performance penalty until you are over a few thousand points. So it is still quite valid on lower point count geo. And even if you have a 60,000+ point object you can still leverage stamp() and just write out the result after the stamp operation. Place a FileCache node after your massive stamp operation to recover performance.

Share this post


Link to post
Share on other sites

this was also a post of 2 years ago :P, a lot of us (including me) have already moved on to the new compilable-new-foreach-structure

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
Sign in to follow this  

×