[osg-users] Lighting behavior and osgViewer::osgViewer

Christophe Medard christophe.medard at oktal.fr
Thu Sep 13 09:20:25 PDT 2007


In fact I was puzzled by the fact that if no directional Light is set in the scene graph, the one set transversally onto the draw traversal by the osgViewer (through the cull visitor, ie not in the scenegraph) becomes active. I was unsure about that indeed, but as you say it's not as soon as at least one light is present in the scene graph (GL_LIGHT0 == Viewer's HEADLIGHT if and only if no LightSource is present in the scene).

Debugging a light effect where you can have to deactivate diffuse lights appear tricky not knowing that. Maybe a default behaviour of the viewer where lighting is OFF would have been clearer.

Now I have the whole picture thanks to you and Robert, thanks.

-> Effectively, you can merely work into the scenegraph with osgViewer, since viewer.getCamera()->getOrCreateStateSet()->setMode(..) only activate things on attributes and modes not encountered in the loaded scenegraph ; those who are set in the scenegraph aren't reset by osgViewer. So does the osglight example work.
-> Debugging peacefully an ambient effect can be done : passing through viewer.getCamera()->getOrCreateStateSet()->setMode(..) works to disable the 'transversal' diffuse light established by the viewer.
-> viewer.setLightingMode() doesn't seem too work well, in v.2.0.0 nor 2.1.10 (it's not vital to me).

Christophe
  ----- Original Message ----- 
  From: Paul Martz 
  To: 'OpenSceneGraph Users' 
  Sent: Thursday, September 13, 2007 4:41 PM
  Subject: Re: [osg-users] Lighting behavior and osgViewer::osgViewer


  Hi Christophe --

  If I'm reading your email right, you have two concerns:

   1. You don't understand how SceneView uses its _light member variable. Without digging into the code, I'm not sure either. But I suspect it circumvents the typical update/cull traversals and slaps the light state directly into the positional state of the draw traversal. As _light just controls GL_LIGHT_0, you don't need to access _light or even its StateSet -- you just need to specify your own alternate values for GL_LIGHT_0.

   2. You seem to be unsure that you can fully control lighting and simultaneously use osgViewer. This is not the case, and again I direct you to the osglight example program, which uses osgViewer and overrides lighting effects directly in the scene graph.

  Hope that helps,
     -Paul


  ----- Original Message ----- 
  From: "Robert Osfield" <robert.osfield at gmail.com>
  To: "OpenSceneGraph Users" <osg-users at lists.openscenegraph.org>
  Sent: Thursday, September 13, 2007 3:28 PM
  Subject: Re: [osg-users] Lighting behavior and osgViewer::osgViewer


  Hi Christophe,

  I wouldn't recommended messing with SceneView unless you really have to.

  osgViewer now honours the Camera's StateSet, and this acts as the
  global StateSet.  You can simply sets modes and attributes you want on
  the camera i.e.

  viewer.getCamera()->getOrCreateStateSet()->setMode(..);

  Robert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070913/5a8451ab/attachment-0003.htm>


More information about the osg-users mailing list