VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Friends
makVrv::DtOsgShadowTechnique Class Reference

The DtOsgShadowTechnique class implements a robust shadow mapping system. More...

Inheritance diagram for makVrv::DtOsgShadowTechnique:
Inheritance graph
[legend]

Classes

struct  CameraDescription
struct  CascadeImportanceData
struct  CloudShadowPreDrawCallback
struct  CsmSplitData
struct  PerChannelData

Public Member Functions

 DtOsgShadowTechnique (DtDe &de)
 CTOR.
 DtOsgShadowTechnique (const DtOsgShadowTechnique &es, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 DTOR.
virtual osg::Object * cloneType () const
 Creates a new object of Type DtOsgShadowTechnique.
virtual osg::Object * clone (const osg::CopyOp &copyop) const
 Creates a new copy of DtOsgShadowTechnique object.
virtual bool isSameKindAs (const osg::Object *obj) const
 Returns true if object is of the DtOsgShadowTechnique class. Otherwise, returns false.
virtual const charlibraryName () const
 Returns the namespace string.
virtual const charclassName () const
 Returns the class name string.
virtual void init ()
 Overrides the osgShadow::ShadowTechnique::init method.
virtual void postConstructionInit ()
 another init function
virtual void update (osg::NodeVisitor &nv)
 Overrides the osgShadow::ShadowTechnique::update method.
virtual void cull (osgUtil::CullVisitor &cv)
 Overrides the osgShadow::ShadowTechnique::cull method.
virtual void cleanSceneGraph ()
 Overrides the osgShadow::ShadowTechnique::cleanSceneGraph method.
void setChannelShadowState (DtOsgChannel *osgChannel, bool enable)
 Set the shadow mode for channels.
bool getChannelShadowSettings (DtOsgChannel *osgChannel, DtShadowSettingsObject **shadowSettingObject, bool *isPlanView)
 Gets the shadow settings for this channel.
bool getCameraCloudShadowMap (osg::Camera *camera, unsigned int *textureIndex, osg::Matrix *textureViewProjMatrix, unsigned int *textureIndex2, osg::Matrix *textureViewProjMatrix2)
 Gets the cloud shadow map for this camera.
void setGlobalLight (osg::LightSource *light)
 Sets global light source.
const osg::LightSource * getGlobalLight () const
 Gets global light source.
const osg::StateSet * mapCameraToStateSet (const osg::Camera *camera) const
 returns shared state set uniform infor for this camera, may be null

Static Public Member Functions

static const std::string & shadowCameraPrefixString (void)
static const std::string & shadowSDSMCameraPrefixString (void)

Public Attributes

class ShadowTweakables * myShadowUI

Static Public Attributes

static const int MAX_NUM_CASCADES = 6

Protected Types

typedef std::map< const
osg::Camera *, osg::ref_ptr
< PerChannelData > > 
PerChannelDataMap

Protected Member Functions

virtual void reInitialize (unsigned int quality)
 Re-initialize perChannelData using the specified quality setting.
virtual bool configureShadowTraversalNodeMask (bool traverseEntities, bool traverseProps, bool traverseTerrain)
virtual void slot_refresh_maps ()
virtual std::string generateVertexShader (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Generates an optimized vertex shader given the shadow settings.
virtual std::string generateFragmentShader (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Generates an optimized fragment shader given the shadow settings.
virtual std::string generateCloudShadowVertexShader (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Generates an cloud shadow vertex shader given the shadow settings.
unsigned int getFilterCount (DtShadowSettingsObject *shadowSettingObject)
 Gets the number of taps for percentage closer filtering(PCF)
virtual ~DtOsgShadowTechnique ()
 DTOR.

Protected Attributes

PerChannelDataMap myPerChannelDataMap
osg::ref_ptr< osg::LightSource > myGlobalLight
osg::ref_ptr< osg::Uniform > myLightDirectionUniform
DtDemyDe
osg::ref_ptr< osg::Program > myVsmBlurTextureProgram
osg::ref_ptr< osg::Program > myVsmBlurTexArrayProgram
osg::ref_ptr< osg::Program > myVsmPassthroughArrayProgram
osg::ref_ptr< osg::Program > myVsmPassthroughProgram
osg::ref_ptr< osg::Program > myEsmBlurTextureProgram
osg::ref_ptr< osg::Program > myEsmBlurTexArrayProgram
osg::ref_ptr< osg::Program > myEVsmBlurTextureProgram
osg::ref_ptr< osg::Program > myEVsmBlurTexArrayProgram

Static Protected Attributes

static const std::string myShadowCameraPrefixString
static const std::string mySDSMShadowCameraPrefixString

Private Member Functions

std::string generateFragmentComputeShadowFunction (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Generates an optimized fragment compute shadow function given the shadow settings.
std::string generateFragmentUniformAndVariables (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Generates an optimized fragment uniforms and variables given the shadow settings.
std::string generateFragmentMain (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Generates an optimized fragment main given the shadow settings.
bool getCameraSettings (osg::Camera *viewCamera, PerChannelData **perChannelData, DtShadowSettingsObject **shadowSettingObject, bool *isPlanView)
 Gets camera shadow settings.
void initPerChannelData (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Initializes per channel data.
void installRecieverVPandSharedStateSet (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Initializes the virtual program and shared stateset for perChannelData.
void triggerExternalModuleShaderRefresh ()
void packTextureAtlas (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Computes the total width and height for perChannelData.
void installSDSM (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Install SDSM.
void traverseSDSMCameras (CurrentPassData &d, osgUtil::CullVisitor &cv)
 Traverses SDSM Cameras.
void installCloudShadows (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Initializes per channel cloud shadows.
void updateCloudShadows (osg::RenderInfo &renderInfo, osg::Camera *camera)
 Updates per camera cloud shadows.
void updateCascadeImportance (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 Updates Cascade Importance.
osg::Program * getProgramFromFile (const std::string &szVertexShader, const std::string &szFragmentShader)
 Creates a Program with a vertex and fragment shader.
void installPreFilter (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject, osg::Camera *depthCamera, osg::Camera *xBlurCamera, osg::Camera *yBlurCamera, osg::Texture2D *texture, osg::StateSet *stateSet, unsigned int textureUnit)
 Installs PreFilter for texture 2d.
void installPreFilter (PerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject, osg::Camera *depthCamera, osg::Camera *xBlurCamera, osg::Camera *yBlurCamera, unsigned int textureLayer, osg::Texture2DArray *texture2DArray, osg::Texture2DArray *preFilterTexture2DArray1, osg::Texture2DArray *preFilterTexture2DArray2)
 Installs PreFilter for texture 2d Array.
void setupReverseZBuffer (osg::Camera *depthCamera, osg::Camera *xBlurCamera, osg::Camera *yBlurCamera)
void setupBlurCamera (osg::Camera *camera, osg::ref_ptr< osg::Program > &blurProgram, const osg::Vec2 &direction)
osg::Texture2D * createTexture2D (int width, int height, GLenum internalFormat, GLenum sourceFormat, GLenum sourceType, bool shadowComparisonMode, osg::Texture2D::FilterMode minFilter=osg::Texture2D::NEAREST, osg::Texture2D::FilterMode magFilter=osg::Texture2D::NEAREST)
 Creates 2d texture.
osg::Texture2DArray * createTexture2DArray (int width, int height, int depth, GLenum internalFormat, GLenum sourceFormat, GLenum sourceType, bool shadowComparisonMode, osg::Texture2DArray::FilterMode minFilter=osg::Texture2DArray::NEAREST, osg::Texture2DArray::FilterMode magFilter=osg::Texture2DArray::NEAREST)
 Creates 2d texture array.
osg::Camera * createCamera (int width, int height, GLbitfield clearMask)
 Creates a simple camera.
osg::Geode * createFullScreenQuad (const osg::Vec2 &size, const osg::Vec2 &uvStart, const osg::Vec2 &uvStop)
 Creates a full screen quad.
osg::Camera * createHudCamera (int width, int height, GLbitfield clearMask, const char *name=NULL)
 Creates a hud camera with a full screen quad.
double computeUniformSplit (double nearDistance, double farDistance, unsigned int splitIndex, unsigned int numSplits)
 Compute uniform split distance for specified cascade.
double computeLogarithmicSplit (double nearDistance, double farDistance, unsigned int splitIndex, unsigned int numSplits)
 Compute logarithm split distance for specified cascade.
CameraDescription constructSplitLightCamera (const CurrentPassData &d, int split_index, bool farCascade=false)
 Compute logarithm split distance for specified cascade.
void updateCameras (const CurrentPassData &d)
void getSplitCameraDistances (const CurrentPassData &d, int split_index, double &splitCamNear, double &splitCamFar)
void setDirty (bool dirty)
 Sets dirty for shadow technique's to true or false.
void frustumBoundingBoxLightViewSpace (const CurrentPassData &d, int split_index, const osg::Matrix &lightViewMatrix, double nearPlane, double farPlane, osg::Vec3d &minFrustum, osg::Vec3d &maxFrustum)

Friends

struct CurrentPassData

Detailed Description

The DtOsgShadowTechnique class implements a robust shadow mapping system.

Member Typedef Documentation

typedef std::map< const osg::Camera*, osg::ref_ptr<PerChannelData> > makVrv::DtOsgShadowTechnique::PerChannelDataMap
protected

Constructor & Destructor Documentation

makVrv::DtOsgShadowTechnique::DtOsgShadowTechnique ( DtDe de)

CTOR.

makVrv::DtOsgShadowTechnique::DtOsgShadowTechnique ( const DtOsgShadowTechnique es,
const osg::CopyOp &  copyop = osg::CopyOp::SHALLOW_COPY 
)

DTOR.

virtual makVrv::DtOsgShadowTechnique::~DtOsgShadowTechnique ( )
protectedvirtual

DTOR.

Member Function Documentation

virtual osg::Object* makVrv::DtOsgShadowTechnique::cloneType ( ) const
inlinevirtual

Creates a new object of Type DtOsgShadowTechnique.

virtual osg::Object* makVrv::DtOsgShadowTechnique::clone ( const osg::CopyOp &  copyop) const
inlinevirtual

Creates a new copy of DtOsgShadowTechnique object.

virtual bool makVrv::DtOsgShadowTechnique::isSameKindAs ( const osg::Object *  obj) const
inlinevirtual

Returns true if object is of the DtOsgShadowTechnique class. Otherwise, returns false.

virtual const char* makVrv::DtOsgShadowTechnique::libraryName ( ) const
inlinevirtual

Returns the namespace string.

virtual const char* makVrv::DtOsgShadowTechnique::className ( ) const
inlinevirtual

Returns the class name string.

virtual void makVrv::DtOsgShadowTechnique::init ( )
virtual

Overrides the osgShadow::ShadowTechnique::init method.

virtual void makVrv::DtOsgShadowTechnique::postConstructionInit ( )
virtual

another init function

virtual void makVrv::DtOsgShadowTechnique::update ( osg::NodeVisitor &  nv)
virtual

Overrides the osgShadow::ShadowTechnique::update method.

virtual void makVrv::DtOsgShadowTechnique::cull ( osgUtil::CullVisitor &  cv)
virtual

Overrides the osgShadow::ShadowTechnique::cull method.

virtual void makVrv::DtOsgShadowTechnique::cleanSceneGraph ( )
virtual

Overrides the osgShadow::ShadowTechnique::cleanSceneGraph method.

void makVrv::DtOsgShadowTechnique::setChannelShadowState ( DtOsgChannel osgChannel,
bool  enable 
)

Set the shadow mode for channels.

bool makVrv::DtOsgShadowTechnique::getChannelShadowSettings ( DtOsgChannel osgChannel,
DtShadowSettingsObject **  shadowSettingObject,
bool isPlanView 
)

Gets the shadow settings for this channel.

bool makVrv::DtOsgShadowTechnique::getCameraCloudShadowMap ( osg::Camera *  camera,
unsigned int textureIndex,
osg::Matrix *  textureViewProjMatrix,
unsigned int textureIndex2,
osg::Matrix *  textureViewProjMatrix2 
)

Gets the cloud shadow map for this camera.

void makVrv::DtOsgShadowTechnique::setGlobalLight ( osg::LightSource *  light)
inline

Sets global light source.

const osg::LightSource* makVrv::DtOsgShadowTechnique::getGlobalLight ( ) const
inline

Gets global light source.

static const std::string& makVrv::DtOsgShadowTechnique::shadowCameraPrefixString ( void  )
static
static const std::string& makVrv::DtOsgShadowTechnique::shadowSDSMCameraPrefixString ( void  )
static
const osg::StateSet* makVrv::DtOsgShadowTechnique::mapCameraToStateSet ( const osg::Camera *  camera) const

returns shared state set uniform infor for this camera, may be null

virtual void makVrv::DtOsgShadowTechnique::reInitialize ( unsigned int  quality)
protectedvirtual

Re-initialize perChannelData using the specified quality setting.

virtual bool makVrv::DtOsgShadowTechnique::configureShadowTraversalNodeMask ( bool  traverseEntities,
bool  traverseProps,
bool  traverseTerrain 
)
protectedvirtual
virtual void makVrv::DtOsgShadowTechnique::slot_refresh_maps ( )
protectedvirtual
virtual std::string makVrv::DtOsgShadowTechnique::generateVertexShader ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
protectedvirtual

Generates an optimized vertex shader given the shadow settings.

virtual std::string makVrv::DtOsgShadowTechnique::generateFragmentShader ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
protectedvirtual

Generates an optimized fragment shader given the shadow settings.

virtual std::string makVrv::DtOsgShadowTechnique::generateCloudShadowVertexShader ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
protectedvirtual

Generates an cloud shadow vertex shader given the shadow settings.

unsigned int makVrv::DtOsgShadowTechnique::getFilterCount ( DtShadowSettingsObject shadowSettingObject)
protected

Gets the number of taps for percentage closer filtering(PCF)

std::string makVrv::DtOsgShadowTechnique::generateFragmentComputeShadowFunction ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Generates an optimized fragment compute shadow function given the shadow settings.

std::string makVrv::DtOsgShadowTechnique::generateFragmentUniformAndVariables ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Generates an optimized fragment uniforms and variables given the shadow settings.

std::string makVrv::DtOsgShadowTechnique::generateFragmentMain ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Generates an optimized fragment main given the shadow settings.

bool makVrv::DtOsgShadowTechnique::getCameraSettings ( osg::Camera *  viewCamera,
PerChannelData **  perChannelData,
DtShadowSettingsObject **  shadowSettingObject,
bool isPlanView 
)
private

Gets camera shadow settings.

void makVrv::DtOsgShadowTechnique::initPerChannelData ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Initializes per channel data.

void makVrv::DtOsgShadowTechnique::installRecieverVPandSharedStateSet ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Initializes the virtual program and shared stateset for perChannelData.

void makVrv::DtOsgShadowTechnique::triggerExternalModuleShaderRefresh ( )
private
void makVrv::DtOsgShadowTechnique::packTextureAtlas ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Computes the total width and height for perChannelData.

void makVrv::DtOsgShadowTechnique::installSDSM ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Install SDSM.

void makVrv::DtOsgShadowTechnique::traverseSDSMCameras ( CurrentPassData d,
osgUtil::CullVisitor &  cv 
)
private

Traverses SDSM Cameras.

void makVrv::DtOsgShadowTechnique::installCloudShadows ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Initializes per channel cloud shadows.

void makVrv::DtOsgShadowTechnique::updateCloudShadows ( osg::RenderInfo &  renderInfo,
osg::Camera *  camera 
)
private

Updates per camera cloud shadows.

void makVrv::DtOsgShadowTechnique::updateCascadeImportance ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject 
)
private

Updates Cascade Importance.

osg::Program* makVrv::DtOsgShadowTechnique::getProgramFromFile ( const std::string &  szVertexShader,
const std::string &  szFragmentShader 
)
private

Creates a Program with a vertex and fragment shader.

void makVrv::DtOsgShadowTechnique::installPreFilter ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject,
osg::Camera *  depthCamera,
osg::Camera *  xBlurCamera,
osg::Camera *  yBlurCamera,
osg::Texture2D *  texture,
osg::StateSet *  stateSet,
unsigned int  textureUnit 
)
private

Installs PreFilter for texture 2d.

void makVrv::DtOsgShadowTechnique::installPreFilter ( PerChannelData perChannelData,
DtShadowSettingsObject shadowSettingObject,
osg::Camera *  depthCamera,
osg::Camera *  xBlurCamera,
osg::Camera *  yBlurCamera,
unsigned int  textureLayer,
osg::Texture2DArray *  texture2DArray,
osg::Texture2DArray *  preFilterTexture2DArray1,
osg::Texture2DArray *  preFilterTexture2DArray2 
)
private

Installs PreFilter for texture 2d Array.

void makVrv::DtOsgShadowTechnique::setupReverseZBuffer ( osg::Camera *  depthCamera,
osg::Camera *  xBlurCamera,
osg::Camera *  yBlurCamera 
)
private
void makVrv::DtOsgShadowTechnique::setupBlurCamera ( osg::Camera *  camera,
osg::ref_ptr< osg::Program > &  blurProgram,
const osg::Vec2 &  direction 
)
private
osg::Texture2D* makVrv::DtOsgShadowTechnique::createTexture2D ( int  width,
int  height,
GLenum  internalFormat,
GLenum  sourceFormat,
GLenum  sourceType,
bool  shadowComparisonMode,
osg::Texture2D::FilterMode  minFilter = osg::Texture2D::NEAREST,
osg::Texture2D::FilterMode  magFilter = osg::Texture2D::NEAREST 
)
private

Creates 2d texture.

osg::Texture2DArray* makVrv::DtOsgShadowTechnique::createTexture2DArray ( int  width,
int  height,
int  depth,
GLenum  internalFormat,
GLenum  sourceFormat,
GLenum  sourceType,
bool  shadowComparisonMode,
osg::Texture2DArray::FilterMode  minFilter = osg::Texture2DArray::NEAREST,
osg::Texture2DArray::FilterMode  magFilter = osg::Texture2DArray::NEAREST 
)
private

Creates 2d texture array.

osg::Camera* makVrv::DtOsgShadowTechnique::createCamera ( int  width,
int  height,
GLbitfield  clearMask 
)
private

Creates a simple camera.

osg::Geode* makVrv::DtOsgShadowTechnique::createFullScreenQuad ( const osg::Vec2 &  size,
const osg::Vec2 &  uvStart,
const osg::Vec2 &  uvStop 
)
private

Creates a full screen quad.

osg::Camera* makVrv::DtOsgShadowTechnique::createHudCamera ( int  width,
int  height,
GLbitfield  clearMask,
const char name = NULL 
)
private

Creates a hud camera with a full screen quad.

double makVrv::DtOsgShadowTechnique::computeUniformSplit ( double  nearDistance,
double  farDistance,
unsigned int  splitIndex,
unsigned int  numSplits 
)
private

Compute uniform split distance for specified cascade.

double makVrv::DtOsgShadowTechnique::computeLogarithmicSplit ( double  nearDistance,
double  farDistance,
unsigned int  splitIndex,
unsigned int  numSplits 
)
private

Compute logarithm split distance for specified cascade.

CameraDescription makVrv::DtOsgShadowTechnique::constructSplitLightCamera ( const CurrentPassData d,
int  split_index,
bool  farCascade = false 
)
private

Compute logarithm split distance for specified cascade.

void makVrv::DtOsgShadowTechnique::updateCameras ( const CurrentPassData d)
private
void makVrv::DtOsgShadowTechnique::getSplitCameraDistances ( const CurrentPassData d,
int  split_index,
double splitCamNear,
double splitCamFar 
)
private
void makVrv::DtOsgShadowTechnique::setDirty ( bool  dirty)
inlineprivate

Sets dirty for shadow technique's to true or false.

void makVrv::DtOsgShadowTechnique::frustumBoundingBoxLightViewSpace ( const CurrentPassData d,
int  split_index,
const osg::Matrix &  lightViewMatrix,
double  nearPlane,
double  farPlane,
osg::Vec3d &  minFrustum,
osg::Vec3d &  maxFrustum 
)
private

Friends And Related Function Documentation

friend struct CurrentPassData
friend

Member Data Documentation

class ShadowTweakables* makVrv::DtOsgShadowTechnique::myShadowUI
const int makVrv::DtOsgShadowTechnique::MAX_NUM_CASCADES = 6
static
PerChannelDataMap makVrv::DtOsgShadowTechnique::myPerChannelDataMap
protected
osg::ref_ptr<osg::LightSource> makVrv::DtOsgShadowTechnique::myGlobalLight
protected
osg::ref_ptr<osg::Uniform> makVrv::DtOsgShadowTechnique::myLightDirectionUniform
protected
DtDe& makVrv::DtOsgShadowTechnique::myDe
protected
const std::string makVrv::DtOsgShadowTechnique::myShadowCameraPrefixString
staticprotected
const std::string makVrv::DtOsgShadowTechnique::mySDSMShadowCameraPrefixString
staticprotected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myVsmBlurTextureProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myVsmBlurTexArrayProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myVsmPassthroughArrayProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myVsmPassthroughProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myEsmBlurTextureProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myEsmBlurTexArrayProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myEVsmBlurTextureProgram
protected
osg::ref_ptr<osg::Program> makVrv::DtOsgShadowTechnique::myEVsmBlurTexArrayProgram
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)