7. How to Make 3D Jello

Kaveh Kardan
3 min readApr 22, 2022

--

Besides hacking for fun, learning, and exploring at the Media Lab, I also did a thing which I think qualifies as research. I pushed the state of the art, though I didn’t think to publish the results.

I had come across an article describing “particle systems”, written two years prior by Bill Reeves of Lucasfilm (later rebranded as Pixar when purchased by Steve Jobs). The technique —now a staple of the VFX industry — had been used for the Genesis sequence in the movie “Star Trek II: The Wrath of Khan”, which depicted flames sweeping across the surface of a planet.

The technique involved simulating the action of forces on particles, which were drawn as points or short line segments. So I implemented that and watched bunches of points on the black and white monitor — which could display simple line-drawing animations in real time — fly up and get pulled down by gravity. Soon, they were bouncing off the “floor” at the bottom of the screen like so many tiny black tennis balls.

Then I thought the particles should interact with each other, like magnets. I naively thought that if I took a positively charged particle and placed a circle of negatively charged particles around it, I should have a nice equilibrium of forces. How naive. The setup proved unstable and my particles shot off in all directions.

I thought about what was happening, and realized I needed some force which would attract AND repel. The epiphany came when I remembered my freshman physics class: springs! F = kx!

I joined four particles with springs, cross-braced them (imagine a square with an “X” connecting diagonal corners), and let the simulation run. The square fell under the influence of gravity, and when it hit the bottom of the screen it bounced up, wobbling like jello as the springs did their thing. It didn’t fly apart. It held its shape, bounced a few more times, then settled on the “floor”.

And so it was, alone in the dark of the lab, music (probably) blaring, I “invented” the spring-mass system which is today the standard technique used for all sorts of non-rigid deformations in computer graphics. Clothing, hair, fur, rubber, and, well, jello.

I then made grids of mass-spring systems to simulate drapery hanging from pinned corners, flags blowing in the wind, and 3D cubes bouncing off walls and the floor. I called these “partex” systems, a portmanteau of particle and vertex.

A few months or years later, I saw some animated flags using the same technique from, I think, Ohio State, which had a serious graphics program at the time. I had, at any rate, come up with the approach prior to any published literature on the subject.

Many years later, the cloth simulation work I began in 1985, along with my Symbolics experience, would alter the course of my life and take me to a new life in far away Hawaii.

Design & Code

The code above is pretty standard stuff. The kind of thing you implement at the start of any 3D graphics development. I’ve done it many times, in Lisp, C, C++, and even Smalltalk.

Well, these days you wouldn’t write it yourself. You’d find an existing library to download and use. It will probably be more general, better optimized, and more thoroughly tested than your own code.

But so far in this project I’ve resisted that urge. Partly because I enjoy writing the code, and partly because I know I will at some point re-architect the software, later, when I have a better understanding about what needs to be done.

But also partly because I had already written the code. If you missed it, go back and look at the comments at the top of the listing. Thirty years to the month as of this writing. It’s gotta mean something.

Next Episode

--

--

Kaveh Kardan
Kaveh Kardan

Written by Kaveh Kardan

MIT mathematics degree • wrote animation software used in “Jurassic Park” • software R&D lead on “Final Fantasy” movie • software dev on “The Hobbit” films

No responses yet