laying one jit.matrix with an alpha channel over another… should I use jit.op?
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:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 941.3oc4Y11TiBCDG+0seJX300Nr4Afdux6ywM23PoQMdTnCjp8zwu6GIgZq NUboZC0ioikgX5x+7a2jrK4owi7mWrQT468Cue4MZzSiGMxzjtgQM2OxeYxl zrjJS27yEOTL+N+I1+kRrQYZd8iROx1VyWurXsJSnL+DZSq1lT+ckv977mmj ei+jcWk40152M895hbUdxRSe8+YoLIaq0WknRuUleyUkhTk0TDJYZvDOHfpu vB0eSBlF7h0jKL1oV4Wv826ITIez7D.8u+EwKy2pchtsmGOV+0jOGgxJRVXG oGBRPqP5HoBgqAQjgMgAsAERWfB70Ak6jpoqJqc7dWpj0ibuzhkyKNLhHuGh pMxUKSTkxM5nniEVAFLwoFNAvr1vEkep4kALOHyWT7PGowqYvAFoPjIrfE2L Mo0.CJy2Ag.Eq7tr9uK5CG+VbXWBwNY4coA8ju3w5kyEkcjC5ENm7oVpHL1t .pcNfMh.NLC.XmcJqsuRTdkHOYdl4IEbH9P+BWGom3CEOeHCP9v6P7CcHxmN D+vFf7gEQQyG9PjO.GMeB6S9LesRUj+oxw8.Ce5LvL7oa2b982hFhN0IrrJI 8OdUBUpHKyKn9y8I1q0e53.+HiFZvAylqRHeZDuk3gX+N3yiOuxUkAFmMkBH xUEl465xUJk2bqpOxZkQYFTvaJ7Mp0zVCN0kqbhl1GYJQABQLumBtv4a8aV2 tGyK81jxZ36A8RHPfID.lYJUEX7VwyouB+9YmQp8kbX2Zn8cFIyFfYNPhvym 3gHe5P7Sz.jOPGheBGh7ABQymg4aF.Mdn+GV3hcKZ1Gm+BgM.pagYeSqXJag v+FW1BmZqZgfnpE2WzRl35dolknXqi2DELq0CXg88rfE6oFAgHluScX4JZGd uWsRzdyE.ZbqExerdeiw7yj4u8LsMBR29q4XUw5xzsCylIid6jzBQkRlmnj0 QJ65i9Pf1qS2JWrPju+VTKjU5csLimfC5PwJGNF4.mWxwYpQezjerb3tSOTL 5g4N8PvnmfyK8.ybmd.L7g3N8fAONSMDLKEpSRyKxM5IFqdBcidhvpGtazSH V8vbid3mWgyLr3wQ5ghUOfazCAqdHtQOHji67V.57Bci2BhOu15BvrX3aD8I UOgX0ii7Wbr5wMyt.FV83lMK.JV83lMSABV83ljM..qdbSxXXji6RjGiZN1x truQgjUqtWTV0XRiP7WlbWQo91vIlak41aMVzuTbuba+Yi0V64w+Cn8.vyM -----------end_max5_patcher-----------
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 :)
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.
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 qt.movie objects, but you could swap these for jit.matrix objects:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 740.3oc2WssaiBCD8YxWgEOmMBaHjv9T2uiUUUFXZhq.apw4RaU+2WeAZYSS HzKgsZUjvYlXaNyIybrmml34mJ1C09neh9Mxy6oIddVWFGdM1d9kz8YEzZ6z 7yDkk.W4O08aJXux5WTAbDEUJ1x.jPhtkU.ncL0ZDsnZMEkslx4PQ65JXbHS rgaWLow4sBtpl8HX7gIyBZby2Tx3EfxB.7qNEaTsdamZEUkslwWciDxTtvJb NVuSnkQlm34AlgPsA55l0vxcAP5c+XteGjvokVj3+KIiV3a9gmmLw7X5.4JN rSuqugptiolspX1VVNHpJnb.IAdNHSooOftpf9.HQXzUoEZu2.bp9KF6bnRs t0Nv+SyYjSyYj34V1JxNDEXGHAGmzvQsXws4pGp.21XhzaJoJIau+Tju+Kq9 hSu6X7bwtN75Ektvw1jpfDKoQVzKaEdR1JkxWMx7jNMzwQiKUQVZqIwgQ8RU jQmpJg5Z5J3MbkDn4uGdgbTdA2iJkK4IgXyjbUeKONsr3jrxXxFnbwifblVu +hxKXRRGknjv9Hl3QiX9PB6+C0ywj.Wg1bW5UXekceCkyuWMycwhqn4zJEBO Jm9gW3zy6ksB+dwVJTp8CHo0vmmkh5ImxpcGa4nE8dj24kwObzg9+WyuZpFw KvCH+BG78JA69RPIE56DdYk8sIWgKsoX8d6yj9St9hIEkX0phWpqFPZvYiQb Pazc5Xb4IiQloApqe4cH0AnBjMGpXaLpSPZmnsyqC53yBNi++NxqEajYsuoF sNzq.LGpULNUwD7NywzMPmIslkmC7tsnkypMfK+PzM8cCGsth9bzy.mfQENj y.mvQCMGD3GGNi2+UIC.MjQCMKG.ZRFMzrX.nY7RbhGRQ94ppJY4UBs3TiPC VqjOWWrFGaGz2ou050WzWZc3YC.xnJKDdofiSRmVUsEj0M6oEI5istSHMlwS slLtyzti5N31xZmezDyt87j+.juW21O -----------end_max5_patcher-----------
If you’re planning on blending 8 images, it’s better to do it on the GPU with jit.gl.videoplane as LW demonstrated.
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 http://www.opengl.org/
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?
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:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 924.3oc2XtrbaBCEFds8SACqc8fj3ZW0mhtoSmLxFUa4BRTPNwIYx6dQBgia rMQ3fkIcggAAV7e9z4l34oSbWv2Qpbc9pyOblL44oSlnFRNvD80Sbyw6Vlgq TOlKi7.ewF2YM2RP1ITCmwwoKvrUs23Wblnh9DQdS.btmdX11b9VQFQnlLfd zlgDOVPZThqZlb9o91EXwx0T1p6JIKEMOAD5UOmNApi.O0IHXt29+CMUIqZo 9EX7ghhgyUuE2uSJSwLr6qJix1KL4XuLcp7vLCAyRddNgINhLBdgSF9QRYuP S6nEkjp5YEKnb1A1uum7O5ffwxSd5CcQL+FHgPpSwwcRrnaJwxoooYjq.zRP J2E+.igVRiCVfIPK7lBsEbgfm+Qf1wleXSTVnIVefUr9MTw7hGnrT9CtmzZf c6B.C.RqvO3zwMGkHxcV8uNSDEolD+jDEi1yqSxHzfwgyjEVhGbVwZ7hLBK0 4a47ThCnWtCvygh549tbrnjtyXnnSOG52kmCn+omgCKwJvK+8Ewny4j423jg BMyI6BHKzjBefjdSV+gkraY8lsAlwVuKhslekIqBnDiZ+vyJYFyIUU3UjiVF JI3TmT9Sjx4476un1y5do.4a3RgQHEoQpJkAH4LHEbqSY7GgjlTxUHsAJ5pk 1.EZjCKbbUJu+Ek0ssAQf2unLHxRgfzp0jpKNFreQSZ.nWtAdcELAB9uLXBE 03iGO3ASZ3FmXRIXjUhkD7UqxHt8yChVuKhtry1c8zXf6OdRybeJiBbYsQJH k2QXxtPObGFWqtdqeek75UBK8sGzbAn2bTXmq+d25fqW2Nf02Fftbit3y6Do j7ocW.CAh7MAQweham2NMl2hSfI3L512Wds9ynUy2TrxBMEz18WS5qj3tZJv +ScOACPDIH1nVk+PtPpYzMixd6WfWIK43+K6p3aKW1ZRseYamWEVJoRPYpNg N3gj0lO3gVSSSIrCKKW2Ypr.gxp7N4p3fpG4l2FS5webIGY63VROxuOz6qmX qoGikCvN3wHuYj8Vt7LQOVLZGLxzCzD83YO838OtpmweNYDpGf8zCzD8.smd PlnGz3IdGfFWomirlbLI6r8BtdSY6a9h0adUmGOfQTsK6QGSJU.rWohHCx7D asDOQFjWN1ZokiLnpk8ZJzT0XoR5F3FauLx9WwX7l8JiKJtmTVomRkPbywa3 kxKCmotjxZtTMitkj6osOevT4r8xz+hjSavv -----------end_max5_patcher-----------
Hi Robert – yes, if I was going to use [jit.alphablend] then that is how I would do it – by chaining them together.
Forums > Jitter