VEX Notes

Recently, I’ve been going over VEX in Houdini to become a bit more familiar with the language and I came across a few notes I found of interest. I’m documenting them here mainly so I can remember them myself. You can find these and much more in the Houdini Vex Language Reference.

Operators

  • VEX has the standard C operators with C precedence, with the following differences.
  • Multiplication is defined between two vectors or points. The multiplication performs an element by element multiplication (rather than a dot or cross product; see cross and dot).
  • Many operators are defined for non-scalar data types (i.e. a vector multiplied by a matrix will transform the vector by the matrix).
  • In ambiguous situations where you combine two different types with an operator, the result has the type of the second (right hand side) value, for example

Functions

  • The arguments to the context function, if any, become the user interface for the program, for example the parameters of a shading node that references the VEX program.
  • A VEX program must contain one function whose return type is the name of the context. This is the main function of the program that is called by mantra.
  • There is no limit on the number of user functions.
  • You can access global variables directly (unlike RenderMan Shading Language, you do not need to declare them with extern). However, we recommend you avoid accessing global variables, since this limits your function to only work in one context (where those globals exist). Instead, pass the global(s) to the function as parameters.
  • The functions are in-lined automatically by the compiler, so recursion will not work. To write a recursive algorithm, you should use shader calls instead.
  • The context affects which functions, statements, and global variables are available.
  • You can overload functions with the same name but different argument signatures and/or return type.

 

Reference: Sidefx.com

Share:
990adjustments

990adjustments

I am a motion designer & developer based out of South Florida. When not designing or animating pixels, I wrangle some code. If all else fails, I watch Twilight Zone, I Love Lucy, or Three's Company reruns.