Its a circus out there


Expressions & Functions

Home VOPs SOPs DOPs COPs POPs ROPs Expressions OSTips Shops Tools Lighting Python Pclouds HOT About

Bio Showreel GalleryHoudini.htmlVops.htmlSops.htmlDopsMain.htmlCops.htmlBlank.htmlRops.htmlOSTips.htmlShops.htmlTools.htmlLighting.htmlPython.htmlPointClouds.htmlHotOceanTookkit.htmlAbout.htmlBio.htmlShowreel.htmlGallery.htmlHoudini.htmlshapeimage_1_link_0shapeimage_1_link_1shapeimage_1_link_2shapeimage_1_link_3shapeimage_1_link_4shapeimage_1_link_5shapeimage_1_link_6shapeimage_1_link_7shapeimage_1_link_8shapeimage_1_link_9shapeimage_1_link_10shapeimage_1_link_11shapeimage_1_link_12shapeimage_1_link_13shapeimage_1_link_14shapeimage_1_link_15shapeimage_1_link_16shapeimage_1_link_17shapeimage_1_link_18

A function is an operator that does something ie abs() or rand() are functions. You feed them in a value and the spit something out

An expression is a collection of tokens that may include a function call and which also return something $F + 2 is an expression rand($F +2 ) aswell. In the context of a Houdini parameter expressions and functions are very related.

Wise words from Andrew

Example1:- Use the point function to create an attribute

point("../paint1", $PT,"Cd",0) .The expression returns the red component of the point in the sop paint1

Example2:- Use the pointlist function to read the number of points in a group

argc(pointlist("../OUT","my_group")) .The expression returns the number of points contained in my_group. argc  is the argument count ie how many items in “ a b c d “

Example3:- Use the primgroupmask

argc(primgroupmask("../OUT","my_group_* ")) .The expression returns the number of groups that match my_group_*

Pulse:- pulse (float value, float start, float end)

pulse($FF % 100 , 0 ,24 ) This expression entered in the particle birthing, impulse birthing parameter causes particles to be pulsed out. Its also using the modulus function to achieve this . So every 100 frames 24 particles are birthed at all other times none are birthed.

Modulus:- The symbol for modulus is % . Find below a selection of examples of this function and how it can be used.

Example 2 :- Using  if($FF % 100 == 1 , 100 , 0 )  in the particle location impulse birth rate , will give you a 100 particles bursting out every  100 frames.

Example 3 :- Using  if($PT % 2 == 0, -1 ,1 )*((rand($PT)*360)+9.3*($FF))   in the stamping section of the copy sop .The modulus part of the expression is looking at the point number $PT of the copy SOP if the number is even the teapot will rotate clockwise “ 1 “  if the point number is odd it will rotate anti clockwise  “-1 “

opname :- (string name)

Example 1 :-  `chs(“../../archievectrl/basedir”) ` / `opname(“..”)`.bgeo    .This example will read the the geometry nodes name and then write it out as part of the path for the delayed load SOP.

rand() :-  float rand (float value)

Make a random selection of 50 points from a group of 1000 ,  type rand($PT) <= (50/1000)

Clamp() :- float clamp (float value, float minimum, float maximum)

The points on a line. This shows visually what clamp is doing.

Point sop TY value   $TY + fit((clamp($BBZ,0.3,0.7)),0 , 1 , -10, 10)

Hip file :- rse_sops_changerangeclamp.hip

round() :-  Rounds a number to the nearest integer.

Round up a number to a specific decimal place  padzero(round(<your var>), 2)

Read a sequence of geometry inversed ....


The timewarp sop will do it for you too (input range: 1st frame, last frame,

output range: last frame, 1st frame)

point() :-

Example 1

Smart partitioning the point attribute used to read the data from the input node , normally the connectivity sop and then creating point groups from it.   group_`point(“../” +opinput(“.”,0),$PT , “class”,0)`

Delete SOP :-

Example 1

Picked up this trick :- Pops when you output pops they come with the $LIFE attribute still activated , very very handy. For birthing other particles or killing the particles you have without a re-sim

$LIFE >= rand($PT +7) ^2 &&  $F <= fit01(rand($PT+7), 88 , 99 )

particle life > random point > Power function. Life measured in zero to one , so using a power function the value of lparticles life is pushed into the higher values , ie more points later in life will have the expression act on them.  && > conditional statement  == ie if first value true then evaluate second value . Then use a rand function to pick a frame range for the particle to have the expression act on them. in this case die.

point() :-

Example 2

Smart node connection :-

you can use the point expression in the transforms of a geometry level sop to extract the world space coordinates of a point , normally that would look like this . point(“../myObjectlevelnodename/mysop”, 0 ,”P” , 0)  Great eh but what happens if you want to automate it with that handy expression opinputpath() . To get the name of the node being plugged in ? If you put opinputpath inside the  point(“”) string it will not evaluate as the expression opinputpath() is not a string.

So we instead set up the expression like this point(opinputpath(“.”,0)+ “/mysop”,0,”P”,0)   another neat trick is to read a param using

smart plugging to read a name in a string `chs(opinputpath(“.”,0) + “/mysop_parameter”)`



Make a simple time code

Drop a font sop and add an expression like this to get a counting time code where $F is the frame `int($F/60)`:`int($F/6)`:$F