Can this be done in open GL?

    Feb 11 2014 | 4:15 pm
    Sorry for the (almost) double posting, but i'm hoping to get to the bottom of
    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 layers and doing the painting with @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!

    • Feb 11 2014 | 7:42 pm
      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.
    • Feb 12 2014 | 3:17 pm
      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 still a but of a mystery though!