Yes, two sided lighting was what I was going to suggest, but you beat me to it.
Note that two sided lighting is deprecated in OpenGL 3.0, so you should consider looking for a shader-based solution instead. In the shader, if the dot product of the normal and eye vector is negative, just negate it, then calculate lighting as usual. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Monday, January 26, 2009 8:44 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Rendering double-sided surfaces. For sure the best thing to do would be to process the incoming data as suggested. However, you might be able to get OpenGL to do what you want by setting all material properties for both sides of the polygon and enabling two sided lighting. Something like this. osg::ref_ptr< osg::LightModel > pLightModel = new osg::LightModel(); pLightModel->setTwoSided( true ); pState->setAttributeAndModes( pLightModel.get(), osg::StateAttribute::ON ); osg::ref_ptr<osg::Material> pMaterial = new osg::Material(); pMaterial->setColorMode( osg::Material::DIFFUSE ); pMaterial->setAmbient( osg::Material::FRONT_AND_BACK, osg::Vec4( 0.0, 0.0, 0.0, 1.0 ) ); pMaterial->setSpecular( osg::Material::FRONT_AND_BACK, osg::Vec4( 1.0, 1.0, 1.0, 1.0 ) ); pMaterial->setShininess( osg::Material::FRONT_AND_BACK, 64.0f ); pState->setAttributeAndModes( pMaterial.get(), osg::StateAttribute::ON ); I have never tried this for data like you have but it seems to me like it should work. Frank On Mon, Jan 26, 2009 at 04:21:41PM +0100, alessandro terenzi wrote: > Problem is that the models that come to my application are already > prepared by people that do not (and unfortunately won't) think about > normals issues, so maybe the best thing to do would be to really > render both front and back faces, I'm not an expert, but the only > approach I can think is to double the geometry so to have both faces, > but it would be really a waste (not to mention performace problems > that may arise..and other unexpected visualization problems I cannot > think of..) Regards. > Alessandro > > On Mon, Jan 26, 2009 at 1:37 PM, Tomlinson, Gordon < > [email protected]> wrote: > > > your triangles all need to be wound the same way (anticlockwise by > > default for OSG & Opengl), whether or not your normal's are correct > > > > The easiest fix would be to ensure that your modeling package sets > > up correct normal's before you get to OSG > > > > Assuming your triangles are wound the same way ( if not you will > > have to fix that ) try using the SmoothingVistor on the data see > > > > include\osgUtil\SmoothingVisitor > > > > > > *Gordon* > > > > __________________________________________________________ > > *Gordon Tomlinson* > > > > *Product Manager 3D > > **Email * : gtomlinson @ overwatch.textron.com > > __________________________________________________________ > > *(C): (+1) 571-265-2612 > > (W)**: (+1) 703-437-7651* > > > > "Self defence is not a function of learning tricks but is a function > > of how quickly and intensely one can arouse one's instinct for > > survival" > > - *Master Tambo Tetsura* > > > > > > > > ------------------------------ > > *From:* [email protected] [mailto: > > [email protected]] *On Behalf Of > > *alessandro terenzi > > *Sent:* Monday, January 26, 2009 7:09 AM > > *To:* OpenSceneGraph Users > > *Subject:* [osg-users] Rendering double-sided surfaces. > > > > Sometimes my application has to load models that have normals not > > always oriented in the same coherent way, so it is not always > > possible to say that a surface is oriented in a way or in another > > and my renderings do not look correct. > > > > I'd like to fix this problem in some way...so I was thinking about > > rendering both front and back faces, but how do I ask OSG do this? > > Or perhaps, is there another way/technique to achive the same result? (ie. > > orient a surface in a coherent way: all faces inward XOR outward) > > > > Thank you. > > Alessandro > > > > _______________________________________________ > > osg-users mailing list > > [email protected] > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegrap > > h.org > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph. > org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

