openglopengl-3openscenegraph

Lighting in OpenSceneGraph with Core profile


I use OpenSceneGraph and I want to use some features of OpenGL 3.3 and the Core profile. I compiled OpenSceneGraph with the option -DOPENGL_PROFILE=GL3. I got the features I wanted, however, some features of OSG do not work anymore, as lighting with osg::Light, osg::LineWidth, osg::LineStipple on so on.

I know that OSG is mainly built uppon GL2 features, and that Fixed Function Pipeline is not available in core profile, but I expected for "basic" features as light or lines to work.

It the support of those features in Core profile is planned? Or do I have to implement shaders myself? Or are there any existing implementation?


Solution

  • Lighting and stippling are GL2/legacy features. When you go GL3/Core, you lose all ability to do those things without writing your own shaders.

    While OSG could try to automatically do those things for you, in practice, you would only use that ability for a VERY short time before you had to bypass it and just write your own shaders. Look into the ShaderGen Visitor which you can manually execute on your graph to help do some of this for you: https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgUtil/ShaderGen.cpp

    The data for lights, etc, can be pushed down to the scenegraph as Uniforms which can then be used by your shader.