Random delete points by threshold

   16605   7   0
User Avatar
Member
235 posts
Joined: June 2006
Offline
why this will not work:

a scatter sop and a pointwrangle with:

if ( rand(@ptnum) > ch('threshold') ) {
removepoint(0,@ptnum);
}



Hm, still dont see points, neither with a low nor a high threshold value.

Attachments:
deforming_active.hip (232.1 KB)

User Avatar
Member
83 posts
Joined: Nov. 2018
Offline
Hey, just had a look at your wrangle node & got it to work! Added backticks to the ch() command and changed your ‘Export Parameters’ back to the default ‘*’ value.

Also, remember that rand() only produces floats in range of 0-1, so need a lower threshold. Let me know if that fixes it …

Dan
Dan Warder
Senior FX TD - Framestore
User Avatar
Staff
5647 posts
Joined: July 2005
Offline
I'd recommend not using `` on the ch() expression as that will generate a new VEX code snippet everytime the threshold changes. Which could get expensive for recompiling!

The reason the ch('threshold') does not work is because the Bindings::Evaluation Node Path was set to ../scatter1. This meant it tried to read the parameter ch(“../scatter1/threshold”). And the scatter sop doesn't have that parameter, so it is returning 0. This results in all the points being deleted.

Changing the Evaluation Node Path to the default “.” and making the threshold 0..1 should thus also fix this.
User Avatar
Member
235 posts
Joined: June 2006
Offline
Thanks a lot to you both.

Cheers
User Avatar
Member
127 posts
Joined: Nov. 2018
Offline
Can someone explain to me why does this work?
I just started learning VEX and i want to understand this the correct way:

The rand function adds 0 or 1 to all the points? Why can't i see that in the spreadsheet so i can maybe know which points are being deletet?
User Avatar
Member
1898 posts
Joined: Sept. 2015
Offline
The rand function adds 0 or 1 to all the points? Why can't i see that in the spreadsheet so i can maybe know which points are being deletet?

Could you clarify your question?

Are you referring to the ops' hip file. Note that they are making use of the wrangles evaluation path. And as the hip stands(it's an old post and I just opened it as is)…they don't have a parameter of the name ‘threshold’. So the default value used in the expression is 0.

Since rand returns values between 0-1 all conditions of the if statement return true, so all points get deleted. (pointwrangle4 with display flag enabled).
Edited by BabaJ - Sept. 27, 2019 09:15:28
User Avatar
Member
18 posts
Joined: Feb. 2018
Offline
Follyx
why this will not work:

a scatter sop and a pointwrangle with:

if ( rand(@ptnum) > ch('threshold') ) {
removepoint(0,@ptnum);
}



Hm, still dont see points, neither with a low nor a high threshold value.

chf not ch
User Avatar
Member
3683 posts
Joined: Feb. 2012
Offline
ch will also work, I use it all the time but never chf personally:

https://www.sidefx.com/docs/houdini/vex/functions/chf.html [www.sidefx.com]
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

patreon.com/animatrix | vimeo.com/animatrix3d
  • Quick Links