[osg-users] View Dependent Shadow maps ( LispSM)

Wojciech Lewandowski lewandowski at ai.com.pl
Wed Jul 23 06:52:01 PDT 2008


Hi Robert and J-S (I hope you are reading this mail),

As promised (although it did not take 7 not  2 days) I have refactored LispSM and related classes to easily fit into osgShadow node kit. Attached zip contains osgShadow example + ViewDependentShadow directory with all the classes. ViewDependentShadow directory may also serve as folder for separate node kit if you decide that these files will not go into osgShadow. 

Currently all the files use ViewDependentShadow namespace but conversion to osgShadow would be as simple as search and replace of two strings:   
    "VIEWDEPENDENTSHADOW" to "OSGSHADOW" - i am using it as a prefix in headers - replace without whole words match 
    "ViewDependentShadow" to "osgShadow"  - replace using whole words match. There is ViewDependentShadowTechnique class which should not change its name.

J-S suggested that this code should be added to 2.6 release. I think that it may be bit too early for this. My opinion is that my code is quite mature and I would welcome its inclusion in OSG codebase but I am afraid that it may significantly differ from other osgShadow classes. Besides its quite large (around 5 k lines). This may create some learning problems for users. I think that before putting it in osgShadow it should be tested on the battlefield so best approach for this would be creation of advanced shadow example (for example osgSimShadows) showing advantages of this code for large terrain databases. Alternate route would be to create separate ViewDependentShadow nodekit and create similar example showing its use. 

Once the example survives tests by the users and users will show more intersest it could be put into osgShadow. I would be very grateful if Robert could do some preview of the classes attached and give me some feeedback whether he likes it or not and what to do next. I am bit swamped recently but still eager to make rearangments and fix possible issues. 

Zip contains only VS 2008 solution but testing it under other OSes should be straightforward - osgshadow makefile may require addition of remainig cpp files. osgShadow example scenes are not what this technique is aimed for but it works with them. l have implemented this technique mainly for large terrain / directional light simulation scenarios. Run osgshadow with --lispsm switch. --debugHUD adds debugging display.

Class hierarchy and short explanation follows (I will create more serious specification if it gets Okayed)

ViewDependentShadowTechnique 
    DebugShadowMap
        StandardShadowMap
            MinimalShadowMap
                MinimalCullBoundsShadowMap                
                MinimalDrawBoundsShadowMap
                    LightSpacePerspectiveShadowMap

Each class adds new layer of functionality.

ViewDependentShadowTechnique - performs similar role as ShadowTechnique with this exception that it provides neccessary framework for many Shadow resoures (Textures, Texgens etc) per many views. Derived techniques have initialization deferred to cull phase. Its somewhat similar to osgSim::OverlayNode & osgSim::OverlayNode::ViewData. 

DebugShadowMap - derived from ViewDependentShadowTechnique lays some groundwork for debugging convex hulls and shadow maps for each view.

StandardShadowMap - derived from DebugShadowMap - implements basic shadow map algorithm in accordance to ViewDependentShadowTechnique rules.

MinimalShadowMap - derived from StandardShadowMap - Iplements basic shadow scene bounds optimization. It computes convex hull intersection of Camera Frustum, Light Volume and Scene Bounds. 
Uses computed ConvexHull to optimize ShadowMap camera frustum (field of view) thus optimizing ShadowMap resolution usage. 

MinimalCullBoundsShadowMap - Derived from MinimalShadowMap. Further optimizes shadow  bounds by computing bounds from render leaves that passed ShadowReceiving scene culltraversal.               

MinimalDrawBoundsShadowMap - Derived from MinimalShadowMap. Further optimizes shadow bounds by computing bounds from scene prerendered into small resolution depth map.

LightSpacePerspectiveShadowMap - In the example its derived from MinimalCullBoundsShadowMap. With one macro it can be simply switched to derive from MinimalShadowMap or MinimalCullBoundsShadowMap or MinimalDrawBoundsShadowMap. Depending on the 
BaseClass their precision gets improved. In the final version I will change it to use template to easily switch between parent classes and allow for use of them all. Especially deriving from MinimalDrawBoundsShadowMap can do miracles in some scenarios.

Similarly TrapezoidalShadowMaps could be derived from one of MinimalXXShadowMap classes. 

Supporting classes:

ConvexHull (class based on osgSimulation::OverlayNode CustomPolytope adding few methods I needed)

Let me know what You think about all this. As one may see I treated LisPSM as an excuse to slip some other shadow supporting code. Those other classes do much more heavy work than LisPSM code. In my opinion they are more valuable and should be much more interesting for others trying to implement their shadow algorithms.  

Cheers,
Wojtek Lewandowski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/8718e335/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lispsm.zip
Type: application/x-zip-compressed
Size: 66964 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/8718e335/attachment-0002.bin>


More information about the osg-users mailing list