| name | hou-vex |
| description | Write VEX code for Houdini SOPs, DOPs, COPs, and shaders. Use when creating geometry manipulation scripts, particle systems, procedural modeling, shaders, or working with .vfl files, wrangles, or VOPs in SideFX Houdini. |
Houdini VEX Programming
Write high-performance VEX code for geometry manipulation, simulation, and shading in Houdini.
Quick Start
Basic Point Wrangle pattern:
@P += @N * 0.1;
@Cd = normalize(@P);
Critical Concepts
- @ Syntax: Use
@ to access attributes (@P, @Cd, @N)
- Type Prefixes: Specify types with prefixes (
v@, i@, s@, f@)
- Context Matters: Code runs per-point, per-prim, or per-detail depending on wrangle type
- No Recursion: Functions are inlined by compiler
- Multi-threaded: Code runs in parallel automatically
Attribute Access
@P
@N
@Cd
@pscale
v@velocity
i@id
s@name
f@custom
Common Patterns
See examples/PATTERNS.md for ready-to-use code:
- Point manipulation
- Neighbor operations
- Group creation
- Attribute transfer
- Noise displacement
- Particle systems
VEX Contexts
Point Wrangle: Runs per-point (most common)
- Access:
@ptnum, @numpt
- Use: Deform, scatter, color
Primitive Wrangle: Runs per-primitive
- Access:
@primnum, @numprim
- Use: Primitive operations, extrusions
Detail Wrangle: Runs once for entire geometry
- Access: Detail attributes only
- Use: Global calculations, metadata
Vertex Wrangle: Runs per-vertex
- Access:
@vtxnum, @numvtx
- Use: UV manipulation, vertex colors
Essential Functions
int nearpoints(geometry; vector pos; float radius)
int neighbours(geometry; int ptnum)
vector point(geometry; string attr; int ptnum)
addpoint(geometry; vector pos)
removepoint(geometry; int ptnum)
setpointattrib(geometry; string name; int ptnum; value)
float noise(vector pos)
vector curlnoise(vector pos)
vnoise(vector pos)
normalize(vector)
distance(vector, vector)
dot(vector, vector)
cross(vector, vector)
Response Format
When providing VEX code, always include:
- VEX Code with comments explaining logic
- Wrangle Type (Point/Prim/Detail/Vertex)
- Required Inputs if any
- Expected Attributes that must exist
- Parameters to create if using
ch() functions
Common Functions
See reference/FUNCTIONS.md for complete API including:
- Geometry manipulation
- Attribute operations
- Math and vectors
- Noise and randomness
- Groups and selection
Best Practices
See reference/BEST-PRACTICES.md for:
- Performance optimization
- Memory efficiency
- Code organization
- Debugging strategies
Troubleshooting
See reference/TROUBLESHOOTING.md for solutions to:
- Type mismatch errors
- Attribute not found
- Performance issues
- Common syntax mistakes
Additional Resources
Key Differences from Other Languages
From Python:
- No recursion
- Strongly typed
- Runs per-element (parallel)
- Use @ for attributes, not variable names
From C/C++:
- Context-specific entry points
- No pointers
- Built-in vector/matrix types
- Automatic parallelization
From GLSL:
- Geometry manipulation focus
- Different attribute system
- More procedural modeling functions
- Different execution model