Re: [osg-users] lighting not consistent across images in osgprerendercubemap
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 straw...@astraw.com mailto:straw...@astraw.com 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 osg-users@lists.openscenegraph.org mailto:osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org 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_ptrGroup _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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] lighting not consistent across images in osgprerendercubemap
Hi Andrew, Try applying an osg::LightModel state attribute to your scene graph with setLocalViewer set to true. I use this to get consistent specular highlights across walls in our CAVE setups. Hope this helps. Cheers, Farshid On Wed, Nov 7, 2012 at 5:22 AM, Andrew Straw straw...@astraw.com wrote: 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 straw...@astraw.com 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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] lighting not consistent across images in osgprerendercubemap
That's it! Many thanks! That had been a source of frustration for some time. -Andrew On 07-Nov-12 17:52, Farshid Lashkari wrote: Hi Andrew, Try applying an osg::LightModel state attribute to your scene graph with setLocalViewer set to true. I use this to get consistent specular highlights across walls in our CAVE setups. Hope this helps. Cheers, Farshid On Wed, Nov 7, 2012 at 5:22 AM, Andrew Straw straw...@astraw.com mailto:straw...@astraw.com wrote: 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 straw...@astraw.com mailto:straw...@astraw.com 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 osg-users@lists.openscenegraph.org mailto:osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org mailto:osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org mailto:osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] lighting not consistent across images in osgprerendercubemap
HI Andrew, Try putting an osg::LightSource with a positional light into the scene. Robert. On 3 November 2012 13:01, Andrew Straw straw...@astraw.com 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 osg-users@lists.**openscenegraph.org osg-users@lists.openscenegraph.org http://lists.openscenegraph.**org/listinfo.cgi/osg-users-** openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] lighting not consistent across images in osgprerendercubemap
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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org