Stanislav Yakymenko
Berlin-based digital artist

Houdini VEX Snippets

Handy collection of Houdini VEX fragments

HOUDINI VEX SNIPPETS

 
 

Handy collection of Houdini VEX fragments I have found online and snippets created by myself.

points_box1


// creates box with points using vex
// run over numbers
// create spare parameters
addpoint(0, fit01(rand(@elemnum), chv('min'), chv('max')));

 

rand_removepoint1


// removes random point with certain probability 
// create spare parameters
float prob = chf('probability');
float seed = chf('seed');
float u = rand(set(@elemnum%65535, @elemnum/65535, seed));
@group_pgroup1 = prob > u;
if(@group_pgroup1)
removepoint(geoself(),@ptnum);

 

normal_orient1

@N = set(0, -1, 0);

 

Replace a prim with a point:
Source


prim_to_point_replace1


// with point normals
// run over primitives
int newpoint = addpoint(0, @P);
setpointattrib(0, “N”, newpoint, @N);
@up = set(0, 0, 1); 
removeprim(0, @primnum, 1);


prim_to_point_replace2


// run over primitives
addpoint(0, @P);
removepoint(0, @primnum, 1);

 

normal_orient1

@N = set(0, -1, 0);

 

Parabola formula to create wires:
Extra info | Source


parabolic_tension1


// minimum 3 points is required
// create spare parameters
float ptn = @ptnum;
float npt = @numpt;
float curvu = ptn/(npt-1);
float paraby = 1-(pow((2*curvu-1),2));
@P.y -= paraby*ch("tension");

 

connect_points1
Source


// run over detail
// create spare parameters
int num = npoints(geoself());
int vtx_limit = num-1; //We dont want to add an extra vertex to the last point
for(int i=0;i<vtx_limit;i++)
{
int prim = addprim(0,"polyline");
addvertex(0,prim,i);
addvertex(0,prim,i+1);
}

 

procedural_subdivision_lines1
Source


// connect equal amount of points to inputs 0 and 1
// works best along X-axis
// create spare parameters
// add Resample SOP after
float o = chf("Offset");
float rando = fit01(rand(@ptnum + chi("Seed")), -o, o) * chf("Random_Offset_Amp");
o += rando;
float s = chf("Curve_Softness");
vector npos = point(1, "P", @ptnum);
vector pos = v@P;
vector d = npos - pos;
vector p2 = pos + set(clamp((o - s*o), 0, 1) * d.x, 0, 0);
vector p3 = pos + set(o * d.x, 0, d.z * (1.0 - s));
vector p4 = pos + set(clamp((o + s*o), 0, 1) * d.x, d.y, d.z);
int npt2 = addpoint(0, p2);
int npt3 = addpoint(0, p3);
int npt4 = addpoint(0, p4);
int npt5 = addpoint(0, npos);
int newprim = addprim(0, "polyline", @ptnum, npt2, npt3, npt4);
addvertex(0, newprim, npt5);