noob: rand($PT*50)

   5447   3   0
User Avatar
Member
20 posts
Joined: 5月 2016
Offline
I'm trying to understand the rand.
What exactly is the $PT (and where to find a list of the different variables)
I created a random color node. Values like rand($PT) * 50 didn't work but rand($PT * 50) did?
Thanks and I'm sorry if a tutorial explains this. Haven't seen it?
User Avatar
Member
333 posts
Joined: 10月 2012
Offline
rand() will give you a number between 0-1 so if you do (@ptnum *50) that will still be mapped to 0-1 adn the multiplier becomes like a seed. If you do (@ptnum) *50 that will multiply a random number between 0-1 by 50 therfor you will get values over 1 resulting in showing up white in the viewport.

you can use fit01 to range the random value you get between higher values.

fe: fit01(rand(@ptnum+12), 0, 10) which gives an output between 0-10

hope it helps.

edited to match @ptnum
Edited by Doudini - 2016年5月25日 13:44:21
User Avatar
Member
39 posts
Joined: 7月 2013
Offline
$PT is the global variable for point number. Expressions seem to be switching over to vex terminology which for point number is @ptnum.

I can't seem to find a comprehensive list of the variables, i'll update if I find them
User Avatar
Member
181 posts
Joined: 2月 2013
Offline
Sean Rowe
I can't seem to find a comprehensive list of the variables, i'll update if I find them
I thought something similar had been on Erwin Santacruz's Houdini Tricks [houdinitricks.com] site once, but only see an introduction to the concept:

http://houdinitricks.com/quicktip-new-attribute-syntax-in-houdini-15/ [houdinitricks.com]

$BBX	relbbox(@P).x
$BBY relbbox(@P).y
$BBZ relbbox(@p).z
$T @Time
$FF @Frame
$ST @SimTime
$SF @SimFrame
1/$FPS @TimeInc

From the internal help:

Geometry attributes

In HScript expressions on geometry you can reference the value of an attribute using `@attributename`. For example, you can use `@pscale` to get the value of the `pscale` (point scale) attribute on the current point.

For vector attributes such as `P` (position), you can use dot notation to grab a component, for example `@P.x`. You can use `.x/.y/.z` or `.1/.2/.3` or `.r/.g/.b`, whichever makes sense for the type of data.

Local variables

Nodes often provide variables that are useful for expressions on nodes of that type. For example, a node that operates over the points in a geometry will have a `@ptnum` variable representing the point number of the current point. The help for a node will list the local variables you can use in expressions on that type of node.
  • Quick Links