Thursday, March 22, 2012

The Copy Loop Technique

The Copy Loop Technique is useful for manipulating groups as if they were simple points or particles and want to avoid using DOPs if you don't need exact precision.

You can follow along with this example file:
copy_loop_example.hip


The method is broken down into 4 main steps:
  1. Create an ordered list of groups for each "piece".
  2. Create a single point at the center of each piece.
  3. Transform each piece to the global origin.
  4. Copy each piece back onto its corresponding point.

Creating Groups

 

The first step is key. Say you have created a fractured model using the Voronoi node. You end up with an ordered list of primitive groups, going from 0 to n. When you hold MMB onto the node you can see your group list. (If needed, you can right-click and choose "Extended Information" to see all primitive groups). Before you continue, the list of groups must be in order and no skipping; meaning that they need a common prefix, such as "piece", be in order from top to bottom, and have no missing or empty groups.

You can also use the old Connectivity to Partition combo.


NOTE: In Houdini 12, the list doesn't have to be in order from top to bottom, but should still have a common prefix and not have missing groups.


Creating Center Points

 

Loop for each piece

The next step is simple. Just use a ForEach SOP and for each "piece", create a center point using an Add SOP and the centroid() expression.

Inside the point ForEach

The Add SOP can just hang on the side as long as it is displayed. You don't need to connect it to anything.

Points created at center of each piece

 

Centering All Pieces

 

The third step will go into a different branch from your primitive groups. You need to move each group to global origin. You can use another ForEach and inside, use a Transform SOP.

Inside the center ForEach

The Transform SOP has -$GCX, -$GCY, -$GCZ in its xyz translate parameters.

Centered pieces

 

The Copy Loop

 

The last step is a little hard to grasp the first time you see it. What will happen is this:
  • You take your centered pieces.
  • Isolate all but one piece.
  • Copy that piece to its corresponding point.
  • Repeat those steps for each piece.
The key that makes this work is copy stamping using the Copy SOP. You will need 2 Copy SOPs, one to place the piece onto the point, and one to stamp, or loop, the action for every piece. 
The final layout

As a simple example, say you have a Sphere, a Mountain, then a Copy and create 5 copies. Normally each copy will look the same. But if you want each copy to have an offset in the noise, you can use stamping. Check "Stamp Inputs" and create a custom variable, anything you want. Then set that value to $CY, which represents the copy number. Now go back up to the Mountain and use the stamp() expression one of the offset parameters.

So what you are doing is sending information back up the network and it reflects back to the copy step.

So back to the main event, we will use the same Copy node with $CY, along with another Copy node before it that places the pieces onto the points. We will use the stamp() expression in the Source Group and Template Group parameters.

stamp("../copy_stamp", mystamp, 0)

piece0 gets copied to point 0, piece1 gets copied to point 1, etc.

For convenience, we can set the number of copies, or loops, to ensure we are including all of the pieces or not over-copying by using a combination of the argc() and primgroupmask() expressions.

So now that we have this set up, we can now manipulate the center points to affect the pieces. Convert them to particles, add some animated noise expression, change normal direction, add color or pscale, whatever...

Sometimes you may need to set your normals and upvectors to the points depending on the situation.

Friday, February 10, 2012

UV Space Creeping


This is a neat trick I used on a few projects. It involves moving particles along an object's UV space so that they creep nicely along the surface of the object. It works well for still objects and animated characters.

The first step is to prepare your model with proper UVs. The UVs will be of vertex type. It is recommended that none of the UVs overlap.

Next, you need to "cut" the geometry based on the UVs. Use a VertexSplit SOP and use the uv attribute.

In Houdini, you have points and vertices. Points represent the position, XYZ, in 3 dimensional coordinates and the vertices can also represent the position in 2 dimensional UV coordinates, or texture space, UVW. So you can have multiple vertices that are in the same position as their corresponding point in 3D space, but have a completely different position in texture space.

So what the VertexSplit SOP will do is split the points on the geometry if its vertices are far enough distance from each other in UV space.

The next node you need is a Rest SOP. This will simply create a point attribute that is equal to the position, P, at that frame.

Finally, you need to use a Point SOP and set the position of each point to equal the position in UV space, $MAPU, $MAPV, $MAPW.

So now what you have is a 3D geometry that mimics the 2D UV mapping. If you bypass the VertexSplit, some of the primitives may have been stretched because of the connectivity, and you don't want that. And your rest attribute will remember the original position of each point at a given frame. We will use this later...

In a separate tree, lets create a simple particle system that emits particles in a 2D fashion. They can just be saved to disk.

Now take these particles and move them to the side in Z slightly and set a Normal, N, to (0, 0, -1).

The next step is to use a Ray SOP to project the particles onto our 3D UV geometry. The normals will direct the particles onto the shape.

There will be particles that miss the geometry. Check on 'Create Point Group' to group the successful hits and later delete the ones that miss.

Back at the Ray, tell it to inherit the rest attribute from the geometry. Then use a Point SOP to set the position to $RESTX, $RESTY, $RESTZ.

Now we have particles creeping on the geometry based on the UV space. The rest attributes are pretty accurately approximated on the primitives as the particles are being projected, So it works particularly well with animated characters.

You may need to use UV Transforms to space out your UVs if some overlap.

Later you can use a fluid mesh or something on the particles.

You may need to inherit Normals from the primitives or velocity from the points.

You can also try projecting still curves for some interesting effects.

Saturday, January 28, 2012

Street Fighter X Tekken: Episode 2 Trailer

Capcom showed this trailer for Street Fighter X Tekken today at Comic-Con.
I did some of the fluid effects and shattering of the neon sign at the end.
Enjoy.

Street Fighter X Tekken: Episode 5 Trailer

Another trailer was revealed today. This one takes a more serious tone than the last three. This is my personal favorite. Jin looks so boss!



I worked on Vega's "teleporting fluid" as well as a procedural model for the broken window.

Street Fighter X Tekken: Episode 3 Trailer

Shown earlier this week at Tokyo Game Show 2011 by Capcom and friends. I did the breaking of the wooden gate and also the dynamics and shattering of the various objects on the tables. Fun stuff...