Now that my working days are spent working purely with Swift, it's a good time to stretch my technical and creative muscles and learn something new in my free time. I've long admired Houdini from SideFX, and mastering that is my new goal.

I've picked Houdini over other 3D applications such as Maya and Modo for a few reasons:

  • Houdini takes a procedural approach to building, animating and texturing scenes. Every object is represented as a node and its properties can easily be accessed and tweaked.
  • VEX, Houdini's language, permeates the entire application: everything from geometry to shaders can be written in VEX and this is the direction I'd like to explore.
  • Houdini seems to be the tool of choice for particle effects including pyrotechnics and fluid simulations.
  • I love a node based user interface!
  • SideFX have a great licensing model for learning Houdini: their Apprentice version is free for noncommercial projects and doesn't time out after 30 days.
  • It's hard 🙂 I don't mean that in a bad way - Houdini is a huge and amazingly powerful piece of software that I suspect will be a challenge to master and who doesn't love a challenge?
I needed a bit of a kick start to get to grips with some of the basics - tasks as simple as setting a keyframe may not be immediately obvious. To help me out, I turned to Pluralsight who have some great online training. 

My first experiments in Houdini have been looking at different techniques playing with impacts. I've taken four approaches, which you can see in the video above, here's a little summary of how I've put these together.

Setting the Scene

The scene is pretty basic: a box which is the target and a moving sphere which I'll launch towards the box. Adding a rigid body ground plane automatically creates a DOP (Dynamic Operations) Network - which controls the physics simulation.

I've also added a camera which points towards a null object centered on the box. The first simulation uses depth-of-field, so to get the camera's focus distance property to be the distance between it and the null object, I've written my first piece of VEX (hurrah!):


Of course, the day Houdini supports Swift will be the happiest day of my life ðŸ™‚

Experiment 1: Breakable Rigid Bodies

My first experiment is pretty simple to set up. Rigid body objects (RBD) are created from both the box and the sphere using the "RBD Object" shelf tool and the box is made breakable with the "Make Breakable" shelf tool. These two steps creates all the nodes necessary for the simulation:


In this network, there's only one solver - the rigid body solver.

Selecting the sphere and giving it an 'x' velocity under its "initial state" makes it fly towards the box and, upon impact, creates the effect above.

To get the depth of field rendering nicely, the camera has a pretty wide aperture (an f-stop of 0.6) and I've set the Mantra pixel samples to 8 x 8.

Experiment 2: Particle Fluids

My second experiment makes the box a highly viscous fluid - this is more like shooting a ball bearing through treacle. In this experiment, the sphere is still an RBD, but the box is made into a particle fluid using the "FLIP Fluid from Object" shelf tool. To add viscosity, I additionally used "Make Viscous". The end result is s lightly different DOP Network:


In this network, there are two solvers - the rigid body solver for the sphere and a FLIP fluid solver.

For this experiment, I wasn't interested in simulating refraction and decided on an opaque fluid. To that end, I turned off the fluid interior display in the top level network.

Experiment 3: Finite Element Method

The third experiment takes a very different approach - rather than making the box and the sphere rigid bodies, I made them into FEM solids using the "Solid Object" shelf tool. Solid objects have properties such as stiffness, damping and density and Houdini supplies presets for materials such as rubber, organic tissue and cork. Much like an RBD, solid objects have an initial state and that's how I gave the sphere its initial velocity.

The DOP Network after creating the solid objects is:


In this network, there's just one solver - the finite element solver.

Experiment 4: Grains

My forth and final (and favorite!) experiment uses Houdini's grains. Here, the sphere is an RBD but the box is turned into a system of grains using the "Wet Sand" shelf tool:


In this network, I'm back to two solvers - the rigid body solver and a POP solver for the grain particles. 

A little tinkering with the clumping and internal collision properties of the POP Grains node gave a fairly solid object until the sphere hits it and makes it collapse.

Conclusion

Houdini is powerful - super powerful - but daunting. From my experience, it will take some time to start feeling at home in the application but, my goodness, it's worth it. Once I had a grasp of the basics, creating these effects was actually a pretty simple affair - the shelf tools give some really nice defaults that can be easily tweaked. 

Keep an eye on my blog or follow me on Twitter, where I am @FlexMonkey, to to keep up with my explorations with Houdini. 






0

Add a comment


It's been a fairly busy few months at my "proper" job, so my recreational Houdini tinkering has taken a bit of a back seat. However, when I saw my Swarm Chemistry hero, Hiroki Sayama tweeting a link to How a life-like system emerges from a simple particle motion law, I thought I'd dust off Houdini to see if I could implement this model in VEX.

The paper discusses a simple particle system, named Primordial Particle Systems (PPS), that leads to life-like structures through morphogenesis. Each particle in the system is defined by its position and heading and, with each step in the simulation, alters its heading based on the PPS rule and moves forward at a defined speed. The heading is updated based on the number of neighbors to the particle's left and right. 

The project set up is super simple: 



Inside a geometry node, I create a grid, and randomly scatter 19,000 points across it. An attribute wrangle node assigns a random value to @angle:
@angle = $PI * 2 * rand(@ptnum); 
The real magic happens inside another attribute wrangle inside the solver.

In a nutshell, my VEX code iterates over each point's neighbors and sums the neighbor count to its left and right. To figure out the chirality, I use some simple trigonometry to rotate the vector defined by the current particle and the neighbor by the current particle's angle, then calculate the angle of the rotated vector. 
while(pciterate(pointCloud)) {

    vector otherPosition;
    pcimport(pointCloud, "P", otherPosition);

    vector2 offsetPosition = set(otherPosition.x - @P.x, otherPosition.z - @P.z);
    float xx = offsetPosition.x * cos(-@angle) - offsetPosition.y * sin(-@angle);
    float yy = offsetPosition.x * sin(-@angle) + offsetPosition.y * cos(-@angle);
    
    float otherAngle = atan2(yy, xx); 

    if (otherAngle >= 0) {
        L++;
    } 
    else {
        R++;
    }   
}
After iterating over the nearby particles, I update the angle based on the PPS rule:
float N = float(L + R);
@angle += alpha + beta * N * sign(R - L);
...and, finally, I can update the particle's position based on its angle and speed:
vector velocity = set(cos(@angle) * @speed, 0.0, sin(@angle) * @speed);  
@P += velocity ;
Not quite finally, because to make things pretty, I update the color using the number of neighbors to control hue:
@Cd = hsvtorgb(N / maxParticles, 1.0, 1.0); 
Easy!

Solitons Emerging from Tweaked Model



I couldn't help tinkering with the published PPS math by making the speed a function of the number of local neighbors:
@speed = 1.5 * (N / maxParticles);
In the video above, alpha is 182° and beta is -13°.

References

Schmickl, T. et al. How a life-like system emerges from a simple particle motion law. Sci. Rep. 6, 37969; doi: 10.1038/srep37969 (2016).


5

View comments

  1. ok. I've got to finish current job, then crash course in programming, and ... this is very inspirational!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
About Me
About Me
Labels
Labels
Blog Archive
Loading