Add & Delete Presets
Input the VEX to be saved as a preset and navigate to the gear icon at top right corner of Properties panel and select Save Preset... This will prompt to save the preset with a name and to a specified location.
To delete presets, follow the same path as noted above and select Delete Preset... which will prompt to identify the preset to delete.
Once saved, the preset can be recalled from other wrangles in current project or other projects based on where the preset is saved to. For more information about saving locations, reference link below.
Custom presets are being saved to the specified location.
The following outlines the steps for generating ramp parameters within a Wrangle.
Access Attributes Via Operator Inputs
prim(), and the like,
@opinput provides an alternative way to access input stream attributes.
Round To Even Integer
Normalized Values Between -1 & 1 Range
In instances where normalized values need to be mapped, or fit, between -1 and 1 range, the following are some methods that can be utilized.
A case in which the above methods can be of value is using the returned values from a rand() operation, which are between 0 and 1, to specify a range of random values between -1 and 1, as shown in the video below.
Define time-dependent cycle operation.
Clamp time-dependent cycle operation separated by user-defined clamp length.
Clamp time-dependent cycle operation to positive values and separated by user-defined clamp length.
Data Type Operations
Data Type Specification
When an attribute's data type is first specified in a Wrangle, such as the following string array:
subsequent references to
@test will read the same without having to specify the data type again.
Data Type Conversions
array() can be used to initialize dynamic variable values. Curly braces are used to initialize static values.
The following images display the corresponding return values for each Wrangle.
Point Iteration via Detail Wrangle
While the Resample SOP can assign the @curveu attribute, this same operation can be applied through VEX.
Connect Near Points
Optimized Scatter Points
Optimized scatter points generation within defined bounds using VEX; alternative to
Map Point Attribute To Local Variable
Create and map a point attribute to a local variable in Houdini, as an alternative to using the
Attribute Create SOP. This is particularly useful in linking template point attributes to copy instances via the
Copy Stamp SOP.
Pad Number In Fracture Name
Delete Primitives By Point Count
Carve Functionality In VEX
The groom library is located in the Houdini install location
$HFS\houdini\vex\include\groom.h and includes the following function that can be configured to replicate the actions of the Carve SOP.
#include <groom.h> adjustPrimLength(const int geo, prim; const float currentlength, targetlength)
Comparing the Carve SOP with a Prim Wrangle utilizing the above VEX snippet shows a significant difference in performance.
Group Naming Syntax
Flow Control Operations
Inline & Ternary If Statement
Variations in formatting simple inline if statements in Houdini Vex. Complex conditionals should utilize base formatting for clarity.
Switch/Case Statement Alternative
The Base Setup above outputs the following for the 4 points in the
Geo Spreadsheet. Note that Point 3 has an
@test of 1, which ran through the 2nd condition, but then was overwritten by the 3rd condition.
However, the Switch/Case Alternative below used the
prev_executed variable to serve as the 'break' to exit the Wrangle. As a result, Point 3 in the
Geo Spreadsheet shows that it preserved the output (
CASE 1) from the 2nd condition and did not run through the 3rd condition.
Switch/Case Alt Setup
Switch/Case Alt Setup
Each of the following sections is a periodic exploration of a different Vex function and its application in Houdini. My aim is to use this daily routine to familiarize myself with the wide range of available functions.
relbbox() & relpointbbox()
The bounding box of the incoming geometry is redefined into a range from 0-1 and returns a value within that range for each prim or point in the geometry. As a result, it can then be passed into something like a channel ramp that accepts a normalized (to 0-1 range) value. Both of these function within either a point or primitive wrangle using the positions of the respective geometry elements to define the relative positions.
In this example, the color is driven by the relative position in the y-axis ranging from 0 (bottom of geo) to 1 (top of geo). The returned
@Cd values in the
Geo Spreadsheet show the range from 0-1.
The last condition was a quick check to verify that the returned values in either the
Point Wrangle and use of
relpointbbox() were equal.
This exploration of the function documents how voxel and VDB sizes are extracted with use of the
volumevoxeldiameter() function to show its relationship with the bounds and number of voxels.
The above Primitive Wrangle outputs the following to Primitive 0 in the
The returned values for the attributes assigned to Primitive 0 in the
Geo Spreadsheet are confirmed by the node information to the right. In particular, the number of voxels on each axis align with the size of the
@surface VDB and
@voxel_len matches the Voxel Size
In the video below, the small green box is the individual voxel relative to the bounding box of the VDB. It is sized to the
@voxel_len attribute calculated from the
volumevoxeldiamter() and the VDB bounds.
This first example is documentation of using the
volumesample() Vex function to analyze voxel information from a VDB converted to a volume. Each voxel is then represented by a point with color attributes aligning with their corresponding volume sample values.
The output of the above
Primitive Wrangle in the
Geo Spreadsheet shows the volume resolution with use of
The size of each voxel is transferred to each point's
@pscale so that the
Box passed into the
Copy To Points are sized to represent the voxels.
The video below showcases the voxel's sample values extracted from the
volumesample(). Voxel size and bands are adjusted to showcase visual impact of sample voxel values.
This next example is a variation of the above process that retains the original VDB as a VDB and then is processed through a similar script. Part of the variation is the removal of point representations based on the volume sample values.
The following is the corresponding output from the above
Primitive Wrangle which attributes the volume resolution with
volumeres() and volume origin with
volumeindexorigin(), which specifically identifies the bottom left corner of the VDB's active bounds.
This video demonstrates the VDB's voxel size and bands being adjusted to showcase visual impact of sample voxel values. The original geometry's material is transferred to
@Cd for each voxel representation.
rotate() function applies a defined angle amount rotation around a specified axis. An identity matrix stores the rotation transformation and is then passed into the
rotate() along with the angle (in radians) and the axis. In this example, a sequence of rotations are applied; first around the
@up axis and then the
@N axis. Each of the angle amounts are driven by channel parameters for user-control.
Operating the channel parameters drives the angles in the use of the
rotate() function. Of particular note is the sequence of rotations as they are each applied. Rotating around the
@N axis first followed by rotating around the
@up axis aligns each to the updated axes. However, when the rotation is first applied around the
@up axis, rotation around the
@N axis is around the original state of the
@N axis and not the updated
@N axis following the rotation around the
rotate() function's variation with the
xyz rotation order argument results in the same rotation operation and controls as in the vector-defined function above.
This function is applied to array data structures.
Detail intrinsics can be accessed in the detail section of the Geo Spreadsheet and coordinated with VEX for applications such as identifying the groups available in the geo stream and specific to each geometry element, such as points or primitives.
Directory where current Houdini scene file is located.
Directory where current Houdini project is located.
Scene File Name w/out Extension
Does not include file extension, $HIPFILE does.
Directory where current Houdini version directory is located, in which .env file is located.
Number of Points
Total number of points in current geometry.
Current # of Copy Instance
Total # of Copy Instances
Fractional (Sub) Frames
Applicable for precision, such as motion blur.
Frames Per Second
Set in the
Current simulation time.
Current simulation timestep number as applicable in dynamic simulations. $SF = $ST / $TIMESTEP
Simulation Timestep Size
Current time in seconds.
Normal vector of the element.
Color diffuse using RGB values for the vector.
Position of element.
Non-uniform scale with each float representing each axis: x, y, z.
Uniform scale of element.
Orientation of the element. This takes precedence over @N if both @N and @orient exist in element. But if @orient does not exist in element, then @N defines its orientation along Z-axis. Since @N is simply a vector and @orient is a quaternion, then @orient has greater precision, and therefore precedence.
Can be calculated via
Unique value identifying an element, such as a particle. Even after it dies, another element or particle will not acquire that id value.
Denotes the time that the particle has been in existence since spawning, or being born, from its origin. Value is in seconds and typ. noted as fractions per the frame rate.
Number of seconds that the particles are expected to live. Defined in the POP Source.
An attribute to mark particles that have @age > @life.
Age / Life
Unlike @age, which is just a recording of time that the particle has been alive, @nage is a percentage of how long it has been alive relative to its @life. It is an implicit value denoting @age / @life.
Variables & Attributes Resources
On This Page
- User Interface
- Add & Delete Presets
- Channel Ramps
- Access Attributes Via Operator Inputs
- Math Operations
- Round To Even Integer
- Normalized Values Between -1 & 1 Range
- Clamped Cycle
- Alligator Noise
- Data Type Operations
- Data Type Specification
- Data Type Conversions
- Format String
- Variable Values
- Array Operations
- Point Operations
- Point Iteration via Detail Wrangle
- @curveu Attribute
- Connect Near Points
- Optimized Scatter Points
- Map Point Attribute To Local Variable
- Primitive Operations
- Pad Number In Fracture Name
- Delete Primitives By Point Count
- Carve Functionality In VEX
- Group Operations
- Group Naming Syntax
- Flow Control Operations
- Inline & Ternary If Statement
- Break Statement
- Switch/Case Statement Alternative
- relbbox() & relpointbbox()
- VEX Resources
- Global Variables
- Variables & Attributes Resources