Custom videoplane blend modes
Hey,
My request is simple: I want to be able to set custom blend modes to an arbitrary number of jit.gl.videoplanes with possibly changing rendering order.
The built-in blend modes (add/multiply/screen/exclusion/colorblend/alphablend/coloradd/alphaadd) are fine, but I would like to use my own formulae, like the ones available in co.***.jxs slabs, or others.
I use videoplanes mainly for their ability to be rotated, scaled, positioned, and changing their rendering order on-the-fly with @layer.
I know I could just use textures instead of videoplanes, pass them through a [jit.gl.slab @file td.rota.jxs] for the rotation/scale/position, but then comes the rendering order with an arbitrary number of textures. Say I have N textures. I would need to create N-1 [jit.gl.slab @inputs 2] in cascade, route each texture to a given slab depending on the desired rendering order, and load in each slab the desired custom blend mode for a given texture. But this become quickly becomes a scripting headache when we want to remove/add textures and change their rendering order.
Another interesting approach is the one described in this post, which basically implements the custom blending in a jit.gl.shader applied on any object we want to apply our custom blending on. Then we make use of a [jit.gl.node @capture 1] to capture the scene and feed the blending shader with what's already been rendered, and we use the begin_capture
message out of the node to trigger the rendering in the desired order. The caveat is that instead of relying on the @layer attribute for the rendering order, we need to change the order in which bangs are sent, which seems more manageable than a cascade of slabs.
The problem with this last method is that I just cannot make it work. I made my custom shader starting from the jit.gl.videoplane default shader, adding to it a secondary texture input and implementing a very simple blending for the sake of the example. As you can see in the screenshot below, I get weird square glitches as soon as a videoplane isn't at position 0 0 0, and each videoplane seem "doubled" on the other one as if it was ignoring position.
Am I overthinking it, or is it just utterly tricky to achieve what I want?
Thanks!