Forums > Jitter

Combining matrices of different dimensions

July 2, 2012 | 9:15 pm

I want to be able to combine/mix/alphablend matrices of differing dimensions. For example, take a smaller matrix and mix it into the bottom right hand corner of a larger matrix.

How can this be done? Other than using a combination of jit.spill and jit.fill. Can it be done somehow using jit.op, or does this require the matrices to be the same dimension?


July 2, 2012 | 9:44 pm

In order to mix or blend matrices directly, they’ll need to be the same format. If they’re not, the jit.xfade/jit.alphablend/jit.op/etc. objects will internally adapt the inputs to be the same format. I would definitely recommend giving it a try to see what happens.

There are 3 ways to mix differently sized matrices:
1) using jit.matrix @src/dstdim attributes to put your smaller matrix into a larger one that matches the size of the matrices you’re mixing
2) use OpenGL (jit.gl.texture + jit.gl.videoplane) to composite objects in a window
3) use OpenGL (jit.gl.slab) to mix together your matrices. It takes matrix and texture inputs and outputs a texture


July 2, 2012 | 10:10 pm

Awesome, thanks again Wesley!


July 3, 2012 | 12:29 am

Great, I’ve been successful in implementing method 1 listed by Wesley above. Check it out:

– Pasted Max Patch, click to expand. –


Nat
October 16, 2013 | 6:47 pm

Anyone knows if it’s possible to use this technique but have several smaller matrices blended in a larger one ?


October 17, 2013 | 7:53 am

@Nat Do you mean something like this?
<code>

– Pasted Max Patch, click to expand. –

</code>



Nat
October 17, 2013 | 9:55 am

Thanks, that’s pretty much what I want to do. The only thing missing would be a way to control the blending of the matrices if they overlap but I’m afraid the only solution would be to go with jit.gl. I’m doing this to animate pixels on a led strip so going the opengl way is not convenient as I need direct access to the pixel data.


October 17, 2013 | 10:00 am

You can use jit.gl.slab to blend things together and then do a readback from the texture to a matrix.



Nat
October 17, 2013 | 10:02 am

Here’s what I have so far, it works but there’s no blending, I’m not sure that’s even possible using that technique. If you play with the position setting and they overlap you will see what I mean.

<code>

– Pasted Max Patch, click to expand. –

</code>



Nat
October 17, 2013 | 10:12 am

@Wesley, I tried with videoplanes and the blending works great, in a jit.window all is fine but as soon as I render to a matrix things get very strange, here’s the patch I have:

<code>

– Pasted Max Patch, click to expand. –

</code>


October 17, 2013 | 7:01 pm

You might get some ideas from this page:
http://music.arts.uci.edu/dobrian/IAP2006/examples.htm
Scroll down to the examples "make a mask image" and "masking by alphablend".


October 17, 2013 | 9:10 pm

nat, if you want to do it the way you proposed in your last patch, your matrix dimensions should match the jit.window dims if you want to get the same result in both:

<code>

– Pasted Max Patch, click to expand. –

</code>

also maybe have a look at jit.gl.node…



Nat
October 18, 2013 | 6:48 am

Thanks !
What also seems to help is a bigger matrix. Even if the window and matrix are the same size, if I go lower, say 60, the matrix output looks weird. I assume it’s the way it’s converted.

Things always get complicated when you try to output stuff somewhere else than on a screen…


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