Jit.world or Jit.gl.render with no clearing of screen between frame

Noah Mitchell's icon

Looking to not have the render clear each frame update. Want to leave a trail of motion for an object or give a scaling effect. I know there is a way to do this I just can't put it together myself. Thank you

LSka's icon

use the @erase_color attribute. It requires 4 floats that specify the RGBA values to be drawn on top of the scene. So @erase_color 0 0 0 1 completely clears the frame with solid black. @erase_color 0 0 0 0 leaves the frame as is. You can play with the alpha value (the last one) to create longer or shorter trails.

If you want more control or combine more effects, check [jit.gl.slab @file co.accum.erase.jxs] or [jit.gl.pass @fxname smear]

Max Patch
Copy patch and select New From Clipboard in Max.



Noah Mitchell's icon

I love you so much. You made my night. I've struggle with the jit.gl.slab and the jit.gl.pass previously. I've tried the maxhelp stuff too and it doesn't make much more sense. Perhaps you can explain the functionality to me in more simple terms. Or it may just take time. Anyways thank you so so much for pointing me in the right direction

LSka's icon

Ok, I'll try.
Basically, everything in GL needs a context to be drawn into (see: https://docs.cycling74.com/max8/vignettes/jitter_gl_contexts ). If you don't specify one, jit.gl objects will use the implicit one set by jit.world or jit.gl.render

jit.gl.node allows you to specify a sub-context to do various things, such as grouping objects or applying different lights or capturing the scene to a texture.

If you capture to texture, you can then use [jit.gl.slab] to further process the resulting texture.

[jit.gl.pass] does the same, in fact it's sort of a wrapper for multiple chained shaders, you can create your own passes, editing the .jxp files.
You have to reference it to a [jit.gl.node] sub-context, so it knows where to extract data.

Regarding the "erase" process, you have to think about it as a paint-on, rather than an erasing.
Each frame draws on top of the previous, and just before the renderer writes a background on top. (the old-school jit.gl.render method explicitly shows the "erase" message being sent before the next bang)

Max Patch
Copy patch and select New From Clipboard in Max.

As I said before, the erase_color attribute specifies the background color and alpha to be drawn on top of the previous frame.

Hope this helps clarify some less-straightforward logic in OpenGL logic.

Noah Mitchell's icon

It makes a little bit more sense. I am still getting used to the context and subcontext ideas. I have spent my entire time with jitter thinking that jit.world was the begging and end of the rendering process. Now I am seeing how there can almost be feedback loops and contexts within contexts. Tripping me out a little bit

Rob Ramirez's icon

when come down, open up your file browser and type camera.capture for some mids, and then camera.direct.feedback to really take off again

Noah Mitchell's icon

See I'm so used to the jit.world stuff and jit.gl.pix and gen stuff that this stuff seems different to me. I get the gist of what it is doing, but when I see it with the jit.gl.render context it's not as clear to me.

Thanks for those mids dude, I wanna be able to have my own textures and more control so I can get the true top shelf experience ;)

Noah Mitchell's icon

Okay I figured it out. Holy shit the feedback generates some of the craziest visuals i've ever seen.

Max is so amazing