lighting 2 objects with gl.sketch, obscuring 1 (Hidden-Surface Removal)

Apr 6, 2009 at 5:19pm

lighting 2 objects with gl.sketch, obscuring 1 (Hidden-Surface Removal)

Perhaps I am missing something very simple, but searching the forum and checking the redbook has not solved it.

2 gridshapes are directionally lit by gl.sketch. one object is in front of the other. one should appear eclipsed by the other, but they are both lit the same. i thought this could be dependent on the drawing order of the objects in the gl.sketch command list; however, it seems not to matter where in the command list they are placed. i tried gldisable depth_test, no luck…blendmodes, no luck.

below is my gl.sketch command list. a patch can be provided, but it is perhaps easier to add a second gridshape to the advanced lighting patch included with jitter’s release.

i am sure the answer is simple. thanks for the attention,

ryan

drawobject subject 0,
drawobject obscured_subject 0,
gldisable color_material,
glmaterial front ambient_and_diffuse 0.5 0.5 0.5 1.,
glmaterial front specular 1. 1. 1. 1.,
glmaterial front emission 0. 0. 0. 1.,
glmaterial front shininess 12.,
glmaterial back ambient_and_diffuse 0.25 0.25 0.25 1.,
glmaterial back specular 0.568862 0.568862 0.568862 1.,
glmaterial back emission 0. 0. 0. 1.,
glmaterial back shininess 12.,
gllightmodel ambient 0.1 0.1 0.1 1.,
gllightmodel two_side 1,
gllightmodel local_viewer 1,
gllight light0 ambient 1. 1. 1. 1.,
gllight light0 diffuse 1. 1. 1. 1.,
gllight light0 specular 0. 0. 0. 1.,
gllight light0 position 5.4 -.7 -1.2 1.,
gllight light0 spot_cutoff 42.,
gllight light0 spot_direction 90. 0. 0.,
gllight light0 spot_exponent 0.,
gllight light0 constant_attenuation .01,
gllight light0 linear_attenuation 0.01,
gllight light0 quadratic_attenuation 0.07,
glenable light0,
glenable lighting,
glenable normalize,

#43238
Apr 7, 2009 at 1:01pm

Here is a simple example patch. How can the front plane block light reaching the back plane? Should be as simple as alpha channel, glBlendFunc, or drawing order, right? or is this where a stencil buffer is used?

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 143 32 100 196617 2) BANG ME;
#P newex 388 324 51 196617 zl ecils 5;
#P window linecount 2;
#P newex 429 357 322 196617 jit.gl.gridshape cookie @shape sphere @scale 0.2 0.2 0.2 @color 1. 1. 0 1. @poly_mode 1 1 @dim 6 6 @gridmode 1 @position -6.15 0. 0.;
#B color 5;
#P window linecount 1;
#P newex 764 269 32 196617 print;
#P message 736 210 57 196617 getcmdlist;
#P window linecount 11;
#P message 142 49 397 196617 reset , gldisable depth_test , gldisable color_material , glmaterial front ambient_and_diffuse 0. 0. 0. 0. , glmaterial front specular 0. 0. 0. 0. , glmaterial front emission 0. 0. 0. 0. , glmaterial front shininess 1. , glmaterial back ambient_and_diffuse 0. 0. 0. 0. , glmaterial back specular 0. 0. 0. 0. , glmaterial back emission 0. 0. 0. 0. , glmaterial back shininess 1. , gllightmodel ambient 0.2 0.2 0.2 1. , gllightmodel two_side 1 , gllightmodel local_viewer 1 , gllight light0 ambient 1. 1. 1. 0. , gllight light0 diffuse 1. 1. 1. 0. , gllight light0 specular 1. 1. 1. 0. , gllight light0 position -6.15 0. 0. 1. , gllight light0 spot_cutoff 30. , gllight light0 spot_direction 90. 2. 0. , gllight light0 spot_exponent 0. , gllight light0 constant_attenuation 0.01 , gllight light0 linear_attenuation 0.1 , gllight light0 quadratic_attenuation 0.015 , glenable light0 , glenable lighting , glenable normalize , drawobject front 0 , drawobject back 0 ,;
#P number 123 257 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 82 257 35 9 0 0 0 3 0 0 0 40 204 140 222 222 222 0 0 0;
#P number 44 257 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 39 274 109 196617 pak rotatexyz 0. 0. 0.;
#P flonum 553 177 35 9 0 0 0 3 0 0 0 40 204 140 222 222 222 0 0 0;
#P flonum 586 177 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 388 200 279 196617 pak cmd_replace 16 gllight light0 position -6.15 0. 0. 1.;
#P window linecount 3;
#P newex 429 474 331 196617 jit.gl.gridshape cookie @name back @shape plane @dim 250 250 @scale 6.8 6.75 1. @smooth_shading 1 @lighting_enable 1 @depth_enable 1 @automatic 0 @rotatexyz 0. 90. 0. @position 0.63 0. 0.;
#B color 5;
#P window linecount 1;
#P hidden newex 13 479 106 196617 bgcolor 160 160 160;
#P message 680 211 41 196617 glclear;
#P newex 388 247 386 196617 jit.gl.sketch cookie @automatic 0 @smooth_shading 1 @position 2 0 0 @pushstate 0;
#P toggle 168 390 15 0;
#P message 168 408 55 196617 floating $1;
#P newex 39 297 223 196617 jit.gl.handle cookie @depth_enable 1 @radius 2.;
#P toggle 95 390 15 0;
#P newex 56 389 35 196617 sel 27;
#P message 95 408 68 196617 fullscreen $1;
#P newex 13 432 161 196617 jit.window cookie @depthbuffer 1;
#P newex 11 389 40 196617 key;
#P newex 15 154 43 196617 jit.qball;
#P number 60 105 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 15 105 15 0;
#P newex 15 131 55 196617 metro 20;
#P newex 15 185 58 196617 t b b erase;
#P window linecount 3;
#P newex 429 411 330 196617 jit.gl.gridshape cookie @name front @shape plane @dim 250 250 @scale 3.6 5. 1. @smooth_shading 1 @lighting_enable 1 @depth_enable 1 @automatic 0 @rotatexyz 0. 90. 0. @position -4. 0. 0.;
#B color 5;
#P window linecount 1;
#P newex 15 338 352 196617 jit.gl.render cookie @erase_color 0 0 0 1. @camera 4 -17 -6 @near_clip 1.;
#P comment 13 83 100 196617 1) ON;
#P comment 82 240 100 196617 3) may rotate;
#P window linecount 10;
#P comment 260 386 100 196617 How can the front plane block light reaching the back plane? Should be as simple as alpha channel , glBlendFunc , or drawing order…or is this where stencil buffer is used?;
#P fasten 12 0 11 0 100 427 18 427;
#P fasten 16 0 11 0 173 427 18 427;
#P connect 7 0 6 0;
#P connect 6 0 9 0;
#P connect 9 0 5 0;
#P fasten 5 2 3 0 68 234 20 234;
#P connect 5 0 3 0;
#P fasten 15 0 3 0 44 332 20 332;
#P fasten 25 0 15 0 44 293 44 293;
#P fasten 10 0 13 0 16 417 61 417;
#P connect 8 0 6 1;
#P connect 26 0 25 1;
#P fasten 13 0 14 0 61 407 92 407 92 387 100 387;
#P connect 14 0 12 0;
#P connect 27 0 25 2;
#P connect 28 0 25 3;
#P connect 17 0 16 0;
#P fasten 5 1 18 0 44 234 393 234;
#P fasten 29 0 18 0 147 234 393 234;
#P fasten 30 0 18 0 741 234 393 234;
#P fasten 19 0 18 0 685 234 393 234;
#P connect 22 0 18 0;
#P connect 22 0 33 0;
#P connect 33 1 32 0;
#P connect 24 0 22 5;
#P connect 23 0 22 6;
#P connect 18 1 31 0;
#P window clipboard copycount 35;

#155077
Apr 7, 2009 at 3:31pm

your handle works very funny for me, you might just want to connect your rotate direct, and do you have max 5?

opengl doesn’t do what your asking to my knowledge, you have to setup shadows or have the light only affect certain surfaces

#155078
Apr 7, 2009 at 3:43pm

forget the handle, manually rotate. max 5, why? am still @adapt 0 with the interface.

this is fundamental of opengl::object opacity and z-plane positioning.

i am sure i am just overlooking something…

#155079
Apr 7, 2009 at 8:11pm

as axiom said, one object blocking light from another object is called shadowing. there are no built in shadow techniques for opengl, you have to construct your own method.

one possibility would be to use a texture as a lightmap, as opposed to an actual light. you could control the size and spread of the light with several differnt methods.

#155080
Apr 8, 2009 at 10:18am

ok, i thought i was missing something as basic as object opacity. so, if a light is coming through a “window”, the shape of the window would not influence the spread of the light unless a texture is used as a lightmap. would you have an example of this? cheers.

#155081

You must be logged in to reply to this topic.