Recipe 48: PartyLights

General Principles
- Creating an awesome particle physics generator with jit.gen
- Using jit.gl.node and jit.gl.slab/pix for post-render effects on a scene
- Creating a simple bloom filter
Commentary
Like anyone who spends a lot of time making visuals, I have a soft spot for particle effects. It’s so easy to make something dynamic and pretty with fairly economical means, and if you know where to connect an LFO or two, you can spend more time pounding your fist than twiddling knobs. In the back of my head, I’m always thinking about new ways to work with particles, and when jit.gen came along, I was ready to try. This recipe is an appeal to the most self-indulgent sort of particle effects, complete with feedback trails and a bloom effect. This is a crowd-pleaser, so turn on your projector, turn up the DJ, and get ready.
Ingredients
- jit.gen
- jit.gl.pix
- jit.matrix
- jit.gl.node
- jit.gl.mesh
- jit.gl.slab
Technique
First, to see what the patch can do, try some of the presets. Once you’ve had some fun, let’s switch into patching mode. The core of the patch is the jit.gen object that handles the particle generation and physics. Since particle physics relies on repeated transformation of points from frame to frame, we need some way to store the results of each calculation. Because jit.gen doesn’t have its own memory, we have to use an external jit.matrix object to feedback the results as input. To change the number of particles we can just change the size of the storage matrix.
Here’s a quick breeze through what’s happening in jit.gen. The first input contains a matrix of position and “life” values (x,y,z,life). For each frame, we add a velocity amount (second input) to the position of each particle to animate them. Each frame we also apply a friction calculation to the velocity values for more realistic motion. For “force” we just apply a uniform addition across the whole matrix. We could stop with just the position and velocity values, but to really push this into a more luscious effect, we also store a color value for each particle (third input). The great thing about using jit.gen is that we can keep adding other features to our particle system just by adding more inputs and outputs and deciding how they should change with each frame.
The really tricky part of this patch, and key to a really convincing particle system, is the management of particle life and death. This is done by storing a life value for each cell of the particle matrix in the 4th plane of the position matrix. This value is incremented each frame by a value calculated as 1./life. When the value reaches 1., the particle is reset by setting the logic of the ? operator to false, which passes whatever is in the right inlet. You’ll see that there is a ? object for every input/output, with the reset value going into the right.
Finally, to render the particles, we just draw them as big points in OpenGL. Notice that we aren’t rendering the particles directly to the screen, but rather we’re capturing it to a texture using jit.gl.node and then passing the captured texture through a blur and an additive blending jit.gl.pix patch. Also we use a jit.gl.slab in there for a feedback loop, so we get nice trails on our particles.
After the rendering, capturing, and post-processing, the final texture is passed to a jit.gl.videoplane that displays the final image. You will also notice there is a jit.gl.camera object in there to allow you to move around the particles in space.
[...] Jitter Recipe Books by Andrew Benson: A great set of “simple” Max patches for advanced video applications; excellent tutorials for advanced Jitter work. [...]
This is great! The thing that mistified me was how to get a continuous line when setting the brush size smaller in Recipe 44?
Setting the brush size smaller leaves a lot of ‘holes’ between’ points, upping the metro doesn’t seem to fix it. What is a solution to this?
thanks, M
getting the following error on recipe 48
”
gen_domain: jit.gen: [string "gen1.jit.cpp1"]:431: assertion failed!
jit_gen: Gen patcher not compiled
”
excited to get it working!
Hi! and Thank you!
I get the msg from hit.anim.node “doesn’t understand “anchor”"
Any suggestions ? again, Thank you
We are trying to use a different input method other than a mouse and we are new to using Max Start. Our project is due on friday so PLEASE HELP ASAP :(
Thank you so much for the patch.
However, I couldn’t seem to find which object is triggering the particle burst. I am trying to sync the burst effect to the beat of the audio signal.
Leave a Reply
DISCUSSION
16 Comments