particles and blur effects

adamklec's icon

I’m trying to learn about particles and shaders. I think I have most of the basics down. The PartyLights recipe and a few other patches I’ve found in this forum have has been very helpful for me.

I have a question though.

How would you add an “un-blurred” object to the middle of PartyLights? I’m imagining blurred particles flying around a jit.gl.gridshape sphere that has not been blurred. Of course I can just naively add a gridshape object to the patch but then the sphere just hovers above the videoplane. How do you get the blurred particles to fly in front of and behind the un-blurred sphere?

A few forum posts have touched on this question. For example:
https://cycling74.com/forums/blurring-individual-jit-gl-gridshape/
But I can't say that I fully understand the solutions being discussed.

I'm hoping someone can provide an example or point me in the right direction so I can know where to start reading.

-Adam

Rob Ramirez's icon

there is probably some complicated solution involving capturing depth to a texture and custom shaders, however the simple solution involves using two jit.gl.node objects, one capturing post-processed objects, and one capturing normal objects.

there are two options, depending on your scene and desired results.
the first option is to duplicate post-processed objects in the normal node, and the second is to duplicate normal objects in the post-processed node.

either way, for the duplicated objects, you simply need the geometry captured with no materials or lighting, and @color set to 0 0 0 0. this will provide proper occlusion in the rendered textures.

finally, you can simply alphablend the two textures using jit.gl.videoplane's.
the order the videoplanes are rendered is important, and controlled via the @layer attribute.

i've attached a basic example using the first technique, and modified the party-lights recipe with a jit.gl.gridshape rendered using the second technique.

experimenting with the videoplane @blend mode will give different results.

48.PartyLights.maxpat
Max Patch
node.capture.pp-blend.maxpat
Max Patch
adamklec's icon

Cool. Thanks Rob. That's a clever solution. I assumed that this would require a custom shader but it's nice to see that it does not. Although after reading Andrew's shader tutorial I'm now inspired to begin exploring shaders anyways!
https://cycling74.com/tutorials/your-first-shader/#post-264662