Forums > Jitter

jit.gl layering

July 22, 2009 | 6:18 pm

Hi

Having problems getting layering to work in jit.gl. I have three sketches I want to layer one in front of the other (each masking the one behind). The middle sketch also has 2d text on it. I can’t seem to get all three correctly layering and keep the text drawing correctly. Am I supposed to send each a bang starting from the furthest back or is this not needed?

I know it’s a matter of it being the right combination of depth_enable 1 on the objects and depthbuffer 1
on the jit.window (and maybe automatic 1 in there somewhere) but I just can’t find the correct combination. Also popping between window and fullscreen seems to always look different so this is proving very difficult to test. Any help much appreciated.

Garrett

max v2;
#N vpatcher 245 68 1123 927;
#P origin -37 -158;
#P window setfont "Gill Sans" 10.;
#P comment 566 516 13 278003722 Z;
#B color 14;
#P comment 566 497 14 278003722 Y;
#B color 14;
#P comment 566 478 14 278003722 X;
#B color 14;
#P comment 527 465 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 526 515 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 526 496 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 526 477 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 526 534 100 196617 pak position 0. 0. 0.;
#P toggle 195 75 15 0;
#P message 195 93 55 196617 floating $1;
#P toggle 122 75 15 0;
#P newex 83 74 35 196617 sel 27;
#P message 122 93 68 196617 fullscreen $1;
#P newex 40 117 380 196617 jit.window foo @rect 10 50 810 650 @idlemouse 1 @fsmenubar 0 @depthbuffer 1;
#P newex 38 74 40 196617 key;
#P newex 454 246 40 196617 s line1;
#P message 454 227 82 196617 text hello world;
#P newex 454 534 69 196617 r linesrender;
#P message 454 556 117 196617 reset , drawobject line1;
#P newex 454 603 241 196617 jit.gl.sketch foo @depth_enable 1 @position 0. 0. 0.;
#B color 5;
#P newex 454 205 69 196617 r linesrender;
#P window setfont "Gill Sans" 10.;
#P comment 507 373 13 278003722 Z;
#B color 14;
#P comment 507 354 14 278003722 Y;
#B color 14;
#P comment 507 335 14 278003722 X;
#B color 14;
#P comment 468 322 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 467 372 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 467 353 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 467 334 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 466 395 100 196617 pak position 0. 0. 0.;
#P newex 454 280 40 196617 r line1;
#P newex 454 418 343 196617 jit.gl.text2d foo @name line1 @color 1. 1. 1. 1. @interp 1 @screenmode 0;
#B color 5;
#P newex 135 342 71 196617 s maskrender;
#P newex 179 299 68 196617 s backrender;
#P newex 153 321 69 196617 s linesrender;
#P user jit.fpsgui 58 345 60 196617 0;
#P newex 44 220 43 196617 jit.qball;
#P number 89 171 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 44 171 15 0;
#P newex 44 197 55 196617 metro 20;
#P newex 44 251 81 196617 t b b b b b erase;
#P newex 44 441 195 196617 jit.gl.render foo @erase_color 1. 0. 0. 1.;
#P newex 458 713 71 196617 r maskrender;
#P newex 453 117 68 196617 r backrender;
#P window setfont "Gill Sans" 10.;
#P comment 573 692 13 278003722 Z;
#B color 14;
#P comment 573 673 14 278003722 Y;
#B color 14;
#P comment 573 654 14 278003722 X;
#B color 14;
#P comment 534 641 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 533 691 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 533 672 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 533 653 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 532 712 100 196617 pak position 0. 0. 0.;
#P window setfont "Gill Sans" 10.;
#P comment 565 97 13 278003722 Z;
#B color 14;
#P comment 565 78 14 278003722 Y;
#B color 14;
#P comment 565 59 14 278003722 X;
#B color 14;
#P comment 526 46 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 525 96 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 525 77 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 525 58 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 524 116 100 196617 pak position 0. 0. 0.;
#P newex 453 164 246 196617 jit.gl.sketch foo @depth_enable 1 @position 0. 0. -1.;
#B color 5;
#P message 453 143 383 196617 reset , glcolor 0.18 0.8 0.8 , quad -2.5 0.2 0. 2.3 0.2 0. 2.3 -0.15 0. -2.5 -0.15 0.;
#P window linecount 2;
#P message 459 737 304 196617 reset , glcolor 0. 0. 0. , quad -1.1 0.8 0. 1.1 0.8 0. 1.1 0.1 0. -1.1 0.1 0. , quad -1.1 -0.1 0. 1.1 -0.1 0. 1.1 -0.8 0. -1.1 -0.8 0.;
#P window linecount 1;
#P newex 459 772 241 196617 jit.gl.sketch foo @depth_enable 1 @position 0. 0. 1.;
#B color 5;
#P fasten 53 0 49 0 200 112 45 112;
#P fasten 50 0 49 0 127 112 45 112;
#P connect 25 0 24 0;
#P connect 24 0 27 0;
#P connect 27 0 23 0;
#P connect 23 0 22 0;
#P fasten 23 5 22 0 119 420 49 420;
#P connect 23 1 28 0;
#P fasten 48 0 51 0 43 93 80 93 80 72 88 72;
#P connect 26 0 24 1;
#P fasten 51 0 52 0 88 92 119 92 119 72 127 72;
#P connect 52 0 50 0;
#P connect 23 2 31 0;
#P connect 23 3 29 0;
#P connect 23 4 30 0;
#P connect 54 0 53 0;
#P connect 20 0 2 0;
#P connect 2 0 3 0;
#P connect 4 0 3 0;
#P connect 42 0 46 0;
#P connect 46 0 47 0;
#P connect 34 0 32 0;
#P connect 33 0 32 0;
#P connect 45 0 44 0;
#P connect 55 0 43 0;
#P connect 44 0 43 0;
#P connect 21 0 1 0;
#P connect 1 0 0 0;
#P connect 12 0 0 0;
#P connect 35 0 34 1;
#P connect 36 0 34 2;
#P connect 5 0 4 1;
#P connect 37 0 34 3;
#P connect 56 0 55 1;
#P connect 13 0 12 1;
#P connect 6 0 4 2;
#P connect 57 0 55 2;
#P connect 14 0 12 2;
#P connect 7 0 4 3;
#P connect 58 0 55 3;
#P connect 15 0 12 3;
#P pop;


July 22, 2009 | 6:56 pm

Hi Garrett,

Having a little trouble understanding the final image you’re going for, but here are some thoughts:

Try setting the depth_enable 0, and playing around with the layer attribute instead (layer 0, layer 1, etc.).

Look into blend modes (send blend_mode # #) to your sketch objects, and make sure blend_enable is set to 1.

If playing around with those fails you could try looking into jit.gl.slab techniques, although they can be a little tough to get used to at first.

Hope that helps – best of luck

-C


July 22, 2009 | 7:20 pm

Hi

Sorry yes so frustrated with it that I lost the ability to describe/type it correctly but spot on you just solved all of the issues in 20 minutes uhhhh Smile

Thanks very much, completely forgot about the @layer attribute, and I had been at this so long I was beginning to give up. Setting the blue sketch to @layer 0, the text sketch to @layer 1 and the black sketch to @layer 2 works – blue is at the back, text in the middle and black is at the front so you can see through the space. I’ve reattached the working version.

I am very confused however about the use of the @position x y z attribute on gl objects, the z coordinate when drawing a gl shape i.e. quad -2.5 0.2 0. 2.3 0.2 0. 2.3 -0.15 0. -2.5 -0.15 0., and now the @layer attribute on gl objects. In a situation like this (layering things along the z-axis) when do you use which?

Garrett

max v2;
#N vpatcher 204 90 1082 949;
#P origin -37 -158;
#P window setfont "Gill Sans" 10.;
#P comment 566 516 13 278003722 Z;
#B color 14;
#P comment 566 497 14 278003722 Y;
#B color 14;
#P comment 566 478 14 278003722 X;
#B color 14;
#P comment 527 465 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 526 515 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 526 496 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 526 477 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 526 534 100 196617 pak position 0. 0. 0.;
#P toggle 195 75 15 0;
#P message 195 93 55 196617 floating $1;
#P toggle 122 75 15 0;
#P newex 83 74 35 196617 sel 27;
#P message 122 93 68 196617 fullscreen $1;
#P newex 40 117 380 196617 jit.window foo @rect 10 50 810 650 @idlemouse 1 @fsmenubar 0 @depthbuffer 0;
#P newex 38 74 40 196617 key;
#P newex 454 246 40 196617 s line1;
#P message 454 227 82 196617 text hello world;
#P newex 454 534 69 196617 r linesrender;
#P message 454 556 117 196617 reset , drawobject line1;
#P newex 454 603 203 196617 jit.gl.sketch foo @depth_enable 0 @layer 1;
#B color 5;
#P newex 454 205 69 196617 r linesrender;
#P window setfont "Gill Sans" 10.;
#P comment 507 373 13 278003722 Z;
#B color 14;
#P comment 507 354 14 278003722 Y;
#B color 14;
#P comment 507 335 14 278003722 X;
#B color 14;
#P comment 468 322 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 467 372 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 467 353 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 467 334 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 466 395 100 196617 pak position 0. 0. 0.;
#P newex 454 280 40 196617 r line1;
#P newex 454 418 348 196617 jit.gl.text2d foo @name line1 @depth_enable 0 @color 1. 1. 1. 1. @interp 1;
#B color 5;
#P newex 135 342 71 196617 s maskrender;
#P newex 179 299 68 196617 s backrender;
#P newex 153 321 69 196617 s linesrender;
#P user jit.fpsgui 58 345 60 196617 0;
#P newex 44 220 43 196617 jit.qball;
#P number 89 171 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 44 171 15 0;
#P newex 44 197 55 196617 metro 20;
#P newex 44 251 81 196617 t b b b b b erase;
#P newex 44 441 195 196617 jit.gl.render foo @erase_color 1. 0. 0. 1.;
#P newex 458 713 71 196617 r maskrender;
#P newex 453 117 68 196617 r backrender;
#P window setfont "Gill Sans" 10.;
#P comment 573 692 13 278003722 Z;
#B color 14;
#P comment 573 673 14 278003722 Y;
#B color 14;
#P comment 573 654 14 278003722 X;
#B color 14;
#P comment 534 641 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 533 691 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 533 672 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 533 653 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 532 712 100 196617 pak position 0. 0. 0.;
#P window setfont "Gill Sans" 10.;
#P comment 565 97 13 278003722 Z;
#B color 14;
#P comment 565 78 14 278003722 Y;
#B color 14;
#P comment 565 59 14 278003722 X;
#B color 14;
#P comment 526 46 46 278003722 Position;
#B color 14;
#P window setfont "Sans Serif" 9.;
#P flonum 525 96 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 525 77 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 525 58 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 524 116 100 196617 pak position 0. 0. 0.;
#P newex 453 164 203 196617 jit.gl.sketch foo @depth_enable 0 @layer 0;
#B color 5;
#P message 453 143 383 196617 reset , glcolor 0.18 0.8 0.8 , quad -2.5 0.2 0. 2.3 0.2 0. 2.3 -0.15 0. -2.5 -0.15 0.;
#P window linecount 2;
#P message 459 737 304 196617 reset , glcolor 0. 0. 0. , quad -1.1 0.8 0. 1.1 0.8 0. 1.1 0.1 0. -1.1 0.1 0. , quad -1.1 -0.1 0. 1.1 -0.1 0. 1.1 -0.8 0. -1.1 -0.8 0.;
#P window linecount 1;
#P newex 459 772 203 196617 jit.gl.sketch foo @depth_enable 0 @layer 2;
#B color 5;
#P fasten 50 0 49 0 127 112 45 112;
#P fasten 53 0 49 0 200 112 45 112;
#P connect 25 0 24 0;
#P connect 24 0 27 0;
#P connect 27 0 23 0;
#P connect 23 0 22 0;
#P fasten 23 5 22 0 119 420 49 420;
#P connect 23 1 28 0;
#P fasten 48 0 51 0 43 93 80 93 80 72 88 72;
#P connect 26 0 24 1;
#P fasten 51 0 52 0 88 92 119 92 119 72 127 72;
#P connect 52 0 50 0;
#P connect 23 2 31 0;
#P connect 23 3 29 0;
#P connect 23 4 30 0;
#P connect 54 0 53 0;
#P connect 20 0 2 0;
#P connect 4 0 3 0;
#P connect 2 0 3 0;
#P connect 42 0 46 0;
#P connect 46 0 47 0;
#P connect 34 0 32 0;
#P connect 33 0 32 0;
#P connect 45 0 44 0;
#P connect 44 0 43 0;
#P connect 55 0 43 0;
#P connect 21 0 1 0;
#P connect 12 0 0 0;
#P connect 1 0 0 0;
#P connect 35 0 34 1;
#P connect 36 0 34 2;
#P connect 5 0 4 1;
#P connect 37 0 34 3;
#P connect 56 0 55 1;
#P connect 13 0 12 1;
#P connect 6 0 4 2;
#P connect 57 0 55 2;
#P connect 14 0 12 2;
#P connect 7 0 4 3;
#P connect 58 0 55 3;
#P connect 15 0 12 3;
#P pop;


July 22, 2009 | 7:28 pm

Glad it worked!

Yeah, I too am a little confused by the @layer attribute when used in conjunction with z-space. From the OB3D docs though:

@layer: Object layer number (default = 0) When in automatic mode, the layer number determines he rendering order (low to high). Objects in the same layer have no guarantee which will be rendered first."

So it seems like it’s less of a conventional "layer" (which makes me think top/bottom) and more of a rendering order (timing).

hmmm….


July 22, 2009 | 7:33 pm

yes rendering order is how I’d read that quote too, where are these OB3D docs you referred too? – I should have a look. Thanks.

Garrett


July 22, 2009 | 8:20 pm

OB3D is the generic object that many of jitter’s opengl objects extend. This means that while the gridshape has it’s own unique attributes/properties, it also has generic properties that it inherits from OB3D. jit.gl.sketch, for example, also extends OB3D.

When you view the reference of an object like jit.gl.gridshape, you’ll see a link to the OB3D reference there as well.


July 22, 2009 | 8:40 pm

ah those jitter help pages, yes I know about those. Thanks.

Garrett


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