Open GL plane layering

Apr 3, 2006 at 8:48pm

Open GL plane layering

Hi,
I am trying to create a video using 3 sources:

1 – A background video (multi coloured)
2 – A video of a dancer to be viewed on top of the background (the dancer is solid white and the background solid black)
3 – A video of a fill effect to place inside the dancer (multi coloured and is in front of the background – hiding It)

So far I have been able to get the texture inside the dancer, and the dancer on top of the background, but not both at the same time.

I attempted this by creating three planes, each with a texture applied, and using the chromakey shader to delete the inside of the dancer.

Am I going about this the right way? I really do need this to be done in Open GL. Does anyone have any idea how I can compile all 3 at once?

Thanks

Andy

#25219
Apr 3, 2006 at 10:02pm

Can’t you use a pass filter to combine the 2 upper layers using jit.op?

#74051
Apr 3, 2006 at 10:13pm

Typically the common issues people have with this is related to:
depthbuffer enabled when it shouldn’t be, or render order. If you
post a demonstration patch with a detailed explanation of how it
should work, but isn’t, someone could probably offer further
assistance. Otherwise this is too vague. Also, as is recommended for
all reports, be sure to list platform, hardware, and software info.

-Joshua

#74052
Apr 3, 2006 at 10:56pm

Here is the code for the patch:

max v2;
#N vpatcher 8 44 2001 768;
#P origin -160 -166;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 49 109 100 196617 Fill Input here;
#P message 591 455 31 196617 0.07;
#P message 162 575 80 196617 dancertexture2;
#P newex 162 600 82 196617 prepend texture;
#P flonum 523 486 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 591 486 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 557 486 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 489 506 113 196617 pak position 0. 0. 0.;
#P flonum 523 486 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 591 486 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 557 486 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 489 506 113 196617 pak position 0. 0. 0.;
#P message 508 562 60 196617 background;
#P newex 509 594 82 196617 prepend texture;
#P newex 488 641 303 196617 jit.gl.gridshape foo @color 1 1 1 1 @shape plane @blend_enable 1;
#P message -12 67 46 196617 loadram;
#P message 320 514 14 196617 0;
#P message 286 514 14 196617 0;
#P newex 164 183 193 196617 jit.gl.texture foo @name dancertexture2;
#P message 354 514 31 196617 0.07;
#P flonum 286 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 354 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 320 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 252 554 113 196617 pak position 0. 0. 0.;
#P flonum 286 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 354 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 320 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 252 554 113 196617 pak position 0. 0. 0.;
#P newex 162 644 303 196617 jit.gl.gridshape foo @color 1 1 1 1 @shape plane @blend_enable 1;
#P newex -12 184 173 196617 jit.gl.texture foo @name background;
#P message 267 599 86 196617 shader dancerfill;
#P message 85 125 28 196617 read;
#P newex -12 159 105 196617 jit.qt.movie 886 708;
#P message 233 252 31 196617 1;
#P newex -22 45 48 196617 loadbang;
#P message 95 255 31 196617 0.26;
#P flonum 95 291 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 95 314 65 196617 param tol $1;
#P flonum 377 295 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 340 295 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 303 295 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 229 349 195 196617 pak param color 0. 0. 0. 0.;
#P flonum 164 291 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 164 313 79 196617 param mode $1;
#P hidden message 919 52 50 196617 name foo;
#P user jit.pwindow 1099 -71 888 710 1 1 0 0 1 0;
#X name foo;
#P message -22 314 113 196617 read co.chromakey.jxs;
#P message 207 120 28 196617 read;
#P toggle -12 105 15 0;
#P newex -12 126 55 196617 metro 20;
#P newex 164 160 105 196617 jit.qt.movie 400 576;
#P number 19 442 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex -26 468 55 196617 qmetro 20;
#P newex -26 545 55 196617 t b erase b;
#P newex -26 692 195 196617 jit.gl.render foo @erase_color 0. 1. 1. 1.;
#P newex 1 367 162 196617 jit.gl.shader foo @name dancerfill;
#B color 5;
#P comment 365 663 100 196617 FILL Mix;
#P comment 177 105 100 196617 Dancer Input here;
#P window setfont “Sans Serif” 20.;
#P window linecount 3;
#P comment 403 158 352 196628 needs some programming to add a video around/behind the dancer. How?;
#P fasten 10 0 6 0 -7 230 -21 230;
#P connect 6 0 5 0;
#P fasten 44 0 4 0 493 691 -21 691;
#P connect 5 0 4 0;
#P fasten 5 1 4 0 1 685 -21 685;
#P fasten 30 0 4 0 167 685 -21 685;
#P fasten 24 0 12 0 -17 437 -17 437;
#P connect 10 0 9 0;
#P fasten 9 0 26 0 -7 152 -7 152;
#P fasten 27 0 26 0 90 152 -7 152;
#P connect 43 0 26 0;
#P connect 26 0 29 0;
#P fasten 15 0 3 0 169 347 6 347;
#P fasten 21 0 3 0 100 347 6 347;
#P fasten 12 0 3 0 -17 347 6 347;
#P connect 17 0 3 0;
#P connect 7 0 6 1;
#P fasten 24 0 23 0 -17 240 100 240;
#P connect 23 0 22 0;
#P connect 22 0 21 0;
#P fasten 24 0 56 0 -17 91 167 91;
#P connect 56 0 55 0;
#P fasten 35 0 30 0 257 643 167 643;
#P connect 55 0 30 0;
#P fasten 28 0 30 0 272 619 167 619;
#P fasten 11 0 8 0 212 152 169 152;
#P fasten 43 0 8 0 -7 86 169 86;
#P fasten 9 0 8 0 -7 152 169 152;
#P fasten 8 0 40 0 169 180 169 180;
#P fasten 25 0 16 0 238 277 169 277;
#P connect 16 0 15 0;
#P fasten 24 0 25 0 -17 240 238 240;
#P fasten 24 0 28 0 -17 85 272 85;
#P fasten 24 0 41 0 -17 437 291 437;
#P connect 41 0 38 0;
#P connect 38 0 35 1;
#P fasten 34 0 31 1 291 551 291 551;
#P fasten 25 0 18 0 238 277 308 277;
#P connect 18 0 17 2;
#P fasten 24 0 42 0 -17 437 325 437;
#P connect 42 0 36 0;
#P connect 36 0 35 2;
#P fasten 32 0 31 2 325 551 325 551;
#P fasten 25 0 19 0 238 277 345 277;
#P connect 19 0 17 3;
#P fasten 24 0 39 0 -17 437 359 437;
#P connect 39 0 37 0;
#P connect 37 0 35 3;
#P fasten 33 0 31 3 359 551 359 551;
#P fasten 25 0 20 0 238 277 382 277;
#P connect 20 0 17 4;
#P connect 45 0 44 0;
#P connect 51 0 44 0;
#P fasten 24 0 46 0 -17 85 513 85;
#P connect 46 0 45 0;
#P fasten 50 0 47 1 528 503 528 503;
#P connect 54 0 51 1;
#P fasten 48 0 47 2 562 503 562 503;
#P connect 52 0 51 2;
#P fasten 24 0 57 0 -17 84 596 84;
#P connect 57 0 53 0;
#P fasten 49 0 47 3 596 503 596 503;
#P connect 53 0 51 3;
#P hidden fasten 24 0 14 0 -17 88 924 88;
#P connect 14 0 13 0;
#P pop;

The patch displays a “fill” movie inside the movie of a silhouetted dancer. This chromakey/shader part works. Obviously you’ll need to use some suitable video for the silhouetted dancer qt.movie object.

What I can’t do is keyout the resulting white area around the dancer, replacing it with a third “background” movie.

The same process could be done using the CPU by using two chromakey objects in series. The first object would key out the inside of the dancer, the second would keyout the area around the dancer.

But I need to use the GPU!

Hope that makes sense, cheers,

Andy

Mac G5, dual 2Ghz, 2Gb RAM, ATI Radeon 9600
OSX 10.4.5
Max 4.5.5
Jitter 1.5.2

#74053
Apr 3, 2006 at 11:22pm

I believe that your problem is solved if you specify @depth_enable 0,
and @automatic 0 for each jit.gl.gridshape object, and then bang in
sequence (back to front). This strategy is demonstrated by the
jit.gl.videoplane-xfade.pat example patch.

Hope this helps,
Joshua

#74054

You must be logged in to reply to this topic.