Thanks Daniel, and sorry for the delay because of some heavy client work.

The updating of splitted Z uniforms is done in
ViewDependentShadowMap::cull(), when the new splitted value is computed
either by the callback or the inbuilt function. It should work as I've
already made use of it in the CustomShadowMap.cpp in osgshadow example.

The deletion of ShadowMapData is done
in ViewDependentShadowMap::notifyCullVisitorDeleted(). I add an observer to
each newly traversed cull visitor so it will be notified when the cull
visitor is deleted. I hope it could free the shadow data when the view is
removed. Doesn't it do anything in your applications? Could you please help
me double check if the observer works or not when you have time?

Thanks,

Wang Rui



2013/3/21 Daniel Schmid <[email protected]>

> Hi Wang
>
> I integrated your latest submission in my current project. Since I didn't
> want to patch my osg 3.1.5, I used your code side by side and changed the
> namespace to prevent clashes.
>
> The shadow runs smooth and fast. But I noticed that although there is
> support for parrallel split, the SplitterZ uniform is not evaluated in the
> fragment shader.
>
> Somehow I still didn't find the code that handles deleting of the
> ShadowMapData...
>
> I give you an extract of my code:
>
> HPP:
>
> Code:
>   class EfxViewDependentShadow : public
> osgShadowDev::ViewDependentShadowMap, public osg::Observer
>
>
>
>
> CPP
>
> Code:
>
> // ---------------------------------------------------------------
> // returns viewdependent data
> // ---------------------------------------------------------------
> osgShadowDev::ViewDependentShadowMap::ViewDependentData*
> EfxViewDependentShadow::createViewDependentData(osgUtil::CullVisitor* a_cv)
> {
>   osg::Camera* l_Camera = a_cv->getCurrentCamera();
>   if (l_Camera)
>   {
>     m_ViewMap[a_cv] = l_Camera;
>     l_Camera->addObserver(this);
>   }
>
>   return ViewDependentShadowMap::createViewDependentData(a_cv);
> }
>
> // ---------------------------------------------------------------
> // observer callback method
> // ---------------------------------------------------------------
> void EfxViewDependentShadow::objectDeleted(void* a_ptr)
> {
>   const osg::Camera* l_Camera = reinterpret_cast<const
> osg::Camera*>(a_ptr);
>
>   ViewMapType::iterator itr = m_ViewMap.begin();
>   while (itr != m_ViewMap.end())
>   {
>     osg::Camera* camera = itr->second;
>     osgUtil::CullVisitor* cv = itr->first;
>
>     if (camera == l_Camera)
>     {
>       OpenThreads::ScopedLock<OpenThreads::Mutex>
> lock(_viewDependentDataMapMutex);
>       ViewDependentDataMap::iterator itrVD =
> _viewDependentDataMap.find(cv);
>       if (itrVD != _viewDependentDataMap.end())
>       {
>         _viewDependentDataMap.erase(itrVD);
>         M_INFO("ViewDependentData has been Deleted from Map");
>       }
>
>       m_ViewMap.erase(itr);
>       itr = m_ViewMap.begin();
>
>       continue;
>     }
>     itr++;
>   }
> }
>
>
>
>
>
> Cheers
> Daniel
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=53183#53183
>
>
>
>
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to