laying one jit.matrix with an alpha channel over another... should I use jit.op?

    Apr 19 2012 | 1:24 am
    I'm brand new to Jitter and I have a couple of questions.
    First, some background. Having had past experience with applications like Adobe Photoshop and After Effects, I'm used to creating composite images from layers. I know that if I place one layer over another, then provided the upper layer has a transparency layer, I'll be able to see parts of the lower layer beneath it.
    I'm now trying to apply this concept to Jitter. My progress is in this patch:
    I have two matrices of 10 by 1 pixels.
    The matrix on the left is filled with white pixels, all of which have their alpha channel to 255 (full opacity). In Photoshop terms, this could be seen as my image background.
    The matrix on the right has pixels alternating between completely transparent (alpha of 0) and fully opaque red. In Photoshop terms, this is like my first layer that I will place over the background.
    Now I want to lay the right matrix over the left matrix, and thus the resulting image would be pixels alternating between white (the background) and red (the first layer).
    The closest to this I have achieved is using [jit.op @op -], although as you can see from my patch this isn't quite right. (The cyan colour is unexpected, and it requires two bangs into each source matrix to get it.)
    So my first question is: can/should Jitter be used in this way? Or do I need to get my head out of Photoshop world and into another way of thinking?
    Secondly, if I am already on the right track, then is it jit.op that I should be using for this? And if so, which operator is the correct one to use?
    Many thanks in advance to any experienced Jitter heads who can help me on my path into Jitter :)

    • Apr 19 2012 | 4:48 am
    • Apr 20 2012 | 4:03 pm
      That was pretty easy - thanks Christopher.
      Interesting... the resulting matrix that comes out of [jit.alphablend] has all of it's alpha values set to 255, so after the blend it effectively 'flattens' the image (to use Photoshop terms again).
      Eventually I will have multiple layers (possibly 8 of them) that I will want to blend this way in real time. I'm wondering whether [jit.alphablend] will be the right tool for the job - I guess there's only one way to find out.
      I'm also wondering whether a 3-dimensional matrix might come in handy, as that already has the idea of multiple layers built in. We shall see.
    • Apr 22 2012 | 10:43 am
      GL can be pretty confusing if you are a beginner with Jitter, but is probably the most efficient way to do this and possibly easier with multiple layers. Here's an example with objects, but you could swap these for jit.matrix objects:
    • Apr 22 2012 | 4:10 pm
      If you're planning on blending 8 images, it's better to do it on the GPU with as LW demonstrated.
    • Apr 22 2012 | 4:22 pm
      Thanks guys.
      In Jitter, does GL refer to OpenGL? And would it therefore be wise to get my head around that before trying to use it in Max? E.g. going over the docs at
      Also, I assume the preference of using GL objects over the Jitter Matrix would be because of better performance. However, in my case, the 'images' are only going to be very small - as small as 1px x 10px to begin with. Bearing that in mind, would the Jitter Matrix be an acceptable substitute?
    • Apr 22 2012 | 6:06 pm
      you can do it all with matrices. you just have to chain jit.alphablends together. the output of the alphablend, will be the second input of the next alphablend.
      here's a basic example:
    • Apr 22 2012 | 8:43 pm
      Hi Robert - yes, if I was going to use [jit.alphablend] then that is how I would do it - by chaining them together.
      Here's an interesting point though - one of my projects will require new layers to be placed onto the composite video at the rate of about 4 per second. These layers will fade to complete transparency, so that when the bottom layer has completely faded, it will be removed. So effectively I'll have a continuously rotating stack of layers, with new layers being added to the top, and old layers being removed from the bottom. I can foresee that doing this with chained alphablends may be tricky, as I'd have to dynamically add/remove these alphablends, or do some clever re-routing to reuse existing alphablends as they become available. While I believe that dynamically adding objects is possible using javascript, I'm quite liking the codeless approach of Max, so I may get along better using a patcher object that's suited to the job (e.g.