From cgwiki
Jump to: navigation, search

Point wrangle vs prim wrangle

Set colour from a sine wave based distance as we've been doing:

 float d = length(@P);
 d *= ch('scale');
 @Cd = 0;
 @Cd.r = sin(d);

Now on the 'run over' drop down, change it from points to primitives.

Point vs prim swap.gif

Note how the result looks sharper, more 8 bit. Also notice that @Cd has gone from the geo spreadsheet. Click the primitives button on the geo spreadsheet, ah, thats where colour went.

Why does it look sharper? Because the points are shared between the primitives, the colour is blended across the prims. But if we colour the primitives directly, there's no blending the result is crisp. Read the Points_and_Verts_and_Prims page for more info.

Can we do other tricks like moving @P on prims?

 float d = length(@P);
 d *= ch('scale');
 @P.y = sin(d);

Swap between point and prim mode. No, it only works on points. Look in the geo spreadsheet, can see that points have a @P attribute, so they can be modified, but prims don't, so they can't. Prim position is driven by the points that make it up, again refer to the points/verts/prims page for more info.

But wait... why did colour work then? We got waves, so it must be reading @P on the prims... but its not in the spreadsheet... but the waves work.... but its not there... mind blown

The answer is pseudo-attributes. You've used a few of these already without thinking about it; @ptnum isn't listed in the geo spreadsheet, but we've called it a lot, @Time isn't in the spreadsheet either. Vex has a few read-only attributes like those, and in the case of prims, will generate a pseudo @P that is the center of the prim.

How to know about attributes like ptnum, P, N numpt etc

A lot of it comes down to experience, but houdini comes with a built in cheat sheet. Create a point vop, dive inside, look at the global parameter node. They're the usual ones that either Houdini expects to find, or provides for you, or both. Similarly for the output vop node.

Pvop attributes.gif

Other modes on a wrangle, vertex and detail

Vertex wrangle makes sense, it lets you run over every vert in your geo. Like prims, they don't let you set many interesting things, vert wrangles are rarely used outside of uvs, yet again, refer to the point/vert/prim page for details.

So whats a detail wrangle? This simply means 'run once'. This is handy for situations where you're referring to the entire object in one hit, like calculating its bounding box, or setting a single text variable somewhere. You can do more with this, to come in a later chapter.

You can also set attributes at this high level on the entire geometry, click the 'details' button on the geo spreadsheet to see this level of data.

Moving beyond P N Cd ptnum

All the demos so far have written results directly to position or colour. What if you want to store it as something else? Say you want to store each points distance to the origin, to be used in another wrangle later on?

You can make up your own attributes, just prefix it with @.

 float d = length(@P);
 @mydistance = d;

In fact its common to not use local variables at all, and just directly assign and read from your own attributes:

 @d = length(@P);
 @d *= ch('scale');
 @Cd = 0;
 @Cd.r = sin(@d);


  1. set normals per prims
  2. set a @d attribute on prims in one wrangle, and use it to create a colour sine wave in another.
  3. set a d@ attribute on prims in one wrangle, and use it to create a position sine wave in another. Hint; as mentioned above, @P is read only for prims, but read/write for points. You need to find a way to read @d into points. You can do this in vex in roundabout ways, but its easier to just transfer or promote attributes from prims to points, this is a common operation in Houdini setups. There might even be a sop to do this... I wonder what it's called...

prev: JoyOfVex5 this: JoyOfVex6 next: JoyOfVex7
main menu: JoyOfVex