Sep 292012
 

I’m working on a project right now that involves exporting cached geometry from Houdini to Maya. The Alembic node makes that a fairly painless process now that Houdini and Maya both support Alembic import/export, although it turns out that getting any data other than point positions and normals is kind of a hassle. I tried renaming the Cd point attribute in Houdini to all kinds of things in the hopes that Maya would recognize the data, but Maya wasn’t having any of it. That’s when I checked out the script editor in Maya a little more closely and saw this:

// Error: line 0: Connection not made: 'output_AlembicNode.prop[0]' -> 'subnet1.Cd'. Data types of source and destination are not compatible. // 
// Error: output_AlembicNode.prop[0] --> subnet1.Cd connection not made //

Maya is creating this “Cd” attribute on the mesh, but it has no idea what to do with the data so it throws an error. The Alembic node, though, still contains that data, as the 0th index of the array “prop.” Now all you have to do is get that data from the Alembic node onto the vertex color somehow…

The SOuP plugin for Maya has the answer. There is a node called “arrayToPointColor” that will read an array of data and apply it to the point color of the mesh it’s connected to. Create the arrayToPointColor node, and feed it your geometry (mesh.worldMesh[0] –> arrayToPointColor.inGeometry) and then feed it your data array from the AlembicNode (AlembicNode.prop[0] –> arrayToPointColor.inRgbaPP). If you have more than one point attribute exporting from Houdini, you may want to check the script editor to make sure you know which index of AlembicNode.prop you are supposed to be connecting.

Finally, make a new mesh node and connect arrayToPointColor.outGeometry –> newMesh.inMesh. If you were to select some vertices and look at their properties in the Component Editor, you should see values attached to the “red” “green” and “blue” vertex attributes.

All that’s left to do at this point is to connect this color data to a texture that can read it. In mental ray, you’d create a mentalrayVertexColors node, and connect newMesh.colorSet[0].colorName –> mentalrayVertexColors.cpvSets[0]. If you don’t see a colorSet[0].colorName property on your mesh, try selecting the mesh, then go to Polygons > Colors > Color Set Editor. You should see a colorSet1… just select it, click “Update” and you should have the property you’re looking for. Then connect the mentalrayVertexColors node to any shader. See Fig. 1 for the example network.

Fig. 1: Node Editor network connections to link Alembic attributes to vertex color.

You can also just remove the middleman entirely at this point, and delete the original shape node. Then connect the AlembicNode.outPolyMesh[0] to arrayToPointColor.inGeometry. This is probably a good idea if only because it will stop Maya from throwing annoying errors every time you select the geometry because of that missing “Cd” connection.

Sep 052012
 

L-systems can get very complex very quickly. If you want full control over exactly how the plant grows and what its final shape looks like, you’re in for a long haul. There are a few ways to get “artistic” control over an L-system, like using metaballs to influence rules depending on the turtle’s position inside or outside the volume, but in general a single L-system has to control everything just with variables, which gets tedious quickly. It gets even worse when you want complex branching structures.

I was following along with the excellent L-systems tutorial (part 2) from cmiVFX, which offers a way to nest L-systems using some creative use of the Copy SOP. If you’ve checked out the tutorial, it’s in an older version of Houdini which historically crashed when you tried to connect L-systems together as Leaf inputs. While this isn’t the case anymore with Houdini 12, you still miss out on the big advantage of the Copy SOP method, which is manipulating point attributes and using these to set properties of the branch L-system using copy stamping.

I won’t go into the finer details of setting up this method; you really should just watch the tutorial I linked to in order to understand how the Copy SOP method of nesting L-systems works. Basically there is a “trunk” L-system, which has rules that call for a “J” leaf. The “J” leaf receives a simple curve with three points, one at the center, another straight above the center (+Y), and another along the positive Z axis. After this curve is copied onto all the J inputs in the L-system, you can use the difference in position of these points relative to each other to determine a normal and up vector for each instance of the curve, and write these vectors to the points. Then the points other than the center points are deleted, along with the trunk, leaving you with a bunch of points from which branches will sprout, each with attributes N and up. These attributes are automatically used by the Copy SOP to orient an instance of a second “branch” L-system to each point. Again, this is a very quick write-up of a complex network, and you should watch the tutorial. Hit the jump for more…

Continue reading »