Implementing Open GL render into a Video Mixer

jpratcliffe's icon

Hello,

I am trying to implement some Open GL rendering into a live video mixer for a project I am working on. In this example, I am using Andrew Benson's "Scramble" patch from the jitter recipes, and trying to be able to blend it's output with movies using a 3 way video fader. I plan on using different renders in the final patch, but this is just an example. Does anyone have any advice?

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

Wetterberg's icon

Please start by doing "Copy compressed" instead into here. That'll help.

jpratcliffe's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Sorry for the long code. Here's the compressed code:

Rob Ramirez's icon

in order to turn a gl scene into a matrix that can be processed with standard matrix operators like jit.op, you should use jit.gl.asyncread.
you've done this in your patch, but you haven't connected the matrix output from gl.asyncread to your jit.op video mixer.

doing this makes your patch work as expected.

however, reading back an opengl scene from the GPU to the CPU (which is what gl.asyncread does) is not a very efficient technique. a much better solution is to use jit.gl.videoplanes for each channel of your video mixer, and overlay the videos onto the 3D scene, controlling there color with the @color attribute.
make sure you set @depth_enable 0 @blend_enable 1 on your jit.gl.videoplanes.

mativa's icon

hi, i have a problem which I believe is similar, if I understand. I am trying to process every colorchannel separatly and then blend them together in the end. however, I end up with a picture that is not very bright and where the colors don't match the original.

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

I think there must be a trick with blending everything correctly?

Rob Ramirez's icon

you need to change the blend mode to make this work.
on each of you jit.gl.videoplanes, set @blend add.
you can then adjust the amount using the actual RGB color value for each layer, rather than the alpha value.

mativa's icon

hey, big thanks for your help, sounds exactly what I was looking for!!
now, so I added @blend add to each videoplane, but now I can't get the different videoplanes to blend at all... I tried deleting the @layer attribute, then it works again but looks like before. would I have to adjust the RGB color val in a different way than I did until now?

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

sorry, I feel quite thick...

jpratcliffe's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I am now trying to send the output of two separate video mixers to two separate videoplanes in the same window. I have named all render destinations with the same name. I am not really sure what has gone wrong here...

Rob Ramirez's icon

@Mativa - you need @depth_enable 0 on your videoplanes

@Jpratcliffe - your patch works as expected for me.

mativa's icon

@rob ramirez - still no luck... also, the attribute @blend add doesn't seem to exist, tried @blend_add too but nothing... do you think you could modify my patch and show me how it's done? sorry if this is kind of bold, I am getting desperate...

ps, maybe it doesn't work because i am still on max5?

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

@blend is not available on max 5.
use @blend_mode 1 1 instead