Home News What’s new in Houdini 9 

What’s new in Houdini 9: VEX

Houdini 9 introduces new VEX features and improvements.

Varying strings

Strings can now vary across VEX processors.

This is more important for SOPs and POPs, but it allows for things like this:

sop
cmap()
{
string map = sprintf("map%d.pic", ptnum % 4);
Cd = colormap(map, P.x, P.y);
}

…to work. The fact that strings were uniform in Houdini 8 meant that the map name was the same for all points. In Houdini 9, it can be different.

Gather statement

The gather loop is available in shading contexts. The format of the construct is:

gather(vector origin, vector direction, ...)
{
// Statements for rays that hit other surfaces
}
else
{
// Statements for rays which miss all other surfaces
}

Illuminance message passing and simport

You can now send messages to light shaders through illuminance loops. This is done by setting keyword arguments in the options of the illuminance statement. Use simport to receive the passed values in light shaders.

surface
exporter()
{
vector nf = frontface(normalize(N), I);
Cf = 0;
illuminance(P, nf, M_PI/2, "orgN", N)
{
Cf += Cl;
}
}
light
importer()
{
vector orgN;
if (!simport("orgN", orgN))
orgN = N;
// Use original N
Cl = orgN;
}

Add attribute type option

The SOP/POP context function addattribute now specifies the type as a keyword pair. The types may be vector or indexpair.

sop
setRandom()
{
vector nn = nrandom();
// Houdini 8
// addattribute("rnd", nn, "vector");
// Houdini 9
addattribute("rnd", nn, "type", "vector");
}

Generalized spline function

The new functions spline and kspline take the basis as the first argument. The basis can be one of:

  • linear – Linear spline between keys.

  • catmull-rom – Catmull-Rom interpolation (first and last keys are used only to supply tangent information).

  • linearsolve – Computes the inverse mapping for a set of linear key values (and is used by the kspline function).

The H8 ckspline function is equivalent to:

vector
ckspline(float t, vector v0, float k0,
vector v1, float k1,
...
vector vN, float kN)
{
float tt;
tt = spline("linearsolve", t, k0, k1, ..., kN);
return spline("catmull-rom", tt, v0, v1, ... vN);
}

New forms of transform

There are three new transform functions which can replace many of the shading transform functions.

ptransform will transform the vector as a position. vtransform will transform as a vector. ntransform will transform as a normal.

  • vector ptransform(string tospace, vector P)

  • vector vtransform(string tospace, vector V)

  • vector ntransform(string tospace, vector N)

  • vector ptransform(string fromspace, string tospace, vector P)

  • vector vtransform(string fromspace, string tospace, vector V)

  • vector ntransform(string fromspace, string tospace, vector N)

These transform from one named space to another named space. If the fromspace is not specified, the current space of the vector is used. The space names may refer to any object in the scene, or alternatively, one of the special tokens:

  • space:world - World space.

  • space:camera - Camera space.

  • space:object - Object space.

  • space:texture - Texture space.

  • space:ndc - NDC space.

  • space:current - The current space of the vector.

In Mantra, the native space for vectors in shaders is space:camera. Vectors like P, N, I are all represented in camera space.