Forums > MaxMSP

Can this be done in open GL?

February 11, 2014 | 8:15 am

Sorry for the (almost) double posting, but i’m hoping to get to the bottom of this…so…

IS it possible in open GL to produce the effect in the first patch below? I want to sample pixels from a jit.qt.grab and "paint" them back on top of said video in another layer as ovals of varying dimensions. I have done this in the first patch with an LCD set to transparent and overlaid on top of the jit.pwindow. Sadly this can’t be exported to a jit.window for display and is therefor no use.

I think it can be done using multiple jit.gl.videoplane layers and doing the painting with jit.gl.gridshapes @shapecircle but I am a bit lost in the GL world.

My stab-in-the-dark attempt is the second patch and, as you can see, it doesn’t work very well.

Any advice, hints and comments much appreciated!

– Pasted Max Patch, click to expand. –

<code>

– Pasted Max Patch, click to expand. –

</code>


February 11, 2014 | 11:42 am

fun patch!

you can do this in opengl, using only a few objects. however it’s a little tricky to get right.

the basic idea is to overlay two videoplanes, the first is the live input, and the second is a texture containing the circles.

you can get the correct position of the circles, using the "screentoworld" message to gl.render, and translating that directly to the position attribute of gl.gridshape.

the tricky part is maintaining the "history" of circles. you can do this with a feedback operation, where each time you draw a circle, you paint on top of the previous circles, and store that texture for the next frame. you then composite the current circle on top of the previous circle.

in the patch below, this is accomplished by first capturing the gl.gridshape to a texture, using gl.node @capture 1 (note that it’s important the @erase_color is set to 0 0 0 0 – this allows you to do the alpha compositing in the next step). the compositing happens with a gl.pix shader. i’ve left some comments in the gl.pix patch to explain this a little, so take a look.

<code>

– Pasted Max Patch, click to expand. –

</code>


February 12, 2014 | 7:17 am

Wow…Rob you went above and beyond and I am very grateful. The patch is beautiful and is working a treat. I have it hooked up to an eye tracker to control the position of the blobs and a potentiometer to control the blob size.

Really thanks a lot, i’ve learned a lot from your patch…jit.gl.pix still a but of a mystery though!

Best.


Viewing 3 posts - 1 through 3 (of 3 total)