Re: [osg-users] How to make sure that both the back and the front side of a polygon are lit...

2010-06-30 Thread Sunil S Nandihalli
*
Hi Tony and Alberto,
 The following is a snippet of the code I have tried .. It continues to
light up only one side of the geometry ...

osg::StateSet* st = topo-getOrCreateStateSet(); *
*osg::Group* topo = new osg::Group;
*
*osg::Material* matirial = new osg::Material; *
*matirial-setColorMode(osg::Material::DIFFUSE); *
*matirial-setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 1, 0,
1)); *
*matirial-setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 1, 0,
1)); *
*matirial-setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 1, 0,
1)); *
*matirial-setShininess(osg::Material::FRONT_AND_BACK, 10.0f); *
*st-setAttributeAndModes (matirial,osg::StateAttribute::ON); *
*osg::LightModel* ltModel = new osg::LightModel; *
*ltModel-setTwoSided(true); *
*st-setAttribute(ltModel); *
*/* render the geometry in the children nodes ... */*


If I reverse the normals the opposite side lights up as expected .. Am I
doing something wrong..
Sunil.
On Tue, Jun 29, 2010 at 2:23 PM, Tony Horrobin a.j.horro...@its.leeds.ac.uk
 wrote:

 Hi Sunil,

 Just to be clear, you also need to specify a two-sided light model to make
 OpenGL apply both front and back materials.
 The osg::LightModel class allows this.

 Cheers,

 -Tony


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to make sure that both the back and the front side of a polygon are lit...

2010-06-30 Thread Alberto Luaces
Sunil S Nandihalli writes:

 Hi Tony and Alberto,
  The following is a snippet of the code I have tried .. It continues to light 
 up only one side of the geometry ... 

 osg::StateSet* st = topo-getOrCreateStateSet(); 
 osg::Group* topo = new osg::Group; 
 osg::Material* matirial = new osg::Material; 
 matirial-setColorMode(osg::Material::DIFFUSE); 
 matirial-setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 1, 0, 1)); 
 matirial-setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 1, 0, 1)); 
 matirial-setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 1, 0, 1)); 
 matirial-setShininess(osg::Material::FRONT_AND_BACK, 10.0f); 
 st-setAttributeAndModes (matirial,osg::StateAttribute::ON); 
 osg::LightModel* ltModel = new osg::LightModel; 
 ltModel-setTwoSided(true); 
 st-setAttribute(ltModel); 
 /* render the geometry in the children nodes ... */

 If I reverse the normals the opposite side lights up as expected .. Am I 
 doing something wrong..

You also have to deactivate face culling for st with GL_CULL_FACE.

-- 
Alberto

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to make sure that both the back and the front side of a polygon are lit...

2010-06-29 Thread Alberto Luaces
Hi Sunil,

Sunil S Nandihalli writes:

 Hello everybody,
  I would like to have both the front and the back side of the polygons I draw 
 lit. Right now I have specified the normals and only the side which is on the 
 same side as that of the normals is being lit..
 Should I render the same-geometry twice and add normals to it so that it is 
 lit on both sides.. I realized this might not be the right way to do it.. 
 Does any of you have any suggestion?

You are already doing it right. Just render once, disable the face
culling with osg::StateSet in order to allow both sides to be seen, and
specify a material for the back side or at the same time you defined
the front one.

-- 
Alberto

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to make sure that both the back and the front side of a polygon are lit...

2010-06-29 Thread Tony Horrobin

Hi Sunil,

Just to be clear, you also need to specify a two-sided light model to 
make OpenGL apply both front and back materials.

The osg::LightModel class allows this.

Cheers,

-Tony

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] How to make sure that both the back and the front side of a polygon are lit...

2010-06-28 Thread Sunil S Nandihalli
Hello everybody,
 I would like to have both the front and the back side of the polygons I
draw lit. Right now I have specified the normals and only the side which is
on the same side as that of the normals is being lit.. Should I render the
same-geometry twice and add normals to it so that it is lit on both sides..
I realized this might not be the right way to do it.. Does any of you have
any suggestion?
Thanks for reading this email..
Sunil.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org