Ok, so I found this:
http://www.openscenegraph.org/projects/osg/wiki/Support/OpenGL2OSGLookup
So I am now doing this:
Code:
osg::ref_ptr<osg::LightModel> lightModel = new osg::LightModel;
//
http://www.glprogramming.com/red/chapter05.html
// "OpenGL reverses the surface normals for back-facing polygons; typically, this means that the surface
// normals of visible back- and front-facing polygons face the viewer, rather than pointing away.
// As a result, all polygons are illuminated correctly. However, these additional operations usually make
// two-sided lighting perform more slowly than the default one-sided lighting."
lightModel->setTwoSided(true);
//
http://www.opengl.org/sdk/docs/man2/xhtml/glLightModel.xml
// "GL_SINGLE_COLOR specifies that a single color is generated from the
// lighting computation for a vertex. GL_SEPARATE_SPECULAR_COLOR
// specifies that the specular color computation of lighting be stored
// separately from the remainder of the lighting computation. The specular
// color is summed into the generated fragment's color after the application
// of texture mapping (if enabled). The initial value is GL_SINGLE_COLOR."
lightModel->setColorControl(osg::LightModel::SINGLE_COLOR);
// as of 2.9.9 this would be the default
lightModel->setAmbientIntensity(osg::Vec4(0.2f,0.2f,0.2f,1.0f));
//
http://www.glprogramming.com/red/chapter05.html
// "A local viewpoint tends to yield more realistic results, but since the direction has to be calculated for each vertex,
// overall performance is decreased with a local viewpoint. By default, an infinite viewpoint is assumed."
lightModel->setLocalViewer(false);
modelNode->getOrCreateStateSet()->setAttributeAndModes(lightModel.get());
Question: Am I missing something? What about glMaterialfv ( GL_FRONT_AND_BACK, ...) I read about somewhere else? For my model, something along those lines does not seem necessary.
If someone is interested, the performance impact is as follows:
before 4.75 FPS
after 2.9 FPS
(so it may be best to fix the model in the long run)
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53098#53098