Re: [osg-users] Shadows in OSG
Hi Linda, Its large and advanced topic. Various techniques work in different way. I simply do not have the time to explain it. Besides, I follow the rule to not respond in much more words than question asked (hint). If you are interested in Shadow Mapping I may recomend starting from osgShadow::ShadowMap implementation. See ShadowMap::cull method. Its the place where all the relevant code is located. However be warned, that to fully understand it one needs to understand how OSG culling and rendering backend works so its really stuff for advanced developers. Wojtek -Oryginalna wiadomość- From: Linda Lee Sent: Monday, January 17, 2011 2:42 PM To: osg-users@lists.openscenegraph.org Subject: Re: [osg-users] Shadows in OSG Hi, How about learning the way OSG structures the shadow code. I found it difficult understanding how OSG manage shadow. Could anyone briefly explain the shadow codes in OSG or is there any way I could learn more on them? Thank you! Cheers, Linda -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35694#35694 ___ 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] Shadows in OSG
I suggest looking at StandardShadowMap, MinimalShadowMap and the various LiSPSM variations; based on my experience with osg 2.8.3 they offer the most robust implementation of shadows. There is also a debugging mode that you can enable that renders the depth map which is extremely useful. As Wojtek said, dynamic shadows are a pretty advanced topic, you will need a good theoretical understanding before diving into the particulars of how osg manages it. On 1/17/2011 8:42 AM, Linda Lee wrote: Hi, How about learning the way OSG structures the shadow code. I found it difficult understanding how OSG manage shadow. Could anyone briefly explain the shadow codes in OSG or is there any way I could learn more on them? Thank you! Cheers, Linda -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35694#35694 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Peter Amstutz Senior Software Engineer Technology Solutions Experts Natick, MA 02131 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shadows in OSG
I suggest this presentaton to learn basics: http://developer.nvidia.com/object/cedec_shadowmap.html and then this page offers enough reading for months ;-): http://developer.nvidia.com/object/doc_shadows.html Wojtek Lewandowski -Oryginalna wiadomość- From: Linda Lee Sent: Monday, January 17, 2011 4:51 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Shadows in OSG Hi everyone, I am trying to learn to the detail implementation of shadowing in OSG and maybe to develop my own shadow technique. Could anyone give some advices on where I should get started or if there is any online resources that I could start learning with? Thank you! Cheers, Linda -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35673#35673 ___ 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] Shadows in OSG
Hi, How about learning the way OSG structures the shadow code. I found it difficult understanding how OSG manage shadow. Could anyone briefly explain the shadow codes in OSG or is there any way I could learn more on them? Thank you! Cheers, Linda -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35694#35694 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Shadows in OSG
Hi everyone, I am trying to learn to the detail implementation of shadowing in OSG and maybe to develop my own shadow technique. Could anyone give some advices on where I should get started or if there is any online resources that I could start learning with? Thank you! Cheers, Linda -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35673#35673 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Shadows and osg::Fog?
Hi, I'm wondering if anyone tried the combination of SoftShadowMap shadows and osg::Fog. With 2.2.0 and svn I've tried to use it with SoftShadowMap but that's not working. I suspect that it's not working because of the shader that's being used, but that's just a guess. ShadowTexture and ShadowVolume (both fixed OpenGL) are both working ok with fog and the other shadow techniques are not, and these are all using shaders. Is osg::Fog supposed to work with shadows based on shaders? Or more general, is osg::Fog supposed to work in combination with shaders? thanks a lot Raymond Please find attached the adapted osgshadow.cpp example /* OpenSceneGraph example, osgshadow. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include osg/ArgumentParser #include osg/ComputeBoundsVisitor #include osg/Texture2D #include osg/ShapeDrawable #include osg/MatrixTransform #include osg/Fog #include osg/Geometry #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/AnimationPathManipulator #include osgGA/TerrainManipulator #include osgGA/AnimationPathManipulator #include osgGA/StateSetManipulator #include osgViewer/Viewer #include osgViewer/ViewerEventHandlers #include osgShadow/ShadowedScene #include osgShadow/ShadowVolume #include osgShadow/ShadowTexture #include osgShadow/ShadowMap #include osgShadow/SoftShadowMap #include osgShadow/ParallelSplitShadowMap #include osgDB/ReadFile #include osgDB/WriteFile #include iostream // for the grid data.. #include ../osghangglide/terrain_coords.h const int ReceivesShadowTraversalMask = 0x1; const int CastsShadowTraversalMask = 0x2; namespace ModelOne { enum Faces { FRONT_FACE = 1, BACK_FACE = 2, LEFT_FACE = 4, RIGHT_FACE = 8, TOP_FACE = 16, BOTTOM_FACE = 32 }; osg::Node* createCube(unsigned int mask) { osg::Geode* geode = new osg::Geode; osg::Geometry* geometry = new osg::Geometry; geode-addDrawable(geometry); osg::Vec3Array* vertices = new osg::Vec3Array; geometry-setVertexArray(vertices); osg::Vec3Array* normals = new osg::Vec3Array; geometry-setNormalArray(normals); geometry-setNormalBinding(osg::Geometry::BIND_PER_VERTEX); osg::Vec4Array* colours = new osg::Vec4Array; geometry-setColorArray(colours); geometry-setColorBinding(osg::Geometry::BIND_OVERALL); colours-push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); osg::Vec3 origin(0.0f,0.0f,0.0f); osg::Vec3 dx(2.0f,0.0f,0.0f); osg::Vec3 dy(0.0f,1.0f,0.0f); osg::Vec3 dz(0.0f,0.0f,1.0f); osg::Vec3 px(1.0f,0.0,0.0f); osg::Vec3 nx(-1.0f,0.0,0.0f); osg::Vec3 py(0.0f,1.0f,0.0f); osg::Vec3 ny(0.0f,-1.0f,0.0f); osg::Vec3 pz(0.0f,0.0f,1.0f); osg::Vec3 nz(0.0f,0.0f,-1.0f); if (mask FRONT_FACE) { // front face vertices-push_back(origin); vertices-push_back(origin+dx); vertices-push_back(origin+dx+dz); vertices-push_back(origin+dz); normals-push_back(ny); normals-push_back(ny); normals-push_back(ny); normals-push_back(ny); } if (mask BACK_FACE) { // back face vertices-push_back(origin+dy); vertices-push_back(origin+dy+dz); vertices-push_back(origin+dy+dx+dz); vertices-push_back(origin+dy+dx); normals-push_back(py); normals-push_back(py); normals-push_back(py); normals-push_back(py); } if (mask LEFT_FACE) { // left face vertices-push_back(origin+dy); vertices-push_back(origin); vertices-push_back(origin+dz); vertices-push_back(origin+dy+dz); normals-push_back(nx); normals-push_back(nx); normals-push_back(nx);
Re: [osg-users] Shadows and osg::Fog?
Aha, I guessed that, thanks for the confirmation. So you say that fog should be part of the shadow shader, and not a separate, extra one. I did not do that much with shaders yet, except for using the osg-included ones. I cannot have a hierarchy of nodes with shaders, I guess? If I cannot have a hierarchy, should I be able to setup a RTT and apply the fog shader to the RTTs stateset? I'd rather not put it in the shader since it's not reusable then. Thanks again Raymond Robert Osfield wrote: HI Raynond, osg::Fog wraps up glFog, which is part of OpenGL's fixed function pipeline. As soon as you enable shaders you loose fog support unless you shaders directly include a fog shader in them. Robert. On Wed, Mar 19, 2008 at 2:26 PM, Raymond de Vries [EMAIL PROTECTED] wrote: Hi, I'm wondering if anyone tried the combination of SoftShadowMap shadows and osg::Fog. With 2.2.0 and svn I've tried to use it with SoftShadowMap but that's not working. I suspect that it's not working because of the shader that's being used, but that's just a guess. ShadowTexture and ShadowVolume (both fixed OpenGL) are both working ok with fog and the other shadow techniques are not, and these are all using shaders. Is osg::Fog supposed to work with shadows based on shaders? Or more general, is osg::Fog supposed to work in combination with shaders? thanks a lot Raymond Please find attached the adapted osgshadow.cpp example /* OpenSceneGraph example, osgshadow. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include osg/ArgumentParser #include osg/ComputeBoundsVisitor #include osg/Texture2D #include osg/ShapeDrawable #include osg/MatrixTransform #include osg/Fog #include osg/Geometry #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/AnimationPathManipulator #include osgGA/TerrainManipulator #include osgGA/AnimationPathManipulator #include osgGA/StateSetManipulator #include osgViewer/Viewer #include osgViewer/ViewerEventHandlers #include osgShadow/ShadowedScene #include osgShadow/ShadowVolume #include osgShadow/ShadowTexture #include osgShadow/ShadowMap #include osgShadow/SoftShadowMap #include osgShadow/ParallelSplitShadowMap #include osgDB/ReadFile #include osgDB/WriteFile #include iostream // for the grid data.. #include ../osghangglide/terrain_coords.h const int ReceivesShadowTraversalMask = 0x1; const int CastsShadowTraversalMask = 0x2; namespace ModelOne { enum Faces { FRONT_FACE = 1, BACK_FACE = 2, LEFT_FACE = 4, RIGHT_FACE = 8, TOP_FACE = 16, BOTTOM_FACE = 32 }; osg::Node* createCube(unsigned int mask) { osg::Geode* geode = new osg::Geode; osg::Geometry* geometry = new osg::Geometry; geode-addDrawable(geometry); osg::Vec3Array* vertices = new osg::Vec3Array; geometry-setVertexArray(vertices); osg::Vec3Array* normals = new osg::Vec3Array; geometry-setNormalArray(normals); geometry-setNormalBinding(osg::Geometry::BIND_PER_VERTEX); osg::Vec4Array* colours = new osg::Vec4Array; geometry-setColorArray(colours); geometry-setColorBinding(osg::Geometry::BIND_OVERALL); colours-push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); osg::Vec3 origin(0.0f,0.0f,0.0f); osg::Vec3 dx(2.0f,0.0f,0.0f); osg::Vec3 dy(0.0f,1.0f,0.0f); osg::Vec3 dz(0.0f,0.0f,1.0f); osg::Vec3 px(1.0f,0.0,0.0f); osg::Vec3 nx(-1.0f,0.0,0.0f); osg::Vec3 py(0.0f,1.0f,0.0f); osg::Vec3 ny(0.0f,-1.0f,0.0f); osg::Vec3 pz(0.0f,0.0f,1.0f); osg::Vec3 nz(0.0f,0.0f,-1.0f); if (mask FRONT_FACE) { // front face vertices-push_back(origin); vertices-push_back(origin+dx); vertices-push_back(origin+dx+dz);
Re: [osg-users] Shadows and osg::Fog?
Hi, Composing shaders is next to impossible in a general pupose way, each GLSL Program needs to know all the shaders that contribute to it and have a main shader that glues them all together. Ok, I understand, this would be tricky indeed. And again hard-coded in some (other) way ;-) I am aware of trying to mix shaders with self contained technique likes osgShadow has, so in a future rev I believe we'll need to make the osg::Program and the shaders that it uses publically accessible so users can write their own but leveraging the uniforms and shaders that the osgShadow routines use. Hmm, that would be cool indeed. Another issue on the long list... I actually meant another way of building a hierarchy of nodes with shaders. Would something like: scenedata | |-- osg::Node with fog osg::Program | |-- osgShadow::ShadowedScene | |-- models with proper shadow mask... be possible? Or is this (also) not possible. thanks Raymond Robert. On Wed, Mar 19, 2008 at 2:42 PM, Raymond de Vries [EMAIL PROTECTED] wrote: Aha, I guessed that, thanks for the confirmation. So you say that fog should be part of the shadow shader, and not a separate, extra one. I did not do that much with shaders yet, except for using the osg-included ones. I cannot have a hierarchy of nodes with shaders, I guess? If I cannot have a hierarchy, should I be able to setup a RTT and apply the fog shader to the RTTs stateset? I'd rather not put it in the shader since it's not reusable then. Thanks again Raymond Robert Osfield wrote: HI Raynond, osg::Fog wraps up glFog, which is part of OpenGL's fixed function pipeline. As soon as you enable shaders you loose fog support unless you shaders directly include a fog shader in them. Robert. On Wed, Mar 19, 2008 at 2:26 PM, Raymond de Vries [EMAIL PROTECTED] wrote: Hi, I'm wondering if anyone tried the combination of SoftShadowMap shadows and osg::Fog. With 2.2.0 and svn I've tried to use it with SoftShadowMap but that's not working. I suspect that it's not working because of the shader that's being used, but that's just a guess. ShadowTexture and ShadowVolume (both fixed OpenGL) are both working ok with fog and the other shadow techniques are not, and these are all using shaders. Is osg::Fog supposed to work with shadows based on shaders? Or more general, is osg::Fog supposed to work in combination with shaders? thanks a lot Raymond Please find attached the adapted osgshadow.cpp example /* OpenSceneGraph example, osgshadow. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include osg/ArgumentParser #include osg/ComputeBoundsVisitor #include osg/Texture2D #include osg/ShapeDrawable #include osg/MatrixTransform #include osg/Fog #include osg/Geometry #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/AnimationPathManipulator #include osgGA/TerrainManipulator #include osgGA/AnimationPathManipulator #include osgGA/StateSetManipulator #include osgViewer/Viewer #include osgViewer/ViewerEventHandlers #include osgShadow/ShadowedScene #include osgShadow/ShadowVolume #include osgShadow/ShadowTexture #include osgShadow/ShadowMap #include osgShadow/SoftShadowMap #include osgShadow/ParallelSplitShadowMap #include osgDB/ReadFile #include osgDB/WriteFile #include iostream // for the grid data.. #include ../osghangglide/terrain_coords.h const int ReceivesShadowTraversalMask = 0x1; const int CastsShadowTraversalMask = 0x2; namespace ModelOne { enum Faces { FRONT_FACE = 1, BACK_FACE = 2, LEFT_FACE = 4, RIGHT_FACE = 8, TOP_FACE = 16, BOTTOM_FACE = 32