masking video with jit.gl.gridshape

8888's icon

Hi everyone,

This seems like a simple question, but I cannot figure out how to create a circular mask using jit.gl.gridshape that will not change the dimensions of the incoming video.

What I would like to do is take a live video signal and simply "open up" a circle that will allow a specific portion of the video to be viewed. My current patch (which is mostly from the jit.gl.gridshape help file) changes the dimensions of the video to conform to the circular shape. I have posted the patch below. There are many loadbangs, so please save it and then re-open it.

I would like to be able to change the values to [pak scale] (which is highlighted in green in the patch) and be able to see more or less of the incoming video, without distorting the dimensions.

Any tips would be appreciated.

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

Thanks!

Rob Ramirez's icon

hello.
you want to make use of the tex_plane_s/t attributes in order to zoom the texture.

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

i've added to your patch a helpful abstraction for doing this.

8888's icon

Thanks a lot!

On a related note: is there a way to poll the source/destination data for all of the "copies" of the image that are made using a zoom value less than 1.0 in tex_map mode 1? I'm interested in changing the timings of the different copies when the zoom value is 0.258, for example. I'm not sure how this would work using the GL objects.

Rob Ramirez's icon

no, these copies are simply a gl texture with wrap-mode repeat.

of course you could build this yourself using multiple gl.videoplanes or gridshapes.

Peechiz's icon

i'm using some of this as the basis for a patch I'm working on. Is there a way to map the video texture in its native dimension? My video is being warped to a 1x1 shape, and the video was shot in 16x9.

Rob Ramirez's icon

if you are displaying a texture using jit.gl.videoplane, set @transform_reset 2, and make sure the aspect ratio of your jit.window matches the aspect ratio of your source image.

alternatively, you can try jit.gl.cornerpin @preserve_aspect 1

if the aspect ratios do not match, you can set @adapt 0 and explicitly set the @dim attribute on your jit.gl.texture.

if this doesn't help, post your patch.

Peechiz's icon

great! I will try that. The other thing that I'm wondering about is this: For the effect I'm trying to build, I'd like all the circles to come from the same video source (done), and I'd like the outer circles to have a slight delay from the inner ones so that the further out you go, the more it wiggles. (basically this: http://youtu.be/brIGXnBKEzo).

I'm pretty sure I can control the delay by pulling frames from the jit.qt.movie and just subtracting for each layer, but what if I wanted to do this live? Is there a way to save 3 seconds of incoming video into a buffer from jit.grab, or is there a better way to do it?

Thanks!

Jesse's icon

jit.matrixset

Peechiz's icon

SWEET. This is gonna look so cool when I'm done! I'll post the patch when I'm through.

mr.l's icon

Hey,

very interesting thread!

I was just wondering: Can I use a still-image as a shape for gridshape?
If I understand everything right, my goal is something simular as above. I would like to play a movie as texture and masking it, but in a way that I can move, scale and rotate the movie, without doing the same for the mask. Just as in the example you have posted. Only difference: I don't want to use the gl-shapes (circle etc..) but still images (tiffs with alphachanel). And I have to do this on three or four different movies+masks.
Possible?

Thanks!!!

Tobias Rosenberger's icon

mr. l, you can just have 2 or more videoplanes (with @blend_enable) in one render context... the mask in front

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

So, still not quite working. Transform reset in the gridshape object fixes the aspect ratio, but makes the circle an oval. Also, I can't seem to get the delayed signal to propagate into the second gridshape, it just uses the original signal, which I haven't been able to wrap my head around.

Peechiz's icon

ps. I don't have a good loadbang/loadmess setup yet. You'll have to play with the videozoom and circle size a little.