[osg-users] PrimitiveSet lighting issues

OSG@dvp.co.il osg at dvp.co.il
Mon Sep 24 22:31:51 PDT 2007


Henri, did you try JUST turning off the light for those lines?

what you wrote about the color-material seems ok, it means that in the
pipeline OpenGL will take the glColor value and use it as the emission in
it's light equations. But if you turn off the light, the pipeline use
glColor. so it's pretty much equivalent.
just turning off the light have many benfits though: 1. it's faster to
implement. 2. run time is better. 3. you can set diferrent color at each
vertex, while using the material will set the same emission value to the
whole line (or line strip, depends on your geometry).

----- Original Message -----
From: "Jean-Sébastien Guay" <jean-sebastien.guay at polymtl.ca>
To: <osg-users at lists.openscenegraph.org>
Sent: Tuesday, September 25, 2007 2:12 AM
Subject: Re: [osg-users] PrimitiveSet lighting issues


> Hello Nelson,
>
> > I'm still new to all this.  All I found on emissive color is the
following:
> >
> > glMaterial Default Parameters
> > GL_EMISSION (0.0, 0.0, 0.0, 1.0) emissive color of material
>
> The OpenSceneGraph is a rather thin wrapper of OpenGL, so in most
> cases the OpenGL documentation will be useful to make sense out of
> what OSG does. In most cases, if you see a method name in OSG's
> doxygen reference, you can search for similar names in OpenGL and you
> will find out what it does.
>
> In this case, "Chapter 5 - Lighting" from the red book will be useful.
> http://www.glprogramming.com/red/chapter05.html
>
> At around 1/6th of the page, you will see:
>    "In addition to ambient, diffuse, and specular colors, materials have
an
>     emissive color, which simulates light originating from an object. In
the
>     OpenGL lighting model, the emissive color of a surface adds
> intensity to the
>     object, but is unaffected by any light sources. Also, the emissive
> color does
>     not introduce any additional light into the overall scene."
>
> To understand what the emissive color will give as a result, see
> around 5/6th of the page, where you will find the general lighting
> equation OpenGL uses:
>
> The color produced by lighting a vertex is computed as follows:
>
> "vertex color =
>      the material emission at that vertex +
>      the global ambient light scaled by the material's ambient property at
that
>          vertex +
>      the ambient, diffuse, and specular contributions from all the
> light sources,
>          properly attenuated
>
> So if you just want your color independently of any lighting, you
> should set your color as the material's emissive color, and disable
> all other lighting in the scene (or at least for those nodes in the
> scene graph).
>
> > Is this what you had in mind:
> >
> >
> > osg::StateSet* state = geode->getOrCreateStateSet();
> >     state ->setMode(GL_COLOR_MATERIAL,osg::StateAttribute::ON);
> > osg::ref_ptr<osg::Material> mat = new osg::Material;
> > mat->setColorMode(osg::Material::EMISSION);
> > state->setAttribute(mat.get()
>
> The problem there is that you don't set the emissive color. I think
> this should work, but untested... :
>
>      osg::StateSet* state = geode->getOrCreateStateSet();
>      osg::ref_ptr<osg::Material> mat = new osg::Material;
>      mat->setEmission(osg::Material::FRONT_AND_BACK,
>          osg::Vec4(1.0, 1.0, 1.0, 1.0);    // Set the color to
> whatever you want
>      state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
>      state->setAttribute(mat.get());
>
> But you were definitely on the right track.
>
> Good luck,
>
> J-S
> --
> ______________________________________________________
> Jean-Sebastien Guay     jean-sebastien.guay at polymtl.ca
>                          http://whitestar02.webhop.org/
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





More information about the osg-users mailing list