Precise size in pixels for video mapping/compositing

agustin issidoro's icon

Hello all,

I am working in a video compositing and mapping patch in Jitter. Basically, I need to compose and map 4 video sources of 568x769 each in a 3840x2160 canvas/texture.

I am struggling to load and display those video sources in their original size in pixels.

I am loading each video source in a separate jit.gl.videoplane (transform_reset 0, but I've also tried with different options), all of them drawing to the world. Each jit.gl.video plane is being fed with the right texture dimensions (568x769), but then in the world everything gets bigger/different. Also, the dimension of the window would alter the size of the videos.

How can I keep consistent/fixed sizes as the original?

Thank you very much in advance!

Rob Ramirez's icon

Jitter conventions don't really support exact-pixel rendering out of the box. But you can do it with a bit of shader-ing that is not too horrific. Here's what I came up with as a starting point for this kind of thing.

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


agustin issidoro's icon

Hi Rob!

Thank you very much for your help, this actually works perfectly.

Only a small question too see if I've fully grasped the insights: the orthographic projection mode here is doing the trick, right? This rules out rotations in x,y planes (I was thinking in applications for projection mapping, for example) - in that case I should fallback into a perspective projection mode, right?

Only thinking about further tweaking.

Thanks again!

Rob Ramirez's icon

Glad it's working.

the orthographic projection mode here is doing the trick, right?

Well the trick is jit.gl.camera in ortho mode with a custom frustum that is calculated using the window dimensions, and a custom shader that takes normalized coordinates and maps them to the input texture size with optional offset.

The shader is utilizing the MODELVIEW_PROJECTION_MATRIX, so that MODELVIEW means it will take in position, scale and rotatexyz values from the jit.gl.layer (also the reason we need to take camera z position in the shader), which gives you some amount of transformation control in addtion to the offset. But yes x and y axis rotations are probably not what you'd expect and if you need that you are better staying with the conventions.

In case it isn't obvious, you can use jit.gl.node to mix both styles of rendering (simply bind you camera and exact-pixel objects to one jit.gl.node, and all other objects to another).