alternative to submatrix

Guilherme Martins's icon

I am using this patch to subdivide a video content into two projectors (will be more in the future), and I notice that when using submatrix there is a decay in performance. I've searched on the forum and seen a couple of alternatives to submatrix using jit.gl.pix, but this approach is still very new to my understanding.. and I cannot connect them to the cornerpin keystone patch.

Can someone advice please? Thanks in advance!!!

Max Patch
Copy patch and select New From Clipboard in Max.

LSka's icon

what about jit.scissors?

also, you may try jit.gl.cornerpin for keystone correction.

Guilherme Martins's icon

jit.scissors cuts a single matrix in an uniform fashion, but I need the submatrix dimensions and offset features.

on the other hand jit.gl.cornerpin is just awesome!!! thanks!!!

Guilherme Martins's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is an approach to using jit.gl.cornerpin with a gen patch as a substitute to submatrix.
Now, how can I give videoplane attributes like position, scale, rotation and alphablend?

Rob Ramirez's icon

i may not be understanding what you are trying to do, but the most efficient way to "subdivide" a matrix to different geometries is probably to share the same texture, and use tex_coords to control what part of the texture is drawn where.

if you'd rather use cornerpin, simply replace the videoplanes with gl.cornerpins.

Max Patch
Copy patch and select New From Clipboard in Max.

if you want to use both videoplanes and cornerpin, render the videoplanes to a texture using jit.gl.node @capture 1, and send the output texture to the cornerpins.

Guilherme Martins's icon

thank you for helping!! i apologize if I am not able to express what I need..

following your advice, if I replace the videoplane by the cornerpin, the cornerpin object doesn't recognize the messages tex_plane_s and tex_plane_t, wich I would really like to have

I have also tried to follow your second advice, to render the videoplanes to a texture using jit.gl.node without any success.. I understand that I can capture the texture with the jit.gl.node and use it for another purpose, but it just doesn't work, will you be able to help me solving this?

Max Patch
Copy patch and select New From Clipboard in Max.

this is as far as I can go :

Guilherme Martins's icon

just to clarify what I really need, is exactly to use (two or more) subdivided matrix, each one on its own geometry with videoplane properties, plus cornerpin properties

thank you so much for helping!!!

Guilherme Martins's icon
Max Patch
Copy patch and select New From Clipboard in Max.

this patch gives a significant improvement on cpu performance, loading a movie at 3072x768 using the submatrix I have 11fps, with this patch I have 16fps.. not bad!

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You can get a significant performance boost working in UYVY colormode while on the CPU and then converting to RGBA when entering the GL domain.

Guilherme Martins's icon

@ LSka, why do you say that when entering to GL domain one should convert to RGBA? normally I use UYVY all the way.. please explain

@ Rob Ramirez, I think I finally managed how the gl.node works! thank you for pointing the direction!!

this patch shows a bit of compositing textures inside other textures using gl.node, it is a pitty that cornerpin values aren't stored inside the presets

Max Patch
Copy patch and select New From Clipboard in Max.

LSka's icon

@Guilherme: GPU always processes data in ARGB. UYVY colormode is used to speed up data stream from disk to GPU.
You can find some more info in this thread: https://cycling74.com/forums/slab-compositing-and-colormodes

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You can use number boxes instead of pattrui to store values in presets:

LSka's icon

...I mean "attrui"

Guilherme Martins's icon

I was also mentioning attrui object, the thing in using the number boxes instead of the attrui is that if you use the mouse to set the corner pin the attrui automatically updates values, and the number boxes don't

I will leave a patch showing a way to store jit.gl.cornerpin values

Regarding the UYVY, I have a question wich is, if using [jit.qt.movie @colormode uyvy] and sending to a videoplane object, I need to set the videoplane colormode to uyvy, is this correct? normally it is what I do..

or instead should I use a slab with a shader to perform uyvy to argb before sending to the videoplane?

LSka's icon

mr Joshua Kit Clayton once said:

OS X supports a UYVY texture type, which undergoes a shader based conversion to RGBA as it is loaded into the GPU, but it doesn't do chroma smoothing or other color corrections, and Windows does not provide any. This is why cc.uyvy2rgba.jxs exists, and it should *always* be used with @dimscale 2 1 like the example jjit.gl.slab-uyvy-gpu.maxpat example, to convert from half chroma horizontal resolution to full horizontal resolution.

So using [jit.gl.slab @file cc.uyvy2rgba.jxs @dimscale 2 1] should give you the best quality available.

Max Patch
Copy patch and select New From Clipboard in Max.

Maybe I found a solution for storing presets using pattr:

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

we can use the pattr object's @bindto attribute to bind the pattr to any of a script-named jitter object's attributes:

Guilherme Martins's icon

@LSka: thank you for clarifying this to me!

@Rob: nice tip! thanks!!

Max Patch
Copy patch and select New From Clipboard in Max.

should we use multiple instances of the pattr object in case we need to store multiple attributes any script'named object?

Guilherme Martins's icon

@LSka: using [jit.gl.slab @file cc.uyvy2rgba.jxs @dimscale 2. 1.] made my FPS jump from 19 to 30! I think this is the 1st time I am using a shader knowing exactly what it is doing!

Guilherme Martins's icon

is there any way to set the jit.gl.node background to be transparent?

Rob Ramirez's icon

@erase_color 0 0 0 0

Guilherme Martins's icon

awesome! thanks!!