Alpha channel renders differently to jit.window and jit.matrix

Dec 16, 2007 at 12:40am

Alpha channel renders differently to jit.window and jit.matrix

Can someone explain why this patch does not work as expected? I am using an alpha channel to make 2 jit.gl.videoplanes transparent. This works fine when rendering to a jit.window. But if the same patch renders to a jit.matrix, no alpha transparency is visible. Why?

Thanks in advance.

max v2;
#N vpatcher 449 44 1769 816;
#P window setfont “Sans Serif” 9.;
#P comment 461 217 102 196617 render to matrix — alpha doesn’t work;
#P comment 364 219 91 196617 render to window — alpha works;
#P user jit.pwindow 487 494 322 242 0 0 0 0 1 0;
#P window linecount 1;
#P newex 488 471 150 196617 jit.matrix BBB 4 char 320 240;
#P message 461 256 63 196617 drawto BBB;
#P message 386 256 66 196617 drawto AAA;
#P newex 144 292 143 196617 jit.matrix @planemap 2 1 2 3;
#P newex 186 378 274 196617 jit.gl.videoplane AAA @position 0. 0. 0.5 @blend_enable 1;
#P newex 153 472 129 196617 jit.window AAA @interp 1;
#P message 180 234 81 196617 read wheel.mov;
#P newex 144 256 63 196617 jit.qt.movie;
#P toggle 288 116 15 0;
#P newex 586 251 50 196617 t b erase;
#P newex 288 141 57 196617 qmetro 20;
#P newex 586 374 202 196617 jit.gl.render AAA @erase_color 0. 0. 0. 1.;
#P newex 144 335 265 196617 jit.gl.videoplane AAA @position 0. 0. 0. @blend_enable 1;
#P window linecount 2;
#P comment 25 292 138 196617 creates an alpha channel from green;
#P window setfont “Sans Serif” 12.;
#P comment 147 39 488 196620 when videoplanes render to jit.window , the alpha channel works as expected. when rendering to a jit.matrix , alpha channel no longer works. hmmm why?;
#P fasten 4 0 7 0 293 203 149 203;
#P fasten 8 0 7 0 185 252 149 252;
#P connect 7 0 11 0;
#P connect 13 0 2 0;
#P connect 12 0 2 0;
#P connect 11 0 2 0;
#P connect 13 0 10 0;
#P connect 12 0 10 0;
#P connect 11 0 10 0;
#P connect 6 0 4 0;
#P connect 3 0 14 0;
#P connect 14 0 15 0;
#P fasten 4 0 5 0 293 203 591 203;
#P connect 13 0 3 0;
#P connect 12 0 3 0;
#P connect 5 1 3 0;
#P connect 5 0 3 0;
#P pop;

#35029
Dec 16, 2007 at 12:49am

Here you go. Just name the jit.pwindow.

Zachary

max v2;
#N vpatcher 445 44 1270 776;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 295 411 53 131137545 name BBB;
#P window setfont “Sans Serif” 12.;
#P comment 350 412 183 131137548 name the jit.pwindow BBB;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 445 213 102 131137545 render to matrix — alpha doesn’t work;
#P comment 348 215 91 131137545 render to window — alpha works;
#P user jit.pwindow 294 437 322 242 0 0 0 0 1 0;
#X name BBB;
#P window linecount 1;
#P message 445 252 63 131137545 drawto BBB;
#P message 370 252 66 131137545 drawto AAA;
#P newex 128 288 128 131137545 jit.matrix @planemap 2 1 2 3;
#P newex 170 374 274 131137545 jit.gl.videoplane AAA @position 0. 0. 0.5 @blend_enable 1;
#P message 164 230 81 131137545 read wheel.mov;
#P newex 128 252 63 131137545 jit.qt.movie;
#P toggle 272 112 15 0;
#P newex 570 247 50 131137545 t b erase;
#P newex 272 137 57 131137545 qmetro 20;
#P newex 570 370 202 131137545 jit.gl.render AAA @erase_color 0. 0. 0. 1.;
#P newex 128 331 265 131137545 jit.gl.videoplane AAA @position 0. 0. 0. @blend_enable 1;
#P window linecount 2;
#P comment 9 288 138 131137545 creates an alpha channel from green;
#P window setfont “Sans Serif” 12.;
#P comment 131 35 488 131137548 when videoplanes render to jit.window , the alpha channel works as expected. when rendering to a jit.matrix , alpha channel no longer works. hmmm why?;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 131 414 129 131137545 jit.window AAA @interp 1;
#P fasten 5 0 8 0 277 199 133 199;
#P fasten 9 0 8 0 169 248 133 248;
#P connect 8 0 11 0;
#P connect 13 0 3 0;
#P connect 12 0 3 0;
#P connect 11 0 3 0;
#P connect 13 0 10 0;
#P connect 12 0 10 0;
#P connect 11 0 10 0;
#P connect 7 0 5 0;
#P connect 18 0 14 0;
#P fasten 5 0 6 0 277 199 575 199;
#P connect 13 0 4 0;
#P connect 12 0 4 0;
#P connect 6 0 4 0;
#P connect 6 1 4 0;
#P pop;

#118905
Dec 16, 2007 at 2:01pm

Zachary, thank you, you answered my question perfectly. However… I asked the wrong question! Somehow it seems I sent a wrong version of patch.

The problem I am having is that layered alpha-channel stuff disappears when rendering to a jit.matrix (instead of a jit.window or jit.pwindow).

Thanks in advance

max v2;
#N vpatcher 445 44 1270 776;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 459 401 150 196617 jit.matrix BBB 4 char 320 240;
#P window linecount 2;
#P comment 445 213 102 196617 render to matrix — alpha doesn’t work;
#P comment 348 215 91 196617 render to window — alpha works;
#P user jit.pwindow 458 432 322 242 0 0 0 0 1 0;
#X name CCC;
#P window linecount 1;
#P message 445 252 63 196617 drawto BBB;
#P message 370 252 66 196617 drawto AAA;
#P newex 128 288 147 196617 jit.matrix @planemap 2 1 2 3;
#P newex 170 374 274 196617 jit.gl.videoplane AAA @position 0. 0. 0.5 @blend_enable 1;
#P message 164 230 81 196617 read wheel.mov;
#P newex 128 252 63 196617 jit.qt.movie;
#P toggle 272 112 15 0;
#P newex 570 247 50 196617 t b erase;
#P newex 272 137 57 196617 qmetro 20;
#P newex 570 370 202 196617 jit.gl.render AAA @erase_color 0. 0. 0. 1.;
#P newex 128 331 265 196617 jit.gl.videoplane AAA @position 0. 0. 0. @blend_enable 1;
#P window linecount 2;
#P comment 9 288 138 196617 creates an alpha channel from green;
#P window setfont “Sans Serif” 12.;
#P comment 131 35 488 196620 when videoplanes render to jit.window , the alpha channel works as expected. when rendering to a jit.matrix , alpha channel no longer works. hmmm why?;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 131 414 129 196617 jit.window AAA @interp 1;
#P window setfont “Sans Serif” 14.;
#P window linecount 3;
#P comment 340 527 100 196622 only one layer visible here — why?;
#P fasten 6 0 9 0 277 199 133 199;
#P fasten 10 0 9 0 169 248 133 248;
#P connect 9 0 12 0;
#P connect 13 0 4 0;
#P connect 14 0 4 0;
#P connect 12 0 4 0;
#P connect 13 0 11 0;
#P connect 14 0 11 0;
#P connect 12 0 11 0;
#P connect 8 0 6 0;
#P connect 6 0 18 0;
#P connect 18 0 15 0;
#P fasten 6 0 7 0 277 199 575 199;
#P connect 7 1 5 0;
#P connect 7 0 5 0;
#P connect 13 0 5 0;
#P connect 14 0 5 0;
#P pop;

#118906
Dec 16, 2007 at 2:20pm

Here you go. It’s a rendering order issue.

Zachary

max v2;
#N vpatcher 10 59 905 773;
#P window setfont “Sans Serif” 14.;
#P window linecount 2;
#P comment 151 507 324 131137550 A: It looks like a rendering order issue. Render the smaller videoplane “on top/after” the other one;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 464 266 27 131137545 t l l;
#P newex 478 393 150 131137545 jit.matrix BBB 4 char 320 240;
#P window linecount 2;
#P comment 464 205 102 131137545 render to matrix — alpha doesn’t work;
#P comment 367 207 91 131137545 render to window — alpha works;
#P user jit.pwindow 477 424 322 242 0 0 0 0 1 0;
#X name CCC;
#P window linecount 1;
#P message 464 244 63 131137545 drawto BBB;
#P message 389 244 66 131137545 drawto AAA;
#P newex 147 280 147 131137545 jit.matrix @planemap 2 1 2 3;
#P newex 116 354 274 131137545 jit.gl.videoplane AAA @position 0. 0. 0.5 @blend_enable 1;
#P message 183 222 81 131137545 read wheel.mov;
#P newex 147 244 63 131137545 jit.qt.movie;
#P toggle 291 104 15 0;
#P newex 589 239 50 131137545 t b erase;
#P newex 291 129 57 131137545 qmetro 20;
#P newex 589 362 202 131137545 jit.gl.render AAA @erase_color 0. 0. 0. 1.;
#P newex 147 323 265 131137545 jit.gl.videoplane AAA @position 0. 0. 0. @blend_enable 1;
#P window linecount 2;
#P comment 4 281 138 131137545 creates an alpha channel from green;
#P window setfont “Sans Serif” 12.;
#P comment 150 27 488 131137548 when videoplanes render to jit.window , the alpha channel works as expected. when rendering to a jit.matrix , alpha channel no longer works. hmmm why?;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 150 406 129 131137545 jit.window AAA @interp 1;
#P window setfont “Sans Serif” 14.;
#P comment 230 481 245 131137550 Q: only one layer visible here — why?;
#P connect 13 0 11 0;
#P connect 12 0 11 0;
#P fasten 19 0 11 0 469 346 121 346;
#P fasten 6 0 9 0 296 191 152 191;
#P fasten 10 0 9 0 188 240 152 240;
#P connect 9 0 12 0;
#P connect 13 0 4 0;
#P connect 12 0 4 0;
#P fasten 19 1 4 0 486 314 152 314;
#P connect 8 0 6 0;
#P connect 14 0 19 0;
#P connect 6 0 18 0;
#P connect 18 0 15 0;
#P fasten 6 0 7 0 296 191 594 191;
#P connect 14 0 5 0;
#P connect 13 0 5 0;
#P connect 7 0 5 0;
#P connect 7 1 5 0;
#P pop;

#118907
Dec 16, 2007 at 3:40pm

Zachary, thanks for your help. I used “automatic 0″, and if the videoplanes are banged in the correct order, the image appears correctly.

However, I’m still kind of confused as to why this should be. If rendering to a jit.window or jit.pwindow, the alpha blending works, no matter what the order of the planes. But when rendering to a jit.matrix, the order becomes important. Why?

For example, if I reverse the order of rendering of the videoplanes, the jit.window still displays image correctly, but the jit.matrix does not.

Thanks

#118908
Dec 16, 2007 at 4:22pm

Can you post your patch?

#118909
Dec 16, 2007 at 8:25pm

Thanks — I think this shows the problem

max v2;
#N vpatcher 361 113 1625 917;
#P window setfont “Sans Serif” 9.;
#P window linecount 3;
#P comment 688 144 175 196617 — order does not matter when rendering to jit.window , but matters when rendering to jit.matrix;
#P window setfont “Sans Serif” 14.;
#P window linecount 1;
#P comment 490 95 274 196622 toggle to reverse rendering order;
#P toggle 623 140 45 0;
#P window setfont “Sans Serif” 9.;
#P newex 665 283 30 196617 t b b;
#P newex 622 279 30 196617 t b b;
#P user gswitch2 623 239 39 32 0 0;
#P window setfont “Sans Serif” 14.;
#P window linecount 4;
#P comment 46 582 379 196622 Q: …have tried to resolve ordering with “automatic 0″ message , but still not working. also — even if layers out of order , both should show because they are transparent….?;
#P window linecount 2;
#P comment 49 525 373 196622 A: It looks like a rendering order issue. Render the smaller videoplane “on top/after” the other one;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 464 266 27 196617 t l l;
#P newex 465 404 150 196617 jit.matrix BBB 4 char 320 240;
#P window linecount 2;
#P comment 464 205 102 196617 render to matrix — alpha doesn’t work;
#P comment 367 207 91 196617 render to window — alpha works;
#P user jit.pwindow 464 447 322 242 0 0 0 0 1 0;
#X name CCC;
#P window linecount 1;
#P message 464 244 63 196617 drawto BBB;
#P message 389 244 66 196617 drawto AAA;
#P newex 147 280 147 196617 jit.matrix @planemap 2 1 2 3;
#P newex 91 378 335 196617 jit.gl.videoplane AAA @position 0. 0. 0.5 @blend_enable 1 @automatic 0;
#P message 183 222 81 196617 read wheel.mov;
#P newex 147 244 63 196617 jit.qt.movie;
#P toggle 291 104 15 0;
#P newex 589 208 136 196617 t b b erase;
#P newex 291 129 57 196617 qmetro 20;
#P newex 589 377 202 196617 jit.gl.render AAA @erase_color 0. 0. 0. 1.;
#P newex 147 324 329 196617 jit.gl.videoplane AAA @position 0. 0. 0. @blend_enable 1 @automatic 0;
#P window linecount 2;
#P comment 4 281 138 196617 creates an alpha channel from green;
#P window setfont “Sans Serif” 12.;
#P comment 150 27 488 196620 when videoplanes render to jit.window , the alpha channel works as expected. when rendering to a jit.matrix , alpha channel no longer works. hmmm why?;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 150 406 129 196617 jit.window AAA @interp 1;
#P window setfont “Sans Serif” 14.;
#P comment 128 499 274 196622 Q: only one layer visible here — why?;
#P connect 13 0 11 0;
#P fasten 24 1 11 0 690 365 96 365;
#P fasten 23 0 11 0 627 364 96 364;
#P connect 12 0 11 0;
#P fasten 19 0 11 0 469 366 96 366;
#P fasten 6 0 9 0 296 191 152 191;
#P fasten 10 0 9 0 188 240 152 240;
#P connect 9 0 12 0;
#P connect 13 0 4 0;
#P fasten 24 0 4 0 670 316 152 316;
#P fasten 23 1 4 0 647 311 152 311;
#P connect 12 0 4 0;
#P fasten 19 1 4 0 486 314 152 314;
#P connect 8 0 6 0;
#P connect 14 0 19 0;
#P connect 6 0 18 0;
#P connect 18 0 15 0;
#P fasten 6 0 7 0 296 191 594 191;
#P connect 14 0 5 0;
#P connect 13 0 5 0;
#P fasten 7 2 5 0 720 232 594 232;
#P connect 7 0 5 0;
#P connect 22 0 23 0;
#P connect 25 0 22 0;
#P connect 7 1 22 1;
#P connect 22 1 24 0;
#P pop;

#118910
Dec 16, 2007 at 9:04pm

On Dec 16, 2007, at 12:25 PM, retinalia wrote:

> Thanks — I think this shows the problem

Didn’t look at patch, but I’d double check to make sure that
@depth_enable 0 has been set for blending. Otherwise this can be
subject to depth buffer testing. For more info on that, please see
the OpenGL redbook and our forum archives.

-Joshua

#118911
Dec 16, 2007 at 9:23pm

The basic idea when dealing with transparency in GL: if you want what is closest to the camera to render transparently and display what is behind it, you must render that front-most object after the other one. If you set the jit.window @depthbuffer 1 you’ll get the same behavior as when you render to matrix. Play around with this to see what I mean. Move the videoplanes around on the z axis, adjust their transparencies individually, and toggle the rendering order.

Another way to do this is to use the @layer attribute. set your objects to @automatic 1 and give the videoplane that is closest to the camera the higher layer number (i.e. @layer 1).

Zachary

max v2;
#N vpatcher 10 59 1061 839;
#P window setfont “Sans Serif” 14.;
#P window linecount 1;
#P comment 290 411 109 131137550 @depthbuffer 1;
#P window setfont Geneva 9.;
#P flonum 99 276 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 3 301 107 131137545 pak color 0.5 0.5 0.5 1.;
#P window setfont Geneva 9.;
#P flonum 293 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 197 228 107 131137545 pak color 0.5 0.5 0.5 1.;
#P window setfont Geneva 9.;
#P flonum 388 204 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 307 228 93 131137545 pak position 0. 0. 0.;
#P window setfont Geneva 9.;
#P flonum 194 276 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 113 302 93 131137545 pak position 0. 0. 0.;
#P window setfont “Sans Serif” 14.;
#P comment 736 52 274 131137550 toggle to reverse rendering order;
#P toggle 825 84 45 0;
#P window setfont “Sans Serif” 9.;
#P newex 867 227 30 131137545 t b b;
#P newex 824 223 30 131137545 t b b;
#P user gswitch2 825 183 39 32 1 0;
#P newex 666 210 27 131137545 t l l;
#P newex 512 374 150 131137545 jit.matrix BBB 4 char 320 240;
#P window linecount 2;
#P comment 666 149 102 131137545 render to matrix — alpha doesn’t work;
#P comment 569 151 91 131137545 render to window — alpha works;
#P user jit.pwindow 511 417 322 242 0 0 0 0 1 0;
#X name CCC;
#P window linecount 1;
#P message 666 188 63 131137545 drawto BBB;
#P message 591 188 66 131137545 drawto AAA;
#P newex 113 347 317 131137545 jit.gl.videoplane AAA @position -0.5 0. -1. @blend_enable 1 @automatic 0;
#P message 385 139 81 131137545 read wheel.mov;
#P newex 349 161 63 131137545 jit.qt.movie;
#P toggle 493 48 15 0;
#P newex 791 152 136 131137545 t b b erase;
#P newex 493 73 57 131137545 qmetro 20;
#P newex 765 284 202 131137545 jit.gl.render AAA @erase_color 0. 0. 0. 1.;
#P newex 307 268 311 131137545 jit.gl.videoplane AAA @position 0.2 0. 0. @blend_enable 1 @automatic 0;
#P newex 276 390 137 131137545 jit.window AAA @depthbuffer 1;
#P connect 28 0 27 4;
#P connect 9 0 8 0;
#P fasten 6 0 8 0 354 328 118 328;
#P fasten 18 1 8 0 892 335 118 335;
#P fasten 17 0 8 0 829 334 118 334;
#P fasten 15 0 8 0 671 336 118 336;
#P connect 21 0 8 0;
#P connect 27 0 8 0;
#P connect 22 0 21 3;
#P connect 26 0 25 4;
#P connect 9 0 1 0;
#P fasten 6 0 1 0 354 259 312 259;
#P connect 25 0 1 0;
#P connect 23 0 1 0;
#P fasten 15 1 1 0 688 258 312 258;
#P fasten 17 1 1 0 849 255 312 255;
#P fasten 18 0 1 0 872 260 312 260;
#P fasten 3 0 6 0 498 135 354 135;
#P fasten 7 0 6 0 390 157 354 157;
#P connect 24 0 23 3;
#P connect 5 0 3 0;
#P connect 3 0 14 0;
#P connect 14 0 11 0;
#P connect 10 0 15 0;
#P connect 10 0 2 0;
#P connect 9 0 2 0;
#P connect 4 0 2 0;
#P fasten 4 2 2 0 922 176 770 176;
#P fasten 3 0 4 0 498 135 796 135;
#P connect 16 0 17 0;
#P connect 19 0 16 0;
#P connect 4 1 16 1;
#P connect 16 1 18 0;
#P pop;

#118912

You must be logged in to reply to this topic.