Dear Robert,
Thanks for your suggestion, but that does not fix the issue. (Diff to
osgprerendercubemap.cpp attached.) Any other ideas?
-Andrew
On 11/05/2012 10:37 AM, Robert Osfield wrote:
HI Andrew,
Try putting an osg::LightSource with a positional light into the scene.
Robert.
On 3 November 2012 13:01, Andrew Straw <[email protected]
<mailto:[email protected]>> wrote:
Hi,
(I have a vague memory of this question being asked years ago but
I cannot find the discussion.)
In the example program osgprerendercubemap, if you study the
reflections you can see, at the borders between the faces of the
cubemap used to render the reflects, inconsistencies in the
specular highlights. Upon further inspection in my own code (just
rendering the cubemap itself), it appears that the lighting, and
hence the specular reflections, are calculated for a light that is
fixed relative to the per-cubemap-face camera rather than fixed in
world coordinates. Consequently, when an object shifts from the
right edge of one camera to the left edge of the next camera, the
reflection is rendered from a totally different relative light
position. The visual seams are quite obvious when you know what to
look for, and even more so in my program based off this one.
Any advice on how to eliminate this effect would be greatly
appreciated.
Thanks in advance,
Andrew
_______________________________________________
osg-users mailing list
[email protected]
<mailto:[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
diff --git a/osgprerendercubemap.cpp b/osgprerendercubemap.cpp
index 0cc5481..c902266 100644
--- a/osgprerendercubemap.cpp
+++ b/osgprerendercubemap.cpp
@@ -102,6 +102,21 @@ ref_ptr<Group> _create_scene()
matirial->setShininess(Material::FRONT_AND_BACK, 64.0f);
scene->getOrCreateStateSet()->setAttributeAndModes(matirial.get(), StateAttribute::ON);
+ osg::LightSource* lightSource = new osg::LightSource;
+ scene->addChild(lightSource);
+
+ osg::Light* light = lightSource->getLight();
+ light->setLightNum(0);
+ light->setPosition(osg::Vec4(0.0f,5.0f,5.0f,1.0f));
+ light->setAmbient(osg::Vec4(0.8f,0.8f,0.8f,1.0f));
+ light->setDiffuse(osg::Vec4(0.2f,0.2f,0.2f,1.0f));
+ light->setSpecular(osg::Vec4(0.9f,0.9f,0.9f,1.0f));
+
+ scene->getOrCreateStateSet()->setAssociatedModes(light,osg::StateAttribute::ON);
+
+ // enable lighting by default.
+ scene->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON);
+
return scene;
}
@@ -352,6 +367,7 @@ int main(int argc, char** argv)
scene->addChild(reflectedScene.get());
viewer.setSceneData(scene.get());
+ viewer.setLightingMode(osg::View::NO_LIGHT);
return viewer.run();
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org