HELP: setAmbient does not work in simple sky node #2382
-
Hello, everyone. osgEarth::Util::SkyOptions skyOptions;
skyOptions.ambient = 1.0;
m_skyNode = osgEarth::Util::SkyNode::create (skyOptions, m_mapNode.get());
osgEarth::DateTime date(2023, 11, 14, 11);
m_skyNode->setDateTime(date);
m_skyNode->setLighting(osg::StateAttribute::ON);
osgEarth::insertGroup(m_skyNode.get(), m_mapNode.get());
m_skyNode->attach(m_viewer.get(), 0); In order to find the problem, I further looked at the source code of simple sky node, and then a more strange problem appeared, which is that The change of functions cannot affect the color of the light source. I modified some source code in the function named "void SimpleSkyNode::initialize(const SpatialReference* srs)" in SimpleSkyNode.cpp. The original code is: _light->setDiffuse(osg::vec4f(1.0f, 1.0f, 1.0f, 1.0f));
_light->setSpecular(osg::vec4f(1.0f, 1.0f, 1.0f, 1.0f)); The modified code is: _light->setDiffuse(osg::vec4f(1.0f, 0.0f, 0.0f, 1.0f));
_light->setSpecular(osg::vec4f(1.0f, 0.0f, 0.0f, 1.0f)); In theory, the color of sunlight should become red. But it does not happen. Why? It is a strange and challenge problem, and I look forward to getting your help. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hello. |
Beta Was this translation helpful? Give feedback.
Hello.
First, I hope you are using a newer version of osgEarth ... 2.7 is rather old :)
Second, there was indeed a defect (in the master branch) in which the diffuse color was not applied in the shader. I have pushed a fix for this. Ambient already works. Keep in mind however that specular light color is not a factor in the PBR lighting model so that will have no effect.
Hope this helps.