Expression Functions
Reference chart for Houdini expression functions
Overview
Houdini expression functions are used in parameter fields, channel expressions, and geometry expressions. They provide math, geometry, random, and utility operations for procedural workflows.
Official Houdini Expression Functions Documentation
Expression Functions Chart
Name▲ | Code | Example | Description | Category |
---|---|---|---|---|
curvature | curvature(surface, u, v) | curvature(opinputpath(".",0), 0.5, 0.5) | Surface curvature at UV. | Geometry |
deg | deg(x) | deg($PI) → 180 | Alias for degrees(x). | Math |
degrees | degrees(x) | degrees($PI) → 180 | Converts radians to degrees. | Math |
detail | detail(surface, attrib, index) | detail(0, "density", 0) | Value of a detail attribute. | Geometry |
details | details(surface, attrib) | details(0, "path") | String value of a detail attribute. | Geometry |
determinant | determinant(matrix) | determinant(identity()) → 1 | Determinant of matrix. | Matrix |
dihedral | dihedral(v0, v1) | dihedral({0,1,0},{0,0,1}) | Dihedral rotation matrix aligning v0 to v1. | Matrix/Math |
distance | distance(p1, p2) | distance({0,0,0},{1,1,1}) → 1.732 | Distance between two 3D points. | Vector/Math |
dopfield | dopfield(object, data, subdata, record, field, index) | dopfield("..:object","..:data","..","..","vel",0) | Value of a DOP field (float). | DOP |
dopfields | dopfields(object, data, subdata, record, field, index) | dopfields("..","..","..","..","name",0) | Value of a DOP field (string). | DOP |
dopframe | dopframe() | dopframe() | Current simulation frame (DOPs). | DOP |
doptime | doptime() | doptime() | Current simulation time (DOPs). | DOP |
doptransform | doptransform(object, data, subdata, record) | doptransform("..","..","..","..") | Transformation matrix for DOP data. | DOP |
dot | dot(a, b) | dot({1,0,0}, {0,1,0}) → 0 | Dot product of two vectors. | Vector/Math |
edgegrouplist | edgegrouplist(surface) | edgegrouplist(0) | List of edge groups in SOP. | Geometry |
edgegroupmask | edgegroupmask(surface, pattern) | edgegroupmask(0, "seam*") | Edge groups matching pattern. | Geometry |
exp | exp(x) | exp(1) → 2.718 | e raised to x. | Math |
fit | fit(x, oldmin, oldmax, newmin, newmax) | fit(0.5, 0, 1, 10, 20) → 15 | Remaps x from one range to another. | Math |
fit01 | fit01(x, newmin, newmax) | fit01(0.25, 10, 20) → 12.5 | Maps x∈[0,1] to [newmin, newmax]. | Math |
fit10 | fit10(x) | fit10(0.2) → 0.2 | Maps x to [0,1] (clamped/normalized). | Math |
fit11 | fit11(x) | fit11(0.5) → 0.0 | Maps x to [-1,1]. | Math |
floor | floor(x) | floor(2.7) → 2 | Largest integer ≤ x. | Math |
fpadzero | fpadzero(width, number) | fpadzero(5, 3.2) → "03.2" | Zero-pad with float handling. | String |
frac | frac(x) | frac(2.7) → 0.7 | Fractional part of x. | Math |
ftoa | ftoa(x) | ftoa(3.14) → "3.14" | Number to string. | String |
ftrim | ftrim(x, digits) | ftrim(3.14159, 3) → "3.142" | Format float string with rounding. | String |
groupbyval | groupbyval(surface, class, attrib, value) | groupbyval(0, "point", "id", 3) | Set of elements with a given integer attribute value. | Geometry |
groupbyvals | groupbyvals(surface, class, attrib, value) | groupbyvals(0, "prim", "name", "wall") | Set by string attribute value. | Geometry |
hasdetailattrib | hasdetailattrib(surface, attrib) | hasdetailattrib(0, "class") | Returns 1 if detail attribute exists. | Geometry |
haspoint | haspoint(surface, group, ptnum) | haspoint(0, "sel", 12) | Returns 1 if point is in group. | Geometry |
haspointattrib | haspointattrib(surface, attrib) | haspointattrib(0, "Cd") | Returns 1 if point attribute exists. | Geometry |
hasprim | hasprim(surface, group, primnum) | hasprim(0, "sel", 7) | Returns 1 if prim is in group. | Geometry |
hasprimattrib | hasprimattrib(surface, attrib) | hasprimattrib(0, "name") | Returns 1 if prim attribute exists. | Geometry |
hasvertexattrib | hasvertexattrib(surface, attrib) | hasvertexattrib(0, "uv") | Returns 1 if vertex attribute exists. | Geometry |
hextoint | hextoint(hex) | hextoint("FF") → 255 | Hex string → integer. | String |
hsv | hsv(r, g, b) | hsv(1, 0.5, 0.5) | RGB → HSV components. | Color |
identity | identity() | identity() → 4×4 I | Identity matrix. | Matrix |
index | index(string, pattern) | index("abcabc","ab") → 0 | First occurrence of pattern in string. | String |
instancepoint | instancepoint() | instancepoint() | Point number currently being instanced onto. | Instancing |
int | int(x) | int(2.9) → 2 | Truncates x to integer. | Math |
inttohex | inttohex(i) | inttohex(255) → "FF" | Integer → hex string. | String |
invert | invert(matrix) | invert(identity()) → identity() | Inverts a matrix. | Matrix |
length | length(v) | length({3,4,0}) → 5 | Length (magnitude) of vector v. | Vector/Math |
listbyval | listbyval(surface, class, attrib, value) | listbyval(0, "prim", "class", 2) | List elements with given integer attribute value. | Geometry |
listbyvals | listbyvals(surface, class, attrib, value) | listbyvals(0, "point", "name", "pt*") | List by string attribute value. | Geometry |
lock | lock(value) | lock(ch("tx")) | Value that cannot be changed by further evaluation. | Channel |
log | log(x) | log(1) → 0 | Natural logarithm of x. | Math |
log10 | log10(x) | log10(100) → 2 | Base-10 logarithm of x. | Math |
loplastmodifiedprim | loplastmodifiedprim() | loplastmodifiedprim() | Path of USD prim last modified by node. | LOP/USD |
lopparentprims | lopparentprims(prims) | lopparentprims("/root/*") | Parent paths of USD prims. | LOP/USD |
ltrim | ltrim(string) | ltrim(" hi") → "hi" | Trim whitespace at start. | String |
match | match(pattern, string) | match("foo*","foobar") → 1 | Glob-style match test. | String |
matrix | matrix(spec) | matrix("1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1") | Create matrix from string. | Matrix |
matrixtoquat | matrixtoquat(m) | matrixtoquat(identity()) | Rotation matrix → quaternion. | Matrix |
max | max(a, b) | max(3,5) → 5 | Larger of a, b. | Math |
min | min(a, b) | min(3,5) → 3 | Smaller of a, b. | Math |
mlookat | mlookat(from, to) | mlookat({0,0,0}, {0,0,-1}) | Look-at transform matrix (Z forward). | Matrix |
mlookatup | mlookatup(from, to, up) | mlookatup({0,0,0},{0,0,-1},{0,1,0}) | Look-at with explicit up vector. | Matrix |
mobjlookat | mobjlookat(obj_from, obj_to) | mobjlookat("../cam1","../null1") | Object-to-object look-at matrix. | Matrix |
nearpoint | nearpoint(surface, x, y, z) | nearpoint(0, 0.1, 0.2, 0.3) | Nearest point to world position. | Geometry |
noise | noise(x, y, z) | noise(0.1,0.2,0.3) | 3D noise value. | Noise |
normalize | normalize(v) | normalize({2,0,0}) → {1,0,0} | Normalizes a vector. | Vector/Math |
npoints | npoints(surface) | npoints(0) | Number of points in geometry. | Geometry |
npointsgroup | npointsgroup(surface, groupname) | npointsgroup(0, "mygrp") | Number of points in group. | Geometry |
nprims | nprims(surface) | nprims(0) | Number of primitives in geometry. | Geometry |
nprimsgroup | nprimsgroup(surface, groupname) | nprimsgroup(0, "grps") | Number of prims in group. | Geometry |
nvertices | nvertices(surface) | nvertices(0) | Number of vertices in geometry. | Geometry |
nverticesgroup | nverticesgroup(surface, groupname) | nverticesgroup(0, "edgegrp") | Number of vertices in group. | Geometry |
oldrand | oldrand(seed) | oldrand(1) | Legacy random (0..1). | Random |
opdigits | opdigits(path) | opdigits("box3") → 3 | Numeric suffix of a node name. | OP/Node |
opexist | opexist(path) | opexist("../geo1") → 1/0 | 1 if node/group/bundle exists. | OP/Node |
opflag | opflag(flag, pattern) | opflag("display", "/obj/*") | List nodes with a flag set. | OP/Node |
opfullpath | opfullpath(path) | opfullpath("../geo1") → "/obj/geo1" | Absolute path of a node. | OP/Node |
opname | opname(path) | opname("../geo1") → "geo1" | Name of a node from its path. | OP/Node |
opnchildren | opnchildren(path) | opnchildren("/obj") | Number of nodes inside a container. | OP/Node |
opninputs | opninputs(path) | opninputs("../merge1") | Max number of connected inputs. | OP/Node |
opnodigits | opnodigits(path) | opnodigits("box3") → "box" | Alphanumeric prefix sans trailing digits. | OP/Node |
opnoutputs | opnoutputs(path) | opnoutputs("../switch1") | Number of connected outputs. | OP/Node |
oprelativepath | oprelativepath(from, to) | oprelativepath("../geo1","/obj") → "../.." | Relative path between nodes. | OP/Node |
opselect | opselect() | opselect() → list | Selected nodes (list). | OP/Node |
optransform | optransform(object_path) | optransform("../geo1") | Object transform matrix at current time. | Object/Xform |
optype | optype(path) | optype("../box1") → "box" | Type name of a node. | OP/Node |
optypeinfo | optypeinfo(path) | optypeinfo("../box1") | Type info about a node. | OP/Node |
origin | origin(object_path, space, type) | origin("../xform1", "D_WORLDSpace", D_ZROT) | Object transform components (origin/rotation/etc.). | Object/Xform |
originoffset | originoffset(object_path, space, type) | originoffset("../xform1", "D_WORLDSpace", D_ZROT) | Object offset transform components. | Object/Xform |
padzero | padzero(width, number) | padzero(4, 12) → "0012" | Zero-pad a number to width. | String |
pdgattrib | pdgattrib(name) | pdgattrib("workitemindex") | Value of a PDG work item attribute. | PDG/TOP |
pdginput | pdginput(index, tag) | pdginput(0, "file/geo") | Work item input file by index and tag. | PDG/TOP |
pdgoutput | pdgoutput(index, tag) | pdgoutput(0, "file/geo") | Work item output file by index and tag. | PDG/TOP |
pic | pic(cop, x, y, plane) | pic("/img/comp1/IN", 100,200, "C") | Interpolated pixel color from COP. | COP/Image |
picni | picni(cop, x, y, plane) | picni("/img/comp1/IN", 100,200, "C") | Non-interpolated pixel color from COP. | COP/Image |
pluralize | pluralize(noun) | pluralize("box") → "boxes" | English plural of a noun. | String |
point | point(surface, point_number, attrib, index) | point(0, 0, "P", 0) | Value of a point attribute. | Geometry |
pointdist | pointdist(surface, ptnum, prim, u, v, w) | pointdist(0, 0, 1, 0.5, 0.5, 0) | Distance from point to primitive. | Geometry |
pointgrouplist | pointgrouplist(surface) | pointgrouplist(0) | List of point groups in SOP. | Geometry |
pointgroupmask | pointgroupmask(surface, pattern) | pointgroupmask(0, "left*") | Group names matching pattern. | Geometry |
points | points(surface, point_number, attrib) | points(0, 0, "name") | String value of a point attribute. | Geometry |
pow | pow(x, y) | pow(2,3) → 8 | x raised to power y. | Math |
prim | prim(surface, prim_number, attrib, index) | prim(0, 0, "Cd", 0) | Value of a primitive attribute. | Geometry |
primbbox | bbox(surface, D_XMIN) | bbox("../geo1", D_YMAX) | Per-prim bbox via bbox() types. | Geometry |
primduv | primduv(surface, primnum, attrib, u, v, w) | primduv(0, 0, "P", 0.5, 0.5, 0) | Partial derivatives at UV on primitive. | Geometry |
primgrouplist | primgrouplist(surface) | primgrouplist(0) | List of primitive groups in SOP. | Geometry |
primgroupmask | primgroupmask(surface, pattern) | primgroupmask(0, "roof*") | Primitive groups matching pattern. | Geometry |
prims | prims(surface, prim_number, attrib) | prims(0, 0, "name") | String value of a primitive attribute. | Geometry |
primuv | primuv(surface, primnum, attrib, u, v, w, comp) | primuv(0, 0, "P", 0.5, 0.5, 0, 0) | Attribute value at UV/UVW on primitive. | Geometry |
pulse | pulse(x, start, end) | pulse($F, 10, 20) → 1 on frames 10–20 | 1 when x is within range [start, end], else 0. | Utility |
quattomatrix | quattomatrix(q) | quattomatrix({0,0,0,1}) | Quaternion → 3×3 rotation matrix. | Matrix |
rad | rad(x) | rad(180) → $PI | Converts degrees to radians. | Math |
rand | rand(seed) | rand(123) → 0..1 | Pseudo-random number 0..1. | Random |
res | res(cop) | res("/img/comp1/IN") → 1920 1080 | Natural resolution of COP image. | COP/Image |
rgb | rgb(h, s, v) | rgb(0.0, 1.0, 1.0) | HSV → RGB components. | Color |
rindex | rindex(string, pattern) | rindex("abcabc","ab") → 3 | Last occurrence of pattern in string. | String |
rint | rint(x) | rint(2.5) → 3 | Rounds x to nearest integer. | Math |
rotate | rotate(angle, axis) | rotate(90, {0,1,0}) | 4×4 rotation matrix from angle+axis. | Matrix |
rotaxis | rotaxis(angle, axis) | rotaxis(45, {1,0,0}) | 4×4 rotation from axis-angle. | Matrix |
round | round(x) | round(2.4) → 2 | Rounds x to nearest integer. | Math |
rtrim | rtrim(string) | rtrim("hi ") → "hi" | Trim whitespace at end. | String |
sin | sin(x) | sin(0) → 0 | Sine of x (radians). | Math |
sinh | sinh(x) | sinh(0) → 0 | Hyperbolic sine of x. | Math |
sqrt | sqrt(x) | sqrt(9) → 3 | Square root of x. | Math |
tan | tan(x) | tan(0) → 0 | Tangent of x (radians). | Math |