Combining matrices of different dimensions
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?
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
Awesome, thanks again Wesley!
Great, I've been successful in implementing method 1 listed by Wesley above. Check it out:
Anyone knows if it's possible to use this technique but have several smaller matrices blended in a larger one ?
@Nat Do you mean something like this?
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.
You can use jit.gl.slab to blend things together and then do a readback from the texture to a matrix.
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.
@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:
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".
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:
also maybe have a look at jit.gl.node...
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...