Re: [osg-users] osgShadow one shot shadow map
Hi J-S, > Thank you Wojtek, I'll check that out! I'm really very grateful to you > for contributing this. I've been banging my head on this and we're still > on OSG 2.2 here so I didn't think of going to see in the new additions > if there was something that would help me out. You're welcome. I am glad I could help. Wojtek ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hello Wojtek, > And thats it. Thank you Robert ! Thank you Wojtek, I'll check that out! I'm really very grateful to you for contributing this. I've been banging my head on this and we're still on OSG 2.2 here so I didn't think of going to see in the new additions if there was something that would help me out. Thanks again, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hi J-S, >This is the part I'm having trouble with. I actually don't mind using >the scene bound I get with the ComputeBoundingBoxVisitor, but getting a >usable camera frustum (both for main and light cameras) and then >intersecting those is the hard part for me. Any tips there? How do you >create the convex objects? How do you do the intersection itself? This piece of code was actually written by Robert ;-). I use his utility CustomPolytope class from osgSim::OverlayNode.cpp. It computes the intersection of two polytopes. Its named CustomPolytope but it does work well as convex hull representation. I attached this class repacked into separate header. Its identical to CustomPolytope from OverlayNode with one bug fixed in my version. I submitted this fix to OverlayNode.cpp but its still pending. So I suggest to use my header before Robert returns. Code for computing frustum polytope is obvious provided we have camera view & projection matrices: / osg::Matrix mvp = camera->getViewMatrix() * camera->getProjectionMatrix(); CustomPolytope cpCameraFrustum; cpCameraFrustum.setToUnitFrustum( ); // transform frustum from clip space into world coords cpCameraFrustum.transform( osg::Matrix::inverse( mvp ), mvp ); / Of course there is also a method to build CustomPolytope from bounding box: / CustomPolytope cpSceneBounds; cp.setToBoundingBox( sceneBounds ); / Computing intersection is straight forward Suppose we have two polytopes for main camera frustum & coarse shadow camera frustum and scene bounds polytope. / CustomPolytope cpMainCamera, cpCoarseShadowCamera, cpSceneBounds; CustomPolytope cpIntersection( cpSceneBounds ); cpIntersection.cut( cpMainCamera ); cpIntersection.cut( cpCoarseShadowCamera ); / CustomPolytope::getVertices returns corners of the convex hull so its easy to find its bounding box. I compute precise shadow camera projection using such bounding box around intersection polytope transformed to shadow space. And thats it. Thank you Robert ! Wojtek Lewandowski #ifndef CUSTOMPOLYTOPE_H #define CUSTOMPOLYTOPE_H #include #include #include // Class directly copied osgSim::OverlayNode (+prefixed few Vec3d occurences with osg::) class CustomPolytope { public: CustomPolytope() {} typedef std::vector Vertices; struct Face { std::string name; osg::Plane plane; Verticesvertices; }; Face& createFace() { _faces.push_back(Face()); return _faces.back(); } /** Create a Polytope which is a cube, centered at 0,0,0, with sides of 2 units.*/ void setToUnitFrustum(bool withNear=true, bool withFar=true) { const osg::Vec3d v000(-1.0,-1.0,-1.0); const osg::Vec3d v010(-1.0,1.0,-1.0); const osg::Vec3d v001(-1.0,-1.0,1.0); const osg::Vec3d v011(-1.0,1.0,1.0); const osg::Vec3d v100(1.0,-1.0,-1.0); const osg::Vec3d v110(1.0,1.0,-1.0); const osg::Vec3d v101(1.0,-1.0,1.0); const osg::Vec3d v111(1.0,1.0,1.0); _faces.clear(); { // left plane. Face& face = createFace(); face.name = "left"; face.plane.set(1.0,0.0,0.0,1.0); face.vertices.push_back(v000); face.vertices.push_back(v001); face.vertices.push_back(v011); face.vertices.push_back(v010); } { // right plane. Face& face = createFace(); face.name = "right"; face.plane.set(-1.0,0.0,0.0,1.0); face.vertices.push_back(v100); face.vertices.push_back(v110); face.vertices.push_back(v111); face.vertices.push_back(v101); } { // bottom plane. Face& face = createFace(); face.name = "bottom"; face.plane.set(0.0,1.0,0.0,1.0); face.vertices.push_back(v000); face.vertices.push_back(v100); face.vertices.push_back(v101); face.vertices.push_back(v001); } { // top plane. Face& face = createFace(); face.name = "top"; face.plane.set(0.0,-1.0,0.0,1.0); face.vertices.push_back(v111); face.vertices.push_back(v011); face.vertices.push_back(v010); face.vertices.push_back(v110); } if (withNear) { // near plane Face& face = createFace(); face.name = "near"; face.plane.set(0.0,0.0,1.0,1.0); face.vertices.push_back(v000); face.vertices.push_back(v010); face.vertices.push_back(v110); face.vertices.push_back(v100); } if (withFar) { // far plane Face& face = createFace(); face.nam
Re: [osg-users] osgShadow one shot shadow map
Hello Wojtek, > then I compute intersection of this convex scene hull with main camera > frustum and coarse light (shadow) camera frustum. This produces my > minimal scene bound polytope which I then use to further narrow shadow > camera projection. This is the part I'm having trouble with. I actually don't mind using the scene bound I get with the ComputeBoundingBoxVisitor, but getting a usable camera frustum (both for main and light cameras) and then intersecting those is the hard part for me. Any tips there? How do you create the convex objects? How do you do the intersection itself? Any guidance in this would be useful. Thanks, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hi, I developed two methods to compute convex hull of visible scene portion: A: one based on cull stage I scan render leaves generated by main camera cull traversal and compute minimal convex hull around them B: second based on draw stage I prerender the scene to small resolution depth texture (64x64) and compute convex hull around valid points stored in this texture then I compute intersection of this convex scene hull with main camera frustum and coarse light (shadow) camera frustum. This produces my minimal scene bound polytope which I then use to further narrow shadow camera projection. Prerender based approach is somewhat radical but produces really good results with my LispSM. Cull based approach is more precise but works well only with fairly small drawables (ie when their bounding boxes are much smaller than frustum). I don't know how useful it may be for you. We make flight sim renderer so my work was mostly oriented towards elipsoid based large terrain / directional light case. But if you do something similar then we may exchange some experiences. I do plan on contributing some of this work with LispSM but will need to finish it first ;-). Cheers, Wojtek - Original Message - From: "Jean-Sébastien Guay" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; "OpenSceneGraph Users" Sent: Tuesday, February 12, 2008 2:54 PM Subject: Re: [osg-users] osgShadow one shot shadow map > Hello Wojtek, > >> Actually most of the time was spent >> on algorithms finding minimal shadowed scene bounds under OSG. It was a >> key >> to good shadow mapping results. > > Well, that's what I'm working on right now too! If you are planning on > contributing this sometime, would it be possible for you to help me with > this? It would save me lots of time. > > I have something that works pretty well, but only if the camera > manipulator is a Trackball Manipulator (for the getCenter() method) - I > essentially get the smallest of either the scene bound or the camera view > volume. > > If I could have something that works well in more cases, it would be very > useful. > > Thanks in advance, > > J-S > -- > __ > Jean-Sebastien Guay[EMAIL PROTECTED] >http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hello Wojtek, > Actually most of the time was spent > on algorithms finding minimal shadowed scene bounds under OSG. It was a key > to good shadow mapping results. Well, that's what I'm working on right now too! If you are planning on contributing this sometime, would it be possible for you to help me with this? It would save me lots of time. I have something that works pretty well, but only if the camera manipulator is a Trackball Manipulator (for the getCenter() method) - I essentially get the smallest of either the scene bound or the camera view volume. If I could have something that works well in more cases, it would be very useful. Thanks in advance, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hi, > will this implementation be avaible for the osg community, new shadow > implementation ? Yes. Thats my intent. I derived it from osgShadow::ShadowMap - it could be integrated with osgShadow. But I had to create a bunch of supporting classes, so after all, the code may not be clean enough to place it directly as new shadow algorithm in osgShadow lib. I will probably first create some sort of example and if Robert and community gives it green light I may repack it into osgShadow::LispSM. But don't expect this too soon ;-(. I won't have time to this in this month. I will try to submit it around the end of March. Wojtek - Original Message - From: Adrian Egli OpenSceneGraph (3D) To: [EMAIL PROTECTED] ; OpenSceneGraph Users Sent: Tuesday, February 12, 2008 8:40 AM Subject: Re: [osg-users] osgShadow one shot shadow map Hi will this implementation be avaible for the osg community, new shadow implementation ? 2008/2/11, Wojciech Lewandowski <[EMAIL PROTECTED]>: I implemented Trapezoidal and LiSpPSM. Actually most of the time was spent on algorithms finding minimal shadowed scene bounds under OSG. It was a key to good shadow mapping results. I will try to contribute LispSM when I am done with all the issues. Cheers, Wojtek -Original Message- From: Jean-Sébastien Guay [mailto:[EMAIL PROTECTED] Sent: Monday, February 11, 2008 9:29 PM To: [EMAIL PROTECTED]; OpenSceneGraph Users Subject: Re: [osg-users] osgShadow one shot shadow map Hello Wojtek, > I have spent couple months banging my head against the wall, implementing > perspective shadow mapping algortihms and that is the only rason I know how > osgShadow::ShadowMap works ;-). Hehehe, I suspect I am on the same road, so only a few months to go if your assessment is correct :-) Any chance you would contribute the PSM implementation? It would make one more on the list. :-) Thanks, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Adrian Egli ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hi, I've implemented this and it works reasonably well. But there is a catch though ... When creating my shadowed scene (usually by loading elements) I set the ShadowMap to "updateMode" in order to render the new Elements. However, due to multithreading I need a way to be certain, that all elements are drawn. Is there a callback I can use? cheers Sebastian > Hi Wojciech, > > Thanks for clarifying. I was looking into it yesterday but didn't find > the right spots. > Maybe this could be integrated into the current implementation. I'm > pretty sure it might be usefull for other users too. > > >> Hi, >> >> ShadowMap::cull invokes culls traversal for both main camera >> (ShadowReceiving) graph & shadow camera (ShadowCasting) graphs. So if you >> block whole cull on ShadowMap level - it won't draw the scene as well. The >> trick is to block only the portion that culls ShadowCasting graph. >> >> See the osgShadow::ShadowMap::cull method (src/ osgShadow / ShadowMap.cpp) >> >> Line 330: _shadowedScene->osg::Group::traverse(cv); >> Thats the line where Scene traversal is invoked >> >> & >> >> Line 469 : _camera->accept(cv); >> Thats the line which calls cull traversal on Shadow Map camera. >> >> >> Cheers, >> Wojtek Lewandowski >> >> >> ----- Original Message - >> From: "Jean-Sébastien Guay" <[EMAIL PROTECTED]> >> To: "OpenSceneGraph Users" >> Sent: Monday, February 11, 2008 4:20 PM >> Subject: Re: [osg-users] osgShadow one shot shadow map >> >> >> >> >>> Hello Sebastian, >>> >>> >>> >>>> I'm quite confused regarding the osgShadow implementation. >>>> My scene and my light-positions are static. My idea was to capture the >>>> shadow-map only once >>>> and apply it consecutively in all frames. I'm a bit lost where to start. >>>> Neither update nor cull seems to be the right place. >>>> Any hints? >>>> >>>> >>> As you have seen, it was not designed to do that. It's designed to >>> recalculate the shadow map each frame. I guess you could add a boolean >>> to it to say that it has been calculated, and then not redo it again... >>> Maybe just something like: >>> >>> class myShadowMap : public osgShadow::ShadowMap >>> { >>> public: >>> myShadowMap() : _done(false) {} >>> >>> virtual void update(osg::NodeVisitor& nv) >>> { >>> if (!_done) >>> osgShadow::ShadowMap::update(nv); >>> } >>> >>> virtual void cull(osgUtil::CullVisitor& cv) >>> { >>> if (!_done) >>> { >>> osgShadow::ShadowMap::cull(cv); >>> _done = true; >>> } >>> } >>> >>> private: >>> bool _done; >>> }; >>> >>> Note that I didn't try this, but it might give you something to start >>> with? Let us know how it goes. >>> >>> Hope this helps, >>> >>> J-S >>> -- >>> __ >>> Jean-Sebastien Guay[EMAIL PROTECTED] >>>http://www.cm-labs.com/ >>> http://whitestar02.webhop.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 >> >> >> > > ___ > 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] osgShadow one shot shadow map
Hi Wojciech, Thanks for clarifying. I was looking into it yesterday but didn't find the right spots. Maybe this could be integrated into the current implementation. I'm pretty sure it might be usefull for other users too. > Hi, > > ShadowMap::cull invokes culls traversal for both main camera > (ShadowReceiving) graph & shadow camera (ShadowCasting) graphs. So if you > block whole cull on ShadowMap level - it won't draw the scene as well. The > trick is to block only the portion that culls ShadowCasting graph. > > See the osgShadow::ShadowMap::cull method (src/ osgShadow / ShadowMap.cpp) > > Line 330: _shadowedScene->osg::Group::traverse(cv); > Thats the line where Scene traversal is invoked > > & > > Line 469 : _camera->accept(cv); > Thats the line which calls cull traversal on Shadow Map camera. > > > Cheers, > Wojtek Lewandowski > > > - Original Message - > From: "Jean-Sébastien Guay" <[EMAIL PROTECTED]> > To: "OpenSceneGraph Users" > Sent: Monday, February 11, 2008 4:20 PM > Subject: Re: [osg-users] osgShadow one shot shadow map > > > >> Hello Sebastian, >> >> >>> I'm quite confused regarding the osgShadow implementation. >>> My scene and my light-positions are static. My idea was to capture the >>> shadow-map only once >>> and apply it consecutively in all frames. I'm a bit lost where to start. >>> Neither update nor cull seems to be the right place. >>> Any hints? >>> >> As you have seen, it was not designed to do that. It's designed to >> recalculate the shadow map each frame. I guess you could add a boolean >> to it to say that it has been calculated, and then not redo it again... >> Maybe just something like: >> >> class myShadowMap : public osgShadow::ShadowMap >> { >> public: >> myShadowMap() : _done(false) {} >> >> virtual void update(osg::NodeVisitor& nv) >> { >> if (!_done) >> osgShadow::ShadowMap::update(nv); >> } >> >> virtual void cull(osgUtil::CullVisitor& cv) >> { >> if (!_done) >> { >> osgShadow::ShadowMap::cull(cv); >> _done = true; >> } >> } >> >> private: >> bool _done; >> }; >> >> Note that I didn't try this, but it might give you something to start >> with? Let us know how it goes. >> >> Hope this helps, >> >> J-S >> -- >> __ >> Jean-Sebastien Guay[EMAIL PROTECTED] >>http://www.cm-labs.com/ >> http://whitestar02.webhop.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 > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hi will this implementation be avaible for the osg community, new shadow implementation ? 2008/2/11, Wojciech Lewandowski <[EMAIL PROTECTED]>: > > I implemented Trapezoidal and LiSpPSM. Actually most of the time was spent > on algorithms finding minimal shadowed scene bounds under OSG. It was a > key > to good shadow mapping results. I will try to contribute LispSM when I am > done with all the issues. > > Cheers, > Wojtek > > > -Original Message- > From: Jean-Sébastien Guay [mailto:[EMAIL PROTECTED] > Sent: Monday, February 11, 2008 9:29 PM > To: [EMAIL PROTECTED]; OpenSceneGraph Users > Subject: Re: [osg-users] osgShadow one shot shadow map > > > Hello Wojtek, > > > I have spent couple months banging my head against the wall, > implementing > > perspective shadow mapping algortihms and that is the only rason I know > how > > osgShadow::ShadowMap works ;-). > > Hehehe, I suspect I am on the same road, so only a few months to go if > your assessment is correct :-) > > Any chance you would contribute the PSM implementation? It would make > one more on the list. :-) > > Thanks, > > J-S > -- > __ > Jean-Sebastien Guay[EMAIL PROTECTED] > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Adrian Egli ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
I implemented Trapezoidal and LiSpPSM. Actually most of the time was spent on algorithms finding minimal shadowed scene bounds under OSG. It was a key to good shadow mapping results. I will try to contribute LispSM when I am done with all the issues. Cheers, Wojtek -Original Message- From: Jean-Sébastien Guay [mailto:[EMAIL PROTECTED] Sent: Monday, February 11, 2008 9:29 PM To: [EMAIL PROTECTED]; OpenSceneGraph Users Subject: Re: [osg-users] osgShadow one shot shadow map Hello Wojtek, > I have spent couple months banging my head against the wall, implementing > perspective shadow mapping algortihms and that is the only rason I know how > osgShadow::ShadowMap works ;-). Hehehe, I suspect I am on the same road, so only a few months to go if your assessment is correct :-) Any chance you would contribute the PSM implementation? It would make one more on the list. :-) Thanks, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hello Wojtek, > I have spent couple months banging my head against the wall, implementing > perspective shadow mapping algortihms and that is the only rason I know how > osgShadow::ShadowMap works ;-). Hehehe, I suspect I am on the same road, so only a few months to go if your assessment is correct :-) Any chance you would contribute the PSM implementation? It would make one more on the list. :-) Thanks, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
I have spent couple months banging my head against the wall, implementing perspective shadow mapping algortihms and that is the only rason I know how osgShadow::ShadowMap works ;-). Wojtek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jean-Sebastien Guay Sent: Monday, February 11, 2008 7:16 PM To: OpenSceneGraph Users Subject: Re: [osg-users] osgShadow one shot shadow map Hello Wojtek, > ShadowMap::cull invokes culls traversal for both main camera > (ShadowReceiving) graph & shadow camera (ShadowCasting) graphs. So if you > block whole cull on ShadowMap level - it won't draw the scene as well. The > trick is to block only the portion that culls ShadowCasting graph. Cool, thanks for clearing that up! I didn't know, haven't looked at the code long enough it seems :-) J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.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] osgShadow one shot shadow map
Hello Wojtek, > ShadowMap::cull invokes culls traversal for both main camera > (ShadowReceiving) graph & shadow camera (ShadowCasting) graphs. So if you > block whole cull on ShadowMap level - it won't draw the scene as well. The > trick is to block only the portion that culls ShadowCasting graph. Cool, thanks for clearing that up! I didn't know, haven't looked at the code long enough it seems :-) J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgShadow one shot shadow map
Hi, ShadowMap::cull invokes culls traversal for both main camera (ShadowReceiving) graph & shadow camera (ShadowCasting) graphs. So if you block whole cull on ShadowMap level - it won't draw the scene as well. The trick is to block only the portion that culls ShadowCasting graph. See the osgShadow::ShadowMap::cull method (src/ osgShadow / ShadowMap.cpp) Line 330: _shadowedScene->osg::Group::traverse(cv); Thats the line where Scene traversal is invoked & Line 469 : _camera->accept(cv); Thats the line which calls cull traversal on Shadow Map camera. Cheers, Wojtek Lewandowski - Original Message - From: "Jean-Sébastien Guay" <[EMAIL PROTECTED]> To: "OpenSceneGraph Users" Sent: Monday, February 11, 2008 4:20 PM Subject: Re: [osg-users] osgShadow one shot shadow map > Hello Sebastian, > >> I'm quite confused regarding the osgShadow implementation. >> My scene and my light-positions are static. My idea was to capture the >> shadow-map only once >> and apply it consecutively in all frames. I'm a bit lost where to start. >> Neither update nor cull seems to be the right place. >> Any hints? > > As you have seen, it was not designed to do that. It's designed to > recalculate the shadow map each frame. I guess you could add a boolean > to it to say that it has been calculated, and then not redo it again... > Maybe just something like: > > class myShadowMap : public osgShadow::ShadowMap > { > public: > myShadowMap() : _done(false) {} > > virtual void update(osg::NodeVisitor& nv) > { > if (!_done) > osgShadow::ShadowMap::update(nv); > } > > virtual void cull(osgUtil::CullVisitor& cv) > { > if (!_done) > { > osgShadow::ShadowMap::cull(cv); > _done = true; > } > } > > private: > bool _done; > }; > > Note that I didn't try this, but it might give you something to start > with? Let us know how it goes. > > Hope this helps, > > J-S > -- > __ > Jean-Sebastien Guay[EMAIL PROTECTED] >http://www.cm-labs.com/ > http://whitestar02.webhop.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] osgShadow one shot shadow map
Hello Sebastian, > I'm quite confused regarding the osgShadow implementation. > My scene and my light-positions are static. My idea was to capture the > shadow-map only once > and apply it consecutively in all frames. I'm a bit lost where to start. > Neither update nor cull seems to be the right place. > Any hints? As you have seen, it was not designed to do that. It's designed to recalculate the shadow map each frame. I guess you could add a boolean to it to say that it has been calculated, and then not redo it again... Maybe just something like: class myShadowMap : public osgShadow::ShadowMap { public: myShadowMap() : _done(false) {} virtual void update(osg::NodeVisitor& nv) { if (!_done) osgShadow::ShadowMap::update(nv); } virtual void cull(osgUtil::CullVisitor& cv) { if (!_done) { osgShadow::ShadowMap::cull(cv); _done = true; } } private: bool _done; }; Note that I didn't try this, but it might give you something to start with? Let us know how it goes. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org