How to smoothly fade out images and avoid flicker?

Diemo Schwarz's icon

Hi, I'm only starting out on Jitter/GL so there must be something very naive I'm doing or something obvious I'm missing.
I want to display an image then smoothly fade it out, blending into the next image. My first try was using the framebuffer fade out via @erase_color's alpha, for simplicity. I'm enabling a jit.gl.layer with the image for a short hold time. Large hold times produce a smooth image fade, values around 2x frame period may flicker,
going shorter makes rendering definitely flicker, and values below half frame period mainly show black.
Before going further I want to understand why this happens. See this patch:

layer-flicker.maxpat
Max Patch

I sense that the simple framebuffer fadeout is too rigid, so I'm also happy about suggestions how to do this properly with several layers that are explicitly faded (which would allow fading in, too), or with shaders (whoooo!).

Many thanks!
Diemo

Vincent Goudard's icon

Hi Diemo!
using erase_color is deprecated as it does no longer work in gl3.
You're better off using slab instead for what you want. See the modified patch below.
cheers!
Vincent

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


Diemo Schwarz's icon

Hi Vincent, I'm finally getting back to this.
Thanks so much for this solution using `jit.gl.layer`, `jit.gl.node`, `jit.gl.camera`, and a little `jit.gl.pix` (is that the slab part?) Unfortunately, it is not reaching the full framerate as with @erase_color, only 50fps.

So I wonder what a solution using a shader mixing several textures with arbitrary envelopes could look like...

Cheers!