TA logoThe Technical Artist
Home/Field Notes/VEX Quick Reference
cheat sheet
printable
pocket vex

VEX Quick Reference

reference~3 min readreviewed 2026-07-05

The one-pager: bindings, syntax, and the functions that carry daily wrangle work. When you need the long version, the 950-snippet library is one search away.

Attribute Bindings - The @ Zoo

BindingMeaning
@P @N @Cd @uvposition - normal - color - uv (known types, auto-cast)
@ptnum / @numptthis point's index / point count
@primnum / @numprimsame, for primitives
@Frame @Timecurrent frame / seconds
f@mask v@dir i@id s@namedeclare your own: float, vector, int, string
v@opinput1_Pread attr from input 1 at same index
Gotcha: undeclared custom attrs default to float - @mask works, @dir without v silently truncates to one float. Declare types.

The Run-Over Rule

A wrangle runs your code once per element (point/prim/vertex) - or once total in Detail mode.
Read any point, write only yourself - writes to other elements need setpointattrib() (applied after the pass) or a Detail wrangle.
Same model as pixel shaders: no loops over the whole mesh, no ordering guarantees. Parallel by default is why it's fast.

Geometry Lookups - The Big Four

FunctionGives you
nearpoint(1, @P)closest point number on input 1
xyzdist(1, @P, prim, uv)distance to a surface + where (prim,uv)
primuv(1, "attr", prim, uv)read any attr at that surface spot
intersect(1, org, dir, p, u, v)raycast; -1 = miss
The transfer/snap/raycast trinity: xyzdist finds where, primuv reads what's there. Half the library builds on these.

Create & Destroy

int pt = addpoint(0, pos);
addprim(0, "polyline", a, b);
setpointattrib(0, "Cd", pt, {1,0,0});
removepoint(0, @ptnum); - delete self (the code form of a delete-by-expression)
Gotcha: geometry created in a wrangle appears after the pass; you can't read it in the same wrangle.

Noise & Randomness

rand(@ptnum) - 0-1, stable per point (add a seed: rand(@ptnum + ch("seed")))
noise(@P * freq) - value noise, ~0-1, blobby
curlnoise(@P) - divergence-free vector - instant swirl
fit(noise(@P*f), 0.3, 0.7, 0, 1) - the contrast trick: raw noise huddles mid-range; fit stretches it

Everyday Toolkit

fit(v, 0,1, a,b) - clamp - lerp - the math sheet family, VEX spelling
ch("name") - makes a UI slider (click the button to create it) - art-directability in one call
chramp("r", x) - a whole artist-editable curve as a function
sprintf("piece_%03d", i) - naming with padding
if (@P.y < ch("cut")) removepoint(0, @ptnum); - the idiom to memorize

Groups In Wrangles

i@group_top = @N.y > 0.7; - create/assign by rule
Run a wrangle over a group: the Group field on the node - cheaper than an if around everything
inpointgroup(0, "top", @ptnum) - membership test in code

Classic Gotchas

Integer division: 1/2 == 0 - write 1.0/2
@N doesn't exist unless something created it - Normal SOP first, or @N = normalize(@P - centroid)-style yourself
String compare is == (fine!), but attribute names are case-sensitive: @cd != @Cd
Point wrangle can't change point count reads mid-pass - see create & destroy card
Degrees vs radians: VEX trig is radians - radians(ch("angle")) for slider-friendly degrees

Learning rather than referencing? Start with the VEX guide, then search the library as problems arise - it's organized for exactly that motion.