Personal tools

Gems

From Odwiki

Jump to: navigation, search

Tricks, Tidbits and Gems for Houdini


Contents

[edit] Houdini

[edit] The $IPT Variable

When instancing geometry on points, the $IPT variable is set to the point number that you are instancing geometry on.

[edit] 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

[edit] 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")

[edit] Mantra

[edit] 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.


[edit] Geometry

[edit] 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.