Forums > Jitter

Using 2D GL Objects as alpha masks over video and other layers

July 6, 2013 | 3:14 pm


I’ve put together a simplified/clarified patch to demonstrate the problem I’m trying to solve. I have a piece that uses crossfading still images as the primary background, then 2D GL objects in the foreground that act as alpha masks over QT video. I’m still fairly new to Jitter (old to Max/MSP), and so the original version of this piece just mixed video and GL without any concept of optimizing to run on the GPU (and thus, my frame rates were terrible and the patch fell back to software GL).

I’ve been in the process of rewriting everything to work via and slab objects, but have hit a block, illustrated in the example patch. I’ve tried playing with the blend settings of the video (Layer 1) and the 2D objects (Layer 2), but without much luck. My understanding of GL is still fairly limited, and so I’m hoping someone can help nudge me out of this rut. Many thanks!


— Pasted Max Patch, click to expand. —
July 6, 2013 | 6:23 pm

here’s one way, using the mix operator.
capture the shapes to texture using gl.node @capture 1, and use the alpha value of the captured texture to mix the two movies.


— Pasted Max Patch, click to expand. —


July 6, 2013 | 7:04 pm

Yes, that’s exactly what I was looking for. I haven’t learned about yet, and while I had played with, I wasn’t sure how to use it in that context. I switched the second two inputs to around in your example, so it now shows the still images in the background, and the 2D objects revealing the qt movie underneath. Many thanks Rob!


— Pasted Max Patch, click to expand. —

July 6, 2013 | 8:33 pm

One quick question: In my full-scale patch, I have three objects inside three copies of an abstraction. I have to connect the object through inlets on each of those abstractions where they then connect to the and objects. However, I get "attached object is not ob3d" as an error from Does this mean it is actually failing, or is it just complaining about the initial connection to the abstraction, but still gets through to the objects inside to create the sub-context? Thanks!


July 8, 2013 | 9:44 am

the gl.node connect-to-objects outlet doesn’t work through abstractions or sub-patchers.
however you simply provide the gl objects the name of the gl.node, for patch-cordless adding to the sub-context.
eg: ctx @name sub-ctx sub-ctx sub-ctx

July 9, 2013 | 12:56 pm

Thanks Rob! I actually figured that part out a little while after posting my question and got it all working (your earlier answer solved my problem, so thank you again!), but I figured it was still a legitimate question, i.e., doesn’t the connect-to-objects outlet not working through abstractions or sub-patchers break a fundamental piece of the max model? I guess that’s really a question for the Jitter dev team, but from a programming perspective, I’m interested to know if there’s a reason for that seemingly inconsistent behavior re patching through.

July 22, 2013 | 11:50 pm

Hi –

I’m struggling with this issue of and sub-patcher hierarchy a bit, also..

I’ve attached an example patch.
I have a render context in the front, a node in a sub-patcher…but what I’d like to be able to do is include multiple sub-patchers onto the same node..

I’m sure this is somewhere in the forum already, but I haven’t been able to find it..

  1. halp.maxpat
July 22, 2013 | 11:58 pm

Nevermind, got it!

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

Forums > Jitter