I need to set the Source item over my landscape in OpenSceneGraph, which will act like the sun. I already know how to set up the light, and this can be done as follows:
osg::ref_ptr<osg::Group> lightGroup (new osg::Group);
osg::ref_ptr<osg::StateSet> lightSS (root->getOrCreateStateSet());
osg::ref_ptr<osg::LightSource> lightSource1 = new osg::LightSource;
osg::ref_ptr<osg::LightSource> lightSource2 = new osg::LightSource;
float xCenter = tree->getRoot()->getXCenter();
float yCenter = tree->getRoot()->getYCenter();
osg::Vec4f lightPosition (osg::Vec4f(xCenter, yCenter,75.0,1.0f));
osg::ref_ptr<osg::Light> myLight = new osg::Light;
myLight->setLightNum(1);
myLight->setPosition(lightPosition);
myLight->setAmbient(osg::Vec4(0.8f,0.8f,0.8f,1.0f));
myLight->setDiffuse(osg::Vec4(0.1f,0.4f,0.1f,1.0f));
myLight->setConstantAttenuation(1.0f);
myLight->setDirection(osg::Vec3(0.0f, 0.0f, -1.0f));
lightSource1->setLight(myLight.get());
lightSource1->setLocalStateSetModes(osg::StateAttribute::ON);
lightSource1->setStateSetModes(*lightSS,osg::StateAttribute::ON);
lightGroup->addChild(lightSource1.get());
osg::ref_ptr<osg::Geode> lightMarkerGeode (new osg::Geode);
lightMarkerGeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3f(xCenter,yCenter,75),10.0f)));
root->addChild(lightGroup.get());
root->addChild(lightMarkerGeode.get());
And this will create a landscape that looks like this:

Landscape with light above (light is indicated by a sphere)
This light source does not seem to really affect the landscape. The question is what lighting parameters (i.e., Atmosphere, diffusion, etc.) are needed to create the emulating light of the Sun.
source
share