Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
LightSpacePerspectiveShadowTechnique.h
1 //
2 // LightSpacePerspectiveShadowTechnique.h
3 //
4 // It's simple because it is.
5 // It's interim because it should be replaced with something better.
6 // It's a shadow technique.
7 //
8 // Copyright (c) 2008 Virtual Terrain Project
9 // Free for all uses, see license.txt for details.
10 //
11 
12 #ifndef VTOSG_LIGHTSPACEPERSPECTIVESHADOWTECHNIQUEH
13 #define VTOSG_LIGHTSPACEPERSPECTIVESHADOWTECHNIQUEH
14 
15 #include <osg/Version>
16 #if (OSG_VERSION_MAJOR==2 && OSG_VERSION_MINOR>6) || OSG_VERSION_MAJOR>2
17 
18 #include <osgShadow/LightSpacePerspectiveShadowMap>
19 
20 // Define one of these to select the area for which shadows will be calculated
21 #define VTP_LISPSM_DRAW_BOUNDS
22 //#define VTP_LISPSM_CULL_BOUNDS
23 //#define VTP_LISPSM_VIEW_BOUNDS
24 
25 /*
26 The following methods from osgShadow::MinimalShadow are available to play with
27 I haven't got a clue what they do!
28 void setModellingSpaceToWorldTransform( const osg::Matrix & modellingSpaceToWorld )
29 void setMaxFarPlane( float maxFarPlane )
30 void setMinLightMargin( float minLightMargin )
31 void setShadowReceivingCoarseBoundAccuracy( ShadowReceivingCoarseBoundAccuracy accuracy )
32 */
33 
34 #if defined(VTP_LISPSM_DRAW_BOUNDS)
35 class CLightSpacePerspectiveShadowTechnique : public osgShadow::LightSpacePerspectiveShadowMapDB
36 #elif defined(VTP_LISPSM_CULL_BOUNDS)
37 class CLightSpacePerspectiveShadowTechnique : public osgShadow::LightSpacePerspectiveShadowMapCB
38 #elif defined(VTP_LISPSM_VIEW_BOUNDS)
39 class CLightSpacePerspectiveShadowTechnique : public osgShadow::LightSpacePerspectiveShadowMapVB
40 #endif
41 {
42 public:
44  typedef CLightSpacePerspectiveShadowTechnique ThisClass;
46 #if defined(VTP_LISPSM_DRAW_BOUNDS)
47  typedef osgShadow::LightSpacePerspectiveShadowMapDB BaseClass;
48 #elif defined(VTP_LISPSM_CULL_BOUNDS)
49  typedef osgShadow::LightSpacePerspectiveShadowMapCB BaseClass;
50 #elif defined(VTP_LISPSM_VIEW_BOUNDS)
51  typedef osgShadow::LightSpacePerspectiveShadowMapVB BaseClass;
52 #endif
53 
54  CLightSpacePerspectiveShadowTechnique();
55 
56  void InitJittering(osg::StateSet *pStateSet);
57  uint m_JitterTextureUnit;
58  void AddAdditionalTerrainTextureUnit(const uint Unit, const uint Mode);
59  void RemoveAdditionalTerrainTextureUnit(const uint Unit);
60  void RemoveAllAdditionalTerrainTextureUnits();
61 
62 protected:
63  std::string GenerateFragmentShaderSource();
64 
65  struct ViewData: public BaseClass::ViewData
66  {
67  virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
68  };
69  std::map<uint, uint> m_AdditionalTerrainTextureUnits;
70 
71  // This macro is required if you override ViewData and ViewData::init
72  // It generates virtual stub function in the Base class which
73  // calls associated ViewData::init.
74  META_ViewDependentShadowTechniqueData( ThisClass, ThisClass::ViewData )
75 };
76 
77 #endif
78 
79 #endif // VTOSG_LIGHTSPACEPERSPECTIVESHADOWTECHNIQUEH