Thread: [Plib-users] plib and shadows
Brought to you by:
sjbaker
|
From: <Rol...@t-...> - 2002-06-10 16:42:03
|
Hi, As a newbie in OpenGL and plib I searched the web for possibilities to have shadows in a scene. I found one simple tutorial for pure OpenGL from a guy at nvidia using the stencil buffer. Now, this requires to draw the scene twice - one for the projection on the ground and one to actually show the scene. It's working fine with an object created using OpenGL directly, but I would like to use modelled scenes from AC3d and benefit from plib's features. Is it possible to make SSG draw the scene with some settings and transformation and stencil buffer, so that the shadows can be calculated ? ssgCullAndDraw() don't seem to work as it's setting up OpenGL the way it needs it to draw it from the eye's point of view. Maybe there are other ways to get shadows with plib ? Thanks in Advance, Rolf -- Rolf Jakob at home (rj...@du...) WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS) |
|
From: Steve B. <sjb...@ai...> - 2002-06-11 03:10:29
|
Rolf Jakob wrote: > As a newbie in OpenGL and plib I searched the web for possibilities to have > shadows in a scene. I found one simple tutorial for pure OpenGL from a guy at > nvidia using the stencil buffer. Yes - that's not a bad approach - but really all shadow algorithms come with some ugly compromises. Many of the ones that are currently seen in games only work because the light source is close to the camera and the scene is quite restricted in size. > Now, this requires to draw the scene twice - one for the projection on the > ground and one to actually show the scene. It's working fine with an object > created using OpenGL directly, but I would like to use modelled scenes from > AC3d and benefit from plib's features. > > Is it possible to make SSG draw the scene with some settings and > transformation and stencil buffer, so that the shadows can be calculated ? Yes. > ssgCullAndDraw() don't seem to work as it's setting up OpenGL the way it > needs it to draw it from the eye's point of view. Well, you can place a draw callback on the top level SGGL node and have it reset the parameters however you like. > Maybe there are other ways to get shadows with plib ? Not that I know of. I do mostly outdoor games - and I generally just plant a fuzzy blob under the things that need shadows. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
|
From: <Rol...@t-...> - 2002-06-11 21:06:55
|
On Monday 10 June 2002 06:58, Steve Baker wrote: > Rolf Jakob wrote: > > As a newbie in OpenGL and plib I searched the web for possibilities to > > have shadows in a scene. I found one simple tutorial for pure OpenGL from > > a guy at nvidia using the stencil buffer. > > Yes - that's not a bad approach - but really all shadow algorithms come > with some ugly compromises. Many of the ones that are currently seen in > games only work because the light source is close to the camera and the > scene is quite restricted in size. Yes, I know. Compared to POVRAY's output it's lame, but it should give my scene a more natural look. > > ssgCullAndDraw() don't seem to work as it's setting up OpenGL the way it > > needs it to draw it from the eye's point of view. > > Well, you can place a draw callback on the top level SGGL node and have > it reset the parameters however you like. Emm, what do you mean by top level SGGL ? The first leaf in the tree ? Thanks, Rolf -- Rolf Jakob at home (rj...@du...) WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS) |
|
From: Steve B. <sjb...@ai...> - 2002-06-11 22:49:07
|
Rolf Jakob wrote: >>Well, you can place a draw callback on the top level SGGL node and have >>it reset the parameters however you like. > > Emm, what do you mean by top level SGGL ? The first leaf in the tree ? (Oops! Sorry - that was a brain slip. My project at work is called SGGL - I *meant* to say "Top level SSG node" - meaning the root node in the scene graph - the topmost branch.) ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
|
From: <Rol...@t-...> - 2002-06-13 11:00:24
|
Hello, I'm still trying to get shadows. Now I reduced the code so that stencil buffer is not (yet) used, I just want to see the projection of my scene to the ground. There is a callback function for predraw which is being called. I tried two ways : - use a glMultMatrixf((GLfloat *) floorShadow) in the callback function, where floorShadow is the projection matrix - use a setTransform(floorshadow) before calling ssgCullAndFace Both don't show a projection, the second shows parts of the scene at a different place. My guess is the first is superseded by ssg functions and the second is a transformation but not a projection. Could that be ? Thanks, Rolf -- Rolf Jakob at home (rj...@du...) WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS) |
|
From: Steve B. <sjb...@ai...> - 2002-06-13 23:36:35
|
> I'm still trying to get shadows. > Now I reduced the code so that stencil buffer is not (yet) used, I just want > to see the projection of my scene to the ground. > There is a callback function for predraw which is being called. > I tried two ways : > - use a glMultMatrixf((GLfloat *) floorShadow) in the callback function, > where floorShadow is the projection matrix You can't do that because SSG culls the scene to the view frustum prior to drawing it - so if you go and change the transforms without SSG knowing about it, you'll get into problems. > - use a setTransform(floorshadow) before calling ssgCullAndFace > Both don't show a projection, the second shows parts of the scene at a > different place. > My guess is the first is superseded by ssg functions and the second is a > transformation but not a projection. Could that be ? Yes - transforms are limited to rotates and translates. It's not possible to do bounding sphere culling when the transform is not shape-preserving. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
|
From: <Rol...@t-...> - 2002-06-15 18:34:53
|
some additional notes after trying several things : On Thursday 13 June 2002 13:07, I wrote: > Hello, > > I'm still trying to get shadows. That's still true ;-) > I tried two ways : > - use a glMultMatrixf((GLfloat *) floorShadow) in the callback function, > where floorShadow is the projection matrix > - use a setTransform(floorshadow) before calling ssgCullAndFace > > Both don't show a projection, the second shows parts of the scene at a > different place. > My guess is the first is superseded by ssg functions and the second is a > transformation but not a projection. Could that be ? No. The second way should work, there was a problem in the matrix. Meanwhile I get a second copy of the scene rendered and I can transform it however I like. So far so good. Now I try to switch off texturing (works), lighting (works) and replace all colors to a half transparent black. For the latter I added two lines to my callback function : glMaterialfv(GL_FRONT,GL_DIFFUSE,shadowColor); glColor4f(0.0, 0.0, 0.0, 0.5); but both seem to be ignored/overwritten. I think I'm almost there, only this last step is missing. Any hints ? Thanks, Rolf -- Rolf Jakob at home (rj...@du...) WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS) |
|
From: <Rol...@t-...> - 2002-06-15 18:34:26
|
Hello,
how can I change the material of a leaf that's part of a database imported
from AC3D ?
I traverse all leaves and set the state as following :
state->disable(GL_LIGHTING);
state->disable(GL_BLEND);
state->disable(GL_TEXTURE_2D);
state->setColourMaterial(GL_DIFFUSE);
state->setMaterial(GL_DIFFUSE,0.0f,0.0f,0.0f,0.5f);
state->setShadeModel(GL_FLAT);
But the leaves are rendered in their colors, so the textures are missing. But
what I need is a whole ssgTransform in black. The branch in question was
created by a clone(SSG_CLONE_RECURSIVE|SSG_CLONE_STATE).
Am I missing something ?
Thanks,
Rolf
--
Rolf Jakob at home (rj...@du...)
WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS)
|
|
From: Steve B. <sjb...@ai...> - 2002-06-16 02:21:54
|
Rolf Jakob wrote: > Hello, > > how can I change the material of a leaf that's part of a database imported > from AC3D ? > I traverse all leaves and set the state as following : > > state->disable(GL_LIGHTING); > state->disable(GL_BLEND); > state->disable(GL_TEXTURE_2D); > state->setColourMaterial(GL_DIFFUSE); > state->setMaterial(GL_DIFFUSE,0.0f,0.0f,0.0f,0.5f); > state->setShadeModel(GL_FLAT); > > But the leaves are rendered in their colors, so the textures are missing. But > what I need is a whole ssgTransform in black. The branch in question was > created by a clone(SSG_CLONE_RECURSIVE|SSG_CLONE_STATE). Can't you just set all of the light sources to black? Unless you have luminous surfaces, that should work...and luminous surfaces (arguably) shouldn't cast shadows. You probably don't want to turn off texturing because something like a tree could be shaped by the alpha part of the texture. If you turn off textures, every tree will cast a neat, perfectly rectangular, shadow! ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |