VR-Forces Developer's Guide
 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 | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Friends
makVrv::DtOsgShadowTechnique Class Reference

Implements cascaded shadow mapping (CSM) for the VRV rendering pipeline.

Manages the full shadow rendering lifecycle per-channel: shadow camera setup, cascade split computation, light view/projection matrix construction, shadow texture allocation, and receiver shader configuration.

Key features:

One instance is shared across all channels. Per-channel state (cameras, textures, uniforms, and visualizers) is stored in DtPerChannelData, keyed by view camera.

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

Classes

struct  CameraDescription
 
struct  MulticastDebugInfo
 

Public Member Functions

 DtOsgShadowTechnique (DtDe &de)
 
 DtOsgShadowTechnique (const DtOsgShadowTechnique &es, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 
virtual osg::Object * cloneType () const
 
virtual osg::Object * clone (const osg::CopyOp &copyop) const
 
virtual bool isSameKindAs (const osg::Object *obj) const
 
virtual const char * libraryName () const
 
virtual const char * className () const
 
virtual void init ()
 
virtual void postConstructionInit ()
 
virtual void update (osg::NodeVisitor &nv)
 
virtual void cull (osgUtil::CullVisitor &cv)
 
virtual void cleanSceneGraph ()
 
void setChannelShadowState (DtOsgChannel *osgChannel, bool enable)
 
bool getChannelShadowSettings (DtOsgChannel *osgChannel, DtShadowSettingsObject **shadowSettingObject, bool *isPlanView)
 
void setGlobalLight (osg::LightSource *light)
 
const osg::LightSource * getGlobalLight () const
 
const osg::StateSet * mapCameraToStateSet (const osg::Camera *camera) const
 
virtual void resizeGLObjectBuffers (unsigned int maxSize) override
 
virtual void releaseGLObjects (osg::State *=0) const override
 

Static Public Member Functions

static const std::string & shadowCameraPrefixString ()
 

Protected Types

typedef std::map< const
osg::Camera *, osg::ref_ptr
< DtPerChannelData > > 
PerChannelDataMap
 
typedef std::vector
< osg::ref_ptr
< DtPerChannelData > > 
PerChannelDataVector
 

Protected Member Functions

virtual ~DtOsgShadowTechnique ()
 
virtual void reInitialize (unsigned int quality)
 
virtual void cleanupOldPerChannelData ()
 
virtual bool configureShadowTraversalNodeMask (bool traverseEntities, bool traverseProps, bool traverseTerrain)
 
virtual void slot_refresh_maps ()
 
unsigned int getFilterCount (DtShadowSettingsObject *shadowSettingObject)
 
bool getReceiveShadows (const DtShadowSettingsObject *shadowSettings) const
 
virtual void computeFrustumPoints (const osg::Matrix &projectionMat, bool reverseZ, const osg::Matrix &inverseViewMat, double nearPlane, double farPlane, osg::Vec3d *outFrustumPoints)
 
virtual const osg::Vec3 computeLightDirection (osg::Camera *viewCamera) const
 
virtual void updateSplitDistancesAndUniforms (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, const DtCurrentPassData &currentPassData)
 
virtual void updateShadowUniformsAndFilters (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, osg::Camera *viewCamera, DtCurrentPassData &currentPassData, bool &bRefreshFarCascade, unsigned int &unbindingIndex)
 
virtual void updateAndRenderCascade (unsigned int splitIndex, DtCurrentPassData &currentPassData, DtPerChannelData *perChannelData, const DtShadowSettingsObject *shadowSettings, const osg::Camera *viewCamera, osgUtil::CullVisitor &cv, unsigned int &unbindingIndex, bool bRefreshFarCascade, DtCVMarkerSeries &series, int &cascades_rendered)
 
virtual void updateShadowOverlayGui (const DtPerChannelData *perChannelData, const DtCurrentPassData &currentPassData, int cascadesRendered)
 
virtual void updateOsgEarthUniforms (const osg::Camera *viewCamera, osg::Camera *cascadeCamera)
 

Protected Attributes

PerChannelDataMap myPerChannelDataMap
 
PerChannelDataVector myPerChannelDataDeleteList
 
osg::ref_ptr< osg::LightSource > myGlobalLight
 
osg::ref_ptr< osg::Uniform > myLightDirectionUniform
 
osg::ref_ptr< osg::Uniform > myReceiveShadowsUniform
 
DtShadowTweakables * myShadowUI
 
DtDe & myDe
 
std::vector< osg::ref_ptr
< osg::Camera > > 
myDeferredDeleteCamera
 
tbb::mutex myDeferredCameraDeletionMutex
 
bool myMulticastIsSupported
 
bool myShadingRateIsSupported
 
DtSkyObjectManager & mySkyObjectManager
 
boost::signalslib::connection myTerrainPatchAddedConnection
 
boost::signalslib::connection myTerrainPatchDeletedConnection
 
DtOsgShaderFilesCache & myShaderFilesCache
 
osg::Vec2f myMaxViewportDims
 
float myAnisotropy
 

Static Protected Attributes

static const std::string myShadowCameraPrefixString
 

Private Member Functions

int farShadowMapCascadeSize () const
 
bool getCameraSettings (osg::Camera *viewCamera, DtPerChannelData **perChannelData, DtShadowSettingsObject **shadowSettingObject, bool *isPlanView)
 
void initPerChannelData (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 
void setupMulticastMask (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings)
 
bool initShadowSplitCamera (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, unsigned int numberOfSplits, const osg::ref_ptr< osg::Texture2DArray > &depthTexture2DArray, const osg::ref_ptr< osg::Texture2DArray > &depthTextureFarCascade, const osg::ref_ptr< osg::Texture2DArray > &textureColor2DArray, const osg::ref_ptr< osg::Texture2DArray > &textureColor2DFarCascade, DtCascadeData &cascade)
 
osg::StateSet * setupShadowCamera (DtCascadeData &cascade, DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, bool farCascade, unsigned int splitIndex, int farCascadeSize, const osg::ref_ptr< osg::Texture2DArray > &depthTexture2DArray, const osg::ref_ptr< osg::Texture2DArray > &depthTextureFarCascade, const osg::ref_ptr< osg::Texture2DArray > &textureColor2DArray, const osg::ref_ptr< osg::Texture2DArray > &textureColor2DFarCascade)
 
void setupShadowSplitStateSet (osg::StateSet *cameraStateSet, DtCascadeData &cascade, DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, unsigned int splitIndex)
 
void initShadowTextures (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, osg::ref_ptr< osg::Texture2DArray > &depthTexture2DArray, osg::ref_ptr< osg::Texture2DArray > &depthTextureFarCascade, osg::ref_ptr< osg::Texture2DArray > &textureColor2DArray, osg::ref_ptr< osg::Texture2DArray > &textureColor2DFarCascade, osg::ref_ptr< osg::Texture2D > &depthTexture2DAtlas, osg::ref_ptr< osg::Texture2D > &debugColor2DAtlas)
 
void initDebugVisualizers (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettings, DtOsgRenderer *osgRenderer, const osg::ref_ptr< osg::Texture2DArray > &textureColor2DArray, const osg::ref_ptr< osg::Texture2DArray > &textureColor2DFarCascade, const osg::ref_ptr< osg::Texture2DArray > &depthTextureFarCascade, const osg::ref_ptr< osg::Texture2D > &depthTexture2DAtlas, const osg::ref_ptr< osg::Texture2D > &debugColor2DAtlas)
 
void installReceiverVPandSharedStateSet (DtPerChannelData *perChannelData, DtShadowSettingsObject *shadowSettingObject)
 
void createPreProcessorDefines (std::string &defines, osg::StateSet &stateSet, DtShadowSettingsObject *shadowSettings)
 
void triggerExternalModuleShaderRefresh ()
 
osg::Program * getProgramFromFile (const std::string &szVertexShader, const std::string &szFragmentShader)
 
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)
 
osg::Camera * createCamera (int width, int height, GLbitfield clearMask)
 
osg::Geode * createFullScreenQuad (const osg::Vec2 &size, const osg::Vec2 &uvStart, const osg::Vec2 &uvStop)
 
osg::Camera * createHudCamera (int width, int height, GLbitfield clearMask, const char *name=nullptr)
 
double computeUniformSplit (double nearDistance, double farDistance, unsigned int splitIndex, unsigned int numSplits)
 
double computeLogarithmicSplit (double nearDistance, double farDistance, unsigned int splitIndex, unsigned int numSplits)
 
osg::Matrix buildShadowBiasMatrix (bool useReverseZ, const osg::Vec2f &scaleFactor) const
 
CameraDescription constructSplitLightCamera (const DtCurrentPassData &d, int split_index, bool farCascade=false)
 
void updateCameras (const DtCurrentPassData &d)
 
void getSplitCameraDistances (const DtCurrentPassData &d, int split_index, double &splitCamNear, double &splitCamFar)
 
void setDirty (bool dirty)
 
void frustumBoundingBoxLightViewSpace (const DtCurrentPassData &d, int split_index, const osg::Matrix &lightViewMatrix, double nearPlane, double farPlane, osg::Vec3d &minFrustum, osg::Vec3d &maxFrustum)
 
osg::Matrix computeExactLightViewMatrix (const osg::Vec3d &targetPos, const DtCurrentPassData &d, double maxCasterDistance, osg::Vec3d *outLightPos=nullptr) const
 
void computeFrustumCornerRays (const osg::Matrix &projectionMat, bool reverseZ, const osg::Matrix &inverseViewMat, osg::Vec3d outRays[4]) const
 
void computeCascadeCenterAndRadius (const DtCurrentPassData &d, const osg::Vec3d rays[4], double nearPlane, double farPlane, osg::Vec3d &outCenter, double &outRadius) const
 
void quantizeCascadeCenter (const osg::Vec3d &inCenter, double radius, int shadowMapSize, const osg::Vec3d &lightCamUp, const osg::Vec3d &lightCamSide, const osg::Vec3d &lightDirection, osg::Vec3d &outCenter) const
 
void drawMulticastDetailsGui (const MulticastDebugInfo &info)
 

Friends

struct DtCurrentPassData
 

Member Typedef Documentation

typedef std::map< const osg::Camera*, osg::ref_ptr<DtPerChannelData> > 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.

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

Sets global light source.

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

Gets global light source.

static const std::string& makVrv::DtOsgShadowTechnique::shadowCameraPrefixString ( )
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::resizeGLObjectBuffers ( unsigned int  maxSize)
overridevirtual

override from osg::ShadowTechnique

virtual void makVrv::DtOsgShadowTechnique::releaseGLObjects ( osg::State *  = 0) const
overridevirtual

override from osg::ShadowTechnique

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

Re-initialize perChannelData using the specified quality setting.

virtual void makVrv::DtOsgShadowTechnique::cleanupOldPerChannelData ( )
protectedvirtual

Since the perChannelData can hold graphics objects we need to clear them in the main render thread. only call this from the main render thread.

virtual bool makVrv::DtOsgShadowTechnique::configureShadowTraversalNodeMask ( bool  traverseEntities,
bool  traverseProps,
bool  traverseTerrain 
)
protectedvirtual
virtual void makVrv::DtOsgShadowTechnique::slot_refresh_maps ( )
protectedvirtual
unsigned int makVrv::DtOsgShadowTechnique::getFilterCount ( DtShadowSettingsObject *  shadowSettingObject)
protected

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

bool makVrv::DtOsgShadowTechnique::getReceiveShadows ( const DtShadowSettingsObject *  shadowSettings) const
protected

True if scene receives shadows from any light casting source. This is used to bypass some shadow work otherwise.

virtual void makVrv::DtOsgShadowTechnique::computeFrustumPoints ( const osg::Matrix &  projectionMat,
bool  reverseZ,
const osg::Matrix &  inverseViewMat,
double  nearPlane,
double  farPlane,
osg::Vec3d *  outFrustumPoints 
)
protectedvirtual

Computes 8 world space frustum points: (near bl, br, tl, tr), (far bl, br, tl, tr). The frustum is computed from the given projection and view matrix. The points will be located in world space at the given near and far frustum plane distances.

Parameters
projectionMatThe projection matrix
reverseZSet to true if the projection matrix is using reverse Z
inverseViewMatThe inverse view matrix
nearPlanethe desired near plane distance to project the near points to
farPlanethe desired far plane distance to project the far points to
outFrustumPointsshould be an array of 8 osg::Vec3d to accept the computed points
virtual const osg::Vec3 makVrv::DtOsgShadowTechnique::computeLightDirection ( osg::Camera *  viewCamera) const
protectedvirtual

Computes the main directional light vector for shadowing. Determines the direction of the primary light source (e.g., sun or moon) to be used for shadow calculations, based on the current view camera, global light, and environmental settings. Handles special cases such as geocentric coordinate systems, XR/sky-off modes, and developer overrides.

Parameters
viewCameraThe current view camera (may be nullptr).
Returns
The normalized direction vector of the main light source in world space.
virtual void makVrv::DtOsgShadowTechnique::updateSplitDistancesAndUniforms ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
const DtCurrentPassData &  currentPassData 
)
protectedvirtual

Updates per-cascade split far distances and associated shader uniforms.

Computes and stores the far plane distance for each shadow cascade split based on the current camera and shadow settings. Also updates the corresponding shader uniforms for split distances in both normalized device coordinates and world space. This is used to ensure correct shadow mapping and filtering across all cascades.

Parameters
perChannelDataThe per-channel shadow data to update.
shadowSettingsThe current shadow settings object.
currentPassDataThe current pass data containing camera and matrix information.
virtual void makVrv::DtOsgShadowTechnique::updateShadowUniformsAndFilters ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
osg::Camera *  viewCamera,
DtCurrentPassData &  currentPassData,
bool &  bRefreshFarCascade,
unsigned int &  unbindingIndex 
)
protectedvirtual

Updates shadow-related uniforms and filtering parameters for the current rendering pass.

This method updates all per-frame and per-pass shadow uniforms and filtering parameters required for correct shadow map rendering. It sets the light direction uniform, shadow ambient factor, and per-cascade filter sizes, and manages refresh logic for far cascades and shadow map updates. This function should be called once per frame for each channel before rendering shadow cascades.

Parameters
perChannelDataThe per-channel shadow data to update.
shadowSettingsThe current shadow settings object.
viewCameraThe current view camera.
currentPassDataThe current pass data containing camera and light information.
bRefreshFarCascadeOutput: set to true if the far cascade should be refreshed this frame.
unbindingIndexOutput: set to the last rendered split index for FBO unbinding.
virtual void makVrv::DtOsgShadowTechnique::updateAndRenderCascade ( unsigned int  splitIndex,
DtCurrentPassData &  currentPassData,
DtPerChannelData *  perChannelData,
const DtShadowSettingsObject *  shadowSettings,
const osg::Camera *  viewCamera,
osgUtil::CullVisitor &  cv,
unsigned int &  unbindingIndex,
bool  bRefreshFarCascade,
DtCVMarkerSeries &  series,
int &  cascades_rendered 
)
protectedvirtual

Updates and renders a single shadow cascade split.

Sets up the shadow camera and state for the specified cascade split, updates its view/projection matrices, and triggers rendering for that split if needed. Handles both regular and far cascades, manages polygon offset, culling, and uniforms, and ensures only the required cascades are refreshed and rendered based on the current pass state and shadow settings.

Parameters
splitIndexThe index of the cascade split to update and render.
currentPassDataThe current pass data containing camera, matrices, and state.
perChannelDataThe per-channel shadow data for this rendering pass.
shadowSettingsThe current shadow settings object.
viewCameraThe main view camera for this pass.
cvThe cull visitor used for scene traversal and rendering.
unbindingIndexOutput: set to the last rendered split index for FBO unbinding.
bRefreshFarCascadeTrue if the far cascade should be refreshed this frame.
seriesMarker series for performance profiling.
cascades_renderedOutput: incremented for each cascade actually rendered.
virtual void makVrv::DtOsgShadowTechnique::updateShadowOverlayGui ( const DtPerChannelData *  perChannelData,
const DtCurrentPassData &  currentPassData,
int  cascadesRendered 
)
protectedvirtual

Updates the shadow overlay GUI with the current per-channel data.

virtual void makVrv::DtOsgShadowTechnique::updateOsgEarthUniforms ( const osg::Camera *  viewCamera,
osg::Camera *  cascadeCamera 
)
protectedvirtual

Updates the shader uniforms related to OSG Earth integration for the current shadow pass.

int makVrv::DtOsgShadowTechnique::farShadowMapCascadeSize ( ) const
private

Gets the size of the far cascade.

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

Gets camera shadow settings.

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

Initializes per channel data.

void makVrv::DtOsgShadowTechnique::setupMulticastMask ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings 
)
private

Sets up the viewport multicast mask and related shader functions for shadow rendering. Configures the mask and shader state for each shadow split camera, enabling or disabling viewport multicast acceleration based on the shadow settings.

bool makVrv::DtOsgShadowTechnique::initShadowSplitCamera ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
unsigned int  numberOfSplits,
const osg::ref_ptr< osg::Texture2DArray > &  depthTexture2DArray,
const osg::ref_ptr< osg::Texture2DArray > &  depthTextureFarCascade,
const osg::ref_ptr< osg::Texture2DArray > &  textureColor2DArray,
const osg::ref_ptr< osg::Texture2DArray > &  textureColor2DFarCascade,
DtCascadeData &  cascade 
)
private

Initializes a shadow split camera for a specific cascade. Configures camera parameters, state set attributes, buffer attachments, and uniforms for each split in the shadow mapping cascade, including far cascade handling and visualization aids. Called during per-channel shadow data initialization. returns true on success, false on failure.

osg::StateSet* makVrv::DtOsgShadowTechnique::setupShadowCamera ( DtCascadeData &  cascade,
DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
bool  farCascade,
unsigned int  splitIndex,
int  farCascadeSize,
const osg::ref_ptr< osg::Texture2DArray > &  depthTexture2DArray,
const osg::ref_ptr< osg::Texture2DArray > &  depthTextureFarCascade,
const osg::ref_ptr< osg::Texture2DArray > &  textureColor2DArray,
const osg::ref_ptr< osg::Texture2DArray > &  textureColor2DFarCascade 
)
private

Creates and configures a shadow split camera for a given cascade. This method initializes the camera object, sets up its state set, callbacks, buffer attachments, and other properties required for shadow map rendering. Returns the configured StateSet for further customization.

void makVrv::DtOsgShadowTechnique::setupShadowSplitStateSet ( osg::StateSet *  cameraStateSet,
DtCascadeData &  cascade,
DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
unsigned int  splitIndex 
)
private

Configures the OpenGL state attributes for a shadow split camera's StateSet. Sets up polygon offset, cull face, shade model, alpha test, blending, and related uniforms for the specified split in the shadow mapping cascade. This method centralizes all per-split StateSet configuration required for shadow map rendering.

void makVrv::DtOsgShadowTechnique::initShadowTextures ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
osg::ref_ptr< osg::Texture2DArray > &  depthTexture2DArray,
osg::ref_ptr< osg::Texture2DArray > &  depthTextureFarCascade,
osg::ref_ptr< osg::Texture2DArray > &  textureColor2DArray,
osg::ref_ptr< osg::Texture2DArray > &  textureColor2DFarCascade,
osg::ref_ptr< osg::Texture2D > &  depthTexture2DAtlas,
osg::ref_ptr< osg::Texture2D > &  debugColor2DAtlas 
)
private

Initializes the shadow textures for perChannelData based on the shadow settings.

void makVrv::DtOsgShadowTechnique::initDebugVisualizers ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettings,
DtOsgRenderer *  osgRenderer,
const osg::ref_ptr< osg::Texture2DArray > &  textureColor2DArray,
const osg::ref_ptr< osg::Texture2DArray > &  textureColor2DFarCascade,
const osg::ref_ptr< osg::Texture2DArray > &  depthTextureFarCascade,
const osg::ref_ptr< osg::Texture2D > &  depthTexture2DAtlas,
const osg::ref_ptr< osg::Texture2D > &  debugColor2DAtlas 
)
private

Initializes the debug visualizer textures for perChannelData based on the shadow settings.

void makVrv::DtOsgShadowTechnique::installReceiverVPandSharedStateSet ( DtPerChannelData *  perChannelData,
DtShadowSettingsObject *  shadowSettingObject 
)
private

Initializes the virtual program and shared stateset for perChannelData.

void makVrv::DtOsgShadowTechnique::createPreProcessorDefines ( std::string &  defines,
osg::StateSet &  stateSet,
DtShadowSettingsObject *  shadowSettings 
)
private

Creates shader defines based on the shadow settings.

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

Creates a Program with a vertex and fragment shader.

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 = nullptr 
)
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.

osg::Matrix makVrv::DtOsgShadowTechnique::buildShadowBiasMatrix ( bool  useReverseZ,
const osg::Vec2f &  scaleFactor 
) const
private

Builds the shadow bias matrix that transforms NDC coordinates to shadow map UV space.

Converts the [-1, 1] NDC range to [0, 1] UV range for shadow map lookups. A scale factor is provided for viewport multicast support. In the standard case (non-multicast), scaleFactor should be (1, 1) producing the identity bias. For reverse Z, the Z component is left unscaled (mapped to [0, 1] as-is). For standard depth, Z is remapped from [-1, 1] to [0, 1].

Parameters
useReverseZTrue if the projection uses a reverse Z buffer.
scaleFactorXY scale applied to the UV mapping; use (1, 1) for the non-multicast path.
Returns
The bias matrix to post-multiply against the light view-projection matrix.
CameraDescription makVrv::DtOsgShadowTechnique::constructSplitLightCamera ( const DtCurrentPassData &  d,
int  split_index,
bool  farCascade = false 
)
private

Compute logarithm split distance for specified cascade.

void makVrv::DtOsgShadowTechnique::updateCameras ( const DtCurrentPassData &  d)
private
void makVrv::DtOsgShadowTechnique::getSplitCameraDistances ( const DtCurrentPassData &  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 DtCurrentPassData &  d,
int  split_index,
const osg::Matrix &  lightViewMatrix,
double  nearPlane,
double  farPlane,
osg::Vec3d &  minFrustum,
osg::Vec3d &  maxFrustum 
)
private
osg::Matrix makVrv::DtOsgShadowTechnique::computeExactLightViewMatrix ( const osg::Vec3d &  targetPos,
const DtCurrentPassData &  d,
double  maxCasterDistance,
osg::Vec3d *  outLightPos = nullptr 
) const
private

Computes a stable light view matrix for the exact anti-flickering stabilization case.

Places the light camera at targetPos + (lightDirection * maxCasterDistance), then constructs a view matrix looking back toward the targetPos position along the light direction.

Parameters
targetPosThe target world-space position toward which the light camera is aimed.
dThe current pass data containing camera position, light direction, and up vector.
maxCasterDistanceDistance along the light direction to offset the light camera origin.
outLightPosOptional output for the computed light position in world space.
Returns
The computed light view matrix.
void makVrv::DtOsgShadowTechnique::computeFrustumCornerRays ( const osg::Matrix &  projectionMat,
bool  reverseZ,
const osg::Matrix &  inverseViewMat,
osg::Vec3d  outRays[4] 
) const
private

Computes 4 normalized world-space ray directions for the camera frustum corners.

The rays are ordered: bottom-left, bottom-right, top-left, top-right. Each ray originates from the camera position and points toward the corresponding frustum corner. Scale by a plane distance to obtain a world-space frustum point.

Parameters
projectionMatThe camera projection matrix.
reverseZTrue if the projection uses reverse Z.
inverseViewMatThe camera inverse view matrix.
outRaysOutput array of exactly 4 normalized direction vectors.
void makVrv::DtOsgShadowTechnique::computeCascadeCenterAndRadius ( const DtCurrentPassData &  d,
const osg::Vec3d  rays[4],
double  nearPlane,
double  farPlane,
osg::Vec3d &  outCenter,
double &  outRadius 
) const
private

Computes the world-space center and bounding sphere radius for a cascade frustum slice.

Given the 4 pre-computed world-space corner rays from computeFrustumCornerRays, scales them to the cascade near and far planes to build 8 world-space frustum corners. The center is computed as the midpoint of the corners' axis-aligned bounding box (AABB), which gives a tighter fit than averaging vertices for asymmetric frusta (e.g. wide aspect ratios where near corners are tightly clustered and far corners are spread wide). The radius is then the maximum distance from that AABB center to any corner.

Parameters
dCurrent pass data providing camera position and orientation.
rays4 normalized world-space frustum corner rays (bl, br, tl, tr).
nearPlaneCascade near plane distance.
farPlaneCascade far plane distance.
outCenterOutput world-space AABB center of the cascade frustum slice.
outRadiusOutput bounding sphere radius from the AABB center to the farthest corner.
void makVrv::DtOsgShadowTechnique::quantizeCascadeCenter ( const osg::Vec3d &  inCenter,
double  radius,
int  shadowMapSize,
const osg::Vec3d &  lightCamUp,
const osg::Vec3d &  lightCamSide,
const osg::Vec3d &  lightDirection,
osg::Vec3d &  outCenter 
) const
private

Snaps a world-space cascade center to the nearest shadow map texel boundary.

Quantizing the center in light-camera space prevents sub-texel shimmer as the main camera moves, because the shadow map coverage shifts only in whole-texel increments. The texel world-size is derived from the shadow map's world coverage (radius) and its pixel resolution. The center is decomposed along the light camera's up and side axes, each component snapped independently, then the center is reconstructed.

Parameters
inCenterWorld-space cascade center to quantize.
radiusWorld-space half-coverage of the shadow map ortho projection. Typically the bounding sphere radius from computeCascadeCenterAndRadius.
shadowMapSizeShadow map resolution in pixels (width == height assumed).
lightCamUpNormalized up vector of the light camera (world space).
lightCamSideNormalized side/right vector of the light camera (world space).
lightDirectionNormalized light direction vector (world space).
outCenterOutput quantized world-space center.
void makVrv::DtOsgShadowTechnique::drawMulticastDetailsGui ( const MulticastDebugInfo &  info)
private

Friends And Related Function Documentation

friend struct DtCurrentPassData
friend

Member Data Documentation

PerChannelDataMap makVrv::DtOsgShadowTechnique::myPerChannelDataMap
protected
PerChannelDataVector makVrv::DtOsgShadowTechnique::myPerChannelDataDeleteList
protected
osg::ref_ptr<osg::LightSource> makVrv::DtOsgShadowTechnique::myGlobalLight
protected
osg::ref_ptr<osg::Uniform> makVrv::DtOsgShadowTechnique::myLightDirectionUniform
protected
osg::ref_ptr<osg::Uniform> makVrv::DtOsgShadowTechnique::myReceiveShadowsUniform
protected
DtShadowTweakables* makVrv::DtOsgShadowTechnique::myShadowUI
protected
DtDe& makVrv::DtOsgShadowTechnique::myDe
protected
const std::string makVrv::DtOsgShadowTechnique::myShadowCameraPrefixString
staticprotected
std::vector<osg::ref_ptr<osg::Camera> > makVrv::DtOsgShadowTechnique::myDeferredDeleteCamera
protected
tbb::mutex makVrv::DtOsgShadowTechnique::myDeferredCameraDeletionMutex
protected
bool makVrv::DtOsgShadowTechnique::myMulticastIsSupported
protected
bool makVrv::DtOsgShadowTechnique::myShadingRateIsSupported
protected
DtSkyObjectManager& makVrv::DtOsgShadowTechnique::mySkyObjectManager
protected
boost::signalslib::connection makVrv::DtOsgShadowTechnique::myTerrainPatchAddedConnection
protected
boost::signalslib::connection makVrv::DtOsgShadowTechnique::myTerrainPatchDeletedConnection
protected
DtOsgShaderFilesCache& makVrv::DtOsgShadowTechnique::myShaderFilesCache
protected
osg::Vec2f makVrv::DtOsgShadowTechnique::myMaxViewportDims
protected
float makVrv::DtOsgShadowTechnique::myAnisotropy
protected

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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)