Forums > Jitter

multiple matrix layer slowdown

March 28, 2006 | 8:02 pm

Hi there – I’m relatively inexperienced with Jitter, and I was trying to do the following:

I have 6 different images that I need to move around on a white background. The way I’ve been doing this is based off Tutorial 16 – rendering the images to a named matrix in the appropriate order. However, I have a .js function that determines the order in which the images need to be layered at any given time. As of now, this function spits out a list that I stick, rather arbitrarily, in a [zl join] just to have somewhere for a metro to bang a jit.qball into it regularly.

Aside from this difference, I think I’ve implemented everything pretty much as the tutorial patch has, but I’ve noticed a big slowdown and chunky reaction times to the instructions for the images to move around. The relevant part of the patch is included below – I haven’t included the .js file but hope that this is enough to diagnose the issue…

Thanks for any help!

Liam

max v2;
#N vpatcher 108 56 1130 608;
#P window setfont "Sans Serif" 12.;
#P comment 574 389 382 196620 — this sets the background to white before any of the images get written.;
#P window setfont "Fixedwidth Serif" 10.;
#P window linecount 1;
#P newex 204 61 58 1441802 loadbang;
#P newex 32 358 26 1441802 t b;
#P newex 32 393 76 1441802 send output;
#P newex 407 416 26 1441802 t b;
#P newex 349 416 26 1441802 t b;
#P newex 291 416 26 1441802 t b;
#P newex 233 416 26 1441802 t b;
#P newex 117 358 34 1441802 iter;
#P newex 175 416 26 1441802 t b;
#P newex 117 416 26 1441802 t b;
#P newex 267 358 26 1441802 t b;
#P newex 267 310 52 1441802 zl join;
#P newex 487 391 82 1441802 send bgcolor;
#P newex 117 391 358 1441802 route amorfo cabezona cecito patachula picoroco princesita;
#P newex 315 208 52 1441802 r index;
#P newex 315 242 88 1441802 js sort_index;
#P window setfont Times 10.;
#P comment 220 83 27 1310730 Start;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 204 126 62 1441802 jit.qball;
#B color 5;
#P toggle 204 82 15 0;
#P newex 204 102 58 1441802 metro 50;
#P window setfont "Sans Serif" 12.;
#P window linecount 2;
#P comment 120 454 382 196620 — each of these [triggers] get sent to an instance of the matrix to be written to.;
#P connect 9 0 19 0;
#P connect 19 0 18 0;
#P connect 9 0 13 0;
#P connect 13 0 7 0;
#P connect 7 0 11 0;
#P connect 7 1 12 0;
#P connect 20 0 2 0;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P connect 7 2 14 0;
#P fasten 3 0 9 0 209 173 272 173;
#P fasten 5 0 9 0 320 268 272 268;
#P connect 9 0 10 0;
#P connect 7 3 15 0;
#P connect 6 0 5 0;
#P connect 7 4 16 0;
#P connect 7 5 17 0;
#P fasten 10 0 8 0 272 382 492 382;
#P pop;


March 28, 2006 | 10:56 pm

This will be much faster using several instances of
jit.gl.videoplane. Trying to decompress and composite 6 videos in
realtime on the CPU will be relatively slow. Almost always faster on
the GPU.

-Joshua


March 30, 2006 | 2:06 am

Excellent – thanks for that. Definitely snappier.

I’m onto my next task, which is to figure out how to composite several of those images together (via slab, I was thinking…?) but still be able to move them around the screen individually. I’ve seen a couple instances in the examples of multiple movies being read into a jit.qt.slab, but I need to get at each image intermediately to position them.

I’ve tried this using both matrices and videoplanes – matrices are still slow (and I couldn’t figure out how to erase jit.gl.render properly after moving them around), and the videoplanes seem to require the same name as the videoplane that the jit.qt.slab is feeding into…meaning I can’t composite them together, but they rather overlay one another.

Feeling very uncertain that this is the right way to go about it…any help is, as always, greatly appreciated! Thanks!

Nasty sample patch:

max v2;
#N vpatcher 445 46 1418 932;
#P origin 0 -77;
#P window setfont "Sans Serif" 9.;
#P message 592 83 35 196617 1.333;
#P window linecount 2;
#P comment 632 78 238 196617 change x scale to match aspect ratio. e.g. typical 4:3 video would have an x scale of 1.333;
#P flonum 670 104 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 632 104 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 592 104 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 567 131 85 196617 pak scale 1. 1. 1.;
#P flonum 689 152 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 651 152 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 611 152 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 583 176 95 196617 pak position 0. 0. 0.;
#P newex 370 396 176 196617 jit.gl.videoplane foo @blend_enable 1;
#P message 8 523 100 196617 erase_color 1 1 1 1;
#P message 302 89 35 196617 1.333;
#P window linecount 2;
#P comment 342 84 238 196617 change x scale to match aspect ratio. e.g. typical 4:3 video would have an x scale of 1.333;
#P flonum 380 110 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 342 110 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 302 110 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 277 137 85 196617 pak scale 1. 1. 1.;
#P flonum 399 158 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 361 158 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 321 158 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 293 182 95 196617 pak position 0. 0. 0.;
#P newex 156 348 176 196617 jit.gl.videoplane foo @blend_enable 1;
#P message 799 255 79 196617 read dozer.mov;
#P message 704 255 28 196617 read;
#P message 769 255 27 196617 stop;
#P message 735 255 31 196617 start;
#P toggle 641 236 15 0;
#P newex 641 255 55 196617 metro 20;
#P newex 641 287 104 196617 jit.qt.movie 320 240;
#P comment 657 236 149 196617 • read a movie and start metro.;
#P newex 150 475 69 196617 jit.gl.slab foo;
#P newex 162 391 45 196617 r slabbo;
#P message 554 255 79 196617 read dozer.mov;
#P message 459 255 28 196617 read;
#P message 524 255 27 196617 stop;
#P message 490 255 31 196617 start;
#P toggle 396 236 15 0;
#P newex 396 255 55 196617 metro 20;
#P newex 396 287 104 196617 jit.qt.movie 320 240;
#P comment 412 236 149 196617 • read a movie and start metro.;
#P message 308 255 79 196617 read dozer.mov;
#P message 213 255 28 196617 read;
#P message 278 255 27 196617 stop;
#P message 244 255 31 196617 start;
#P toggle 150 236 15 0;
#P newex 150 255 55 196617 metro 20;
#P newex 150 287 104 196617 jit.qt.movie 320 240;
#P comment 166 236 149 196617 • read a movie and start metro.;
#P newex 150 432 69 196617 jit.gl.slab foo;
#P toggle 234 593 15 0;
#P message 234 611 45 196617 sync $1;
#P toggle 161 593 15 0;
#P newex 122 592 35 196617 sel 27;
#P message 161 611 68 196617 fullscreen $1;
#P newex 79 635 147 196617 jit.window foo @depthbuffer 0;
#P newex 77 592 40 196617 key;
#P user jit.fpsgui 62 380 60 196617 0;
#P number 85 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 40 253 15 0;
#P newex 40 279 55 196617 qmetro 20;
#P newex 40 329 66 196617 t b b b erase;
#P newex 40 666 80 196617 jit.gl.render foo;
#P newex 150 528 99 196617 jit.gl.videoplane foo;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P connect 52 0 1 0;
#P connect 2 3 1 0;
#P connect 2 0 1 0;
#P connect 2 1 6 0;
#P fasten 9 0 8 0 166 630 84 630;
#P fasten 12 0 8 0 239 630 84 630;
#P connect 5 0 3 1;
#P fasten 7 0 10 0 82 611 119 611 119 590 127 590;
#P connect 18 0 17 0;
#P connect 2 2 16 0;
#P fasten 21 0 16 0 218 281 155 281;
#P fasten 20 0 16 0 283 281 155 281;
#P fasten 19 0 16 0 249 281 155 281;
#P fasten 22 0 16 0 313 281 155 281;
#P connect 41 0 14 0;
#P connect 31 0 14 0;
#P connect 14 0 32 0;
#P connect 32 0 0 0;
#P connect 42 0 41 0;
#P connect 46 0 41 0;
#P connect 16 0 41 0;
#P fasten 10 0 11 0 127 610 158 610 158 590 166 590;
#P connect 11 0 9 0;
#P connect 53 0 14 1;
#P connect 13 0 12 0;
#P connect 51 0 47 0;
#P connect 47 0 46 1;
#P connect 43 0 42 1;
#P fasten 48 0 46 2 347 131 332 131;
#P fasten 44 0 42 2 366 177 354 177;
#P fasten 49 0 46 3 385 131 357 131;
#P connect 24 0 53 0;
#P connect 58 0 53 0;
#P connect 54 0 53 0;
#P fasten 45 0 42 3 404 177 382 177;
#P connect 26 0 25 0;
#P connect 2 2 24 0;
#P fasten 30 0 24 0 559 281 401 281;
#P fasten 27 0 24 0 495 281 401 281;
#P fasten 28 0 24 0 529 281 401 281;
#P fasten 29 0 24 0 464 281 401 281;
#P connect 63 0 59 0;
#P connect 59 0 58 1;
#P connect 55 0 54 1;
#P fasten 60 0 58 2 637 125 622 125;
#P fasten 56 0 54 2 656 171 644 171;
#P connect 36 0 35 0;
#P connect 2 2 34 0;
#P fasten 39 0 34 0 709 281 646 281;
#P fasten 38 0 34 0 774 281 646 281;
#P fasten 37 0 34 0 740 281 646 281;
#P fasten 40 0 34 0 804 281 646 281;
#P fasten 61 0 58 3 675 125 647 125;
#P fasten 57 0 54 3 694 171 672 171;
#P pop;



dan
March 30, 2006 | 2:58 pm

foo is not the name of the jit.gl objects, it’s the name of the render
context. Check out the Jitter tutorials on this subject. Try using a
videoplane for each QT movie. Your videoplanes will composite if you
start playing with the blend_mode attribute, e.g., send the following
to the inlet of a videoplane and play with the number boxes:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 278 295 100 196617 prepend blend_mode;
#P number 339 252 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 280 273 43 196617 pak 1 1;
#P number 280 250 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 0 0 1 0;
#P connect 1 0 3 0;
#P connect 2 0 1 1;
#P window clipboard copycount 4;

If your patch still isn’t doing what you want it to, think about your
render order. (I like to write it down on a piece of paper.) You want
to:

1. erase jit.gl.render
2. Do Stuff, e.g., draw videoplanes with movies on them, move them
around — again, check out the GL tutorials to learn how this works –
6. bang jit.gl.render to write the whole thing out to the render context

best,
dan


***
http://danwinckler.com
http://share.dj

http://gunshowimprov.com


March 30, 2006 | 3:55 pm

Thanks Dan – I think I’ve found a solution, thanks to your nudge towards playing with the blend_mode attribute. This obviates the need for the jit.qt.slab objects in my simple case.

I think there were several other issues in trying to use a videoplane before and after the jit.qt.slab (bad). I was indeed using a videoplane for each movie, as you suggested, but this setup of before and after the slabs was definitely my stumbling block.

Anyhow, thanks for the tip!

Liam


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