Approaches To Dynamics In Houdini
The following is a companion to my talk at the Houdini
Apprentice Fest (or Houdini-Palooza as we like to call it) which took
place 29 January 2003 in London.
Download the accompanying Houdini hip file here,
(approximately 500k).*
Download the finished movie here,
(approximately 2 meg, mpeg video). (Note, this mpeg was saved out with the IRIX utility dmconvert, thus it is in a very old mpeg format. If you can't play it, try renaming it to a .mov file and using QT player.)
* To use: You must cook and lock the two geometry CHOPs
in the CHOP editor. Her's how: Turn the update button at the
top from "never" to "always" and then middle click (once) on each geometry
CHOP to cook. Then either lock the geometry CHOPs, or right-click and
save the clip to disc and change the geometry CHOP with a FILE CHOP and load
the saved clips. Save the hip file to your system.
Introduction
There are many different ways to create dynamic effects in Houdini. You
can use particle effects, soft body dynamics, hard body dynamics and even
the old spring SOP. In this example, I will show you how to use CHOPs
(channel operators) to create a simple dynamics effect. In this particular example, I show how to create swaying branches on a vine, so that the branches sway more at the top than the bottom.
The advantages of using CHOPs over any softbody dynamic effect are many:
- Simulation is not "live"
and does not have to be cooked from first frame
- You have complete visual
feedback in graph form of all channels
- You have complete control
over which points are affected and how much they are affected
- You have complete control
over start and end paramaters.
- You have much more control
over the behaviour of the simulation as you have dozens of CHOPs at your
disposal.
Points Covered
- Building a spline from
a series of world-animated nulls
- Place nulls in scene
- Create a new object
- Add an object merge SOP, object merge each nulls "point" SOP
- Ensure transform object is "This object"
- Concept of transform object
- If you do not have a transform object defined, you will not get
the object's world-space transforms, only the SOP-based ones
- Think of it as putting an apple in a car: Inside the car,
the apple is on the passenger seat always. But if you consider the position
of the car too, it might be in Winnipeg instead of London, (in which case
it is probably frozen solid).
- You can use a null locked at 0,0,0 instead of "This object" as
the transform object.
- Animating growth of stem
- Use add SOP to make the points you brought in with the object merge
into an open polygon
- Use fit and/or polyspline and/or resample SOPs to smooth and add
points
- Use carve SOP to animate growth
- Copying objects to a template
- Copy your L-system to the points you have selected with the group
SOP by:
- Use the add SOP to remove the geometry but keep the points....
- ... thus point positions don't change when you delete unused points
and pipe the rest of the points into the COPY SOP template input
- Using the Polywire SOP
- Any shared points will be smoothly joined... use the facet SOP
to share points
- Using stamping
- Stamping allows "feedback"
back up the SOP chain
- Allows each copy to be
unique
- To access stamping up
the chain, use the expression: param("ID",0), which
means, "use the ID value for the template, unless there is none, then use
0".
- Here we use stamping
to rotate and scale each copy uniquely.
Adding a random rotation for each copy
- Fetching animation into
CHOPs
- Use the geometry CHOP to fetch point positions. Save to disc
and then read back in to save cooking time.
- Assigning point colours
using $BBY
- Back in SOPs, pipe your L-system SOP into a point SOP, add point
colors, and use the expression $BBY
- BBY represents the objects
bounding box in Y. At the bottom of the box, the value is zero, at
the top, it's one, no matter the size of the object. Thus the points
at the bottom are black (0,0,0), and white at the top, (1,1,1).
If you examine the hip file available on this page, you will also see the use of the chf expression to set point colours. Here is an explanation of the use of this expression.
The chf function is used to lookup a value at a specified index. In other words:
I have created a spare channel in a point SOP called which I have called "lookup", (ctr+r click in SOP arena to add spare channel). This lookup channel goes from zero to 100 in time. However, in this case, we are not really using this channel in reference to time, we are using it in reference to $CR, which is the red point colour. The point colours go from 0 to 1, which is too small to be useful in the channel editor, so I have multiplied it by 100 so that I have more resolution to play with, and it now goes from zero to 100.
So, where the value of $CR is zero, the expressions evaluates to use the value at frame zero. When the value of $CR is 1, then the expression evaluates to use the value at frame 100, (1*100).
In this way we can draw a nice curve in the graph editor to create or modulate any value. For example, you can use a similar expression to get the alpha of a particle to fade to zero near the end of its life. In a point SOP, alpha channel:
chf("./lookup",$LIFE*100)
- Fetching point colours
into CHOPs
- Use the geometry CHOP to fetch the point colours too. Do
this for only one frame as these don't animate.
- Adding lag / isolating
lag
- Use the aptly-named lag CHOP to add lag.
- Modulating lag with point
colours
- Subtract the original point position to get the lag only.
Lag only
- Multiply these values by the point color so that there is more
lag at the top of the branch and none at the bottom.
- Add this lag back into the original animation and re-export to
SOPs using the Channel SOP
- Simple particle systems
- A simple particle system is timed to coincide with the collapse
of the wall to simualte broken mortar and dust.
Sean Lewkiw
http://www.lewkiw.com