Gems
From Odwiki
Tricks, Tidbits and Gems for Houdini
Contents |
Houdini
The $IPT Variable
When instancing geometry on points, the $IPT variable is set to the point number that you are instancing geometry on.
Attribute Variables
When an attribute has a variable associated with it, it's possible to differentiate between the different classes of variables by prefixing the variable with pt (point), prim (primitive), vtx (vertex) or det (detail).
For example
$TX - $primCEX
Current Channel Name
The local variable $CH will return the name of the current parameter for which the expression is being executed. So, in the /obj/geo1/tx channel, it'll return "tx". This is really useful for referring to parameters of the same name in other nodes:
For example, instead of
ch("../anotherobject/tx"), ch("../anotherobject/ty"), ch("../anotherobject/tz")
... you can use the exact same expression in all three channels (tx,ty,tz):
ch("../anotherobject/$CH")
Set Channel References Down One Level
If you want to put a network e.g. in a foreach SOP and want the channel references updated all at once, you can create a subnet from the network first and copy-paste the nodes from there into the foreach.
Sharp edges without duplicating points
Promote normal attribute from Point to Vertex, then fuse points. Or, use a Vertex SOP, and choose "Cusp Normal".
Mantra
The orient attribute
When rendering open curves (polygons/Beziers/NURBs), mantra will typically orient the curve so that it's facing the screen. However, in some cases, you may want to orient the curve differently. Mantra looks for a special attribute called "orient" to do this.
Geometry
The .d format
There's a little known geometry format (extension .d) for polygons which is expressed in a move-draw format. For example
m -1 -1 0 d 1 -1 0 d 1 1 0 d -1 1 0 d -1 -1 0
represents a square.
You can use this format for all sorts of things. For example, using the VEX shader:
surface
drawNormal(float scale=.1)
{
vector p0, p1;
p0 = P;
p1 = scale*normalize(N) + p0;
printf("m %g %g %g\nd %g %g %g\n",
p0.x, p0.y, p0.z, p1.x, p1.y, p1.z);
}
and rendering with mantra:
mantra < foo.ifd > foo.d
should generate a .d file which shows all the points and normals which were shaded.



