Parallel Split Shadow Map (PSSM) shadow camera setup. More...
#include <OgreShadowCameraSetupPSSM.h>
Public Types | |
typedef vector< Real >::type | SplitPointList |
typedef vector< Real >::type | OptimalAdjustFactorList |
Public Member Functions | |
PSSMShadowCameraSetup () | |
Constructor, defaults to 3 splits. | |
~PSSMShadowCameraSetup () | |
void | calculateSplitPoints (size_t splitCount, Real nearDist, Real farDist, Real lambda=0.95) |
Calculate a new splitting scheme. | |
void | setSplitPoints (const SplitPointList &newSplitPoints) |
Manually configure a new splitting scheme. | |
void | setOptimalAdjustFactor (size_t splitIndex, Real factor) |
Set the LiSPSM optimal adjust factor for a given split (call after configuring splits). | |
void | setSplitPadding (Real pad) |
Set the padding factor to apply to the near & far distances when matching up splits to one another, to avoid 'cracks'. | |
Real | getSplitPadding () const |
Get the padding factor to apply to the near & far distances when matching up splits to one another, to avoid 'cracks'. | |
size_t | getSplitCount () const |
Get the number of splits. | |
virtual void | getShadowCamera (const Ogre::SceneManager *sm, const Ogre::Camera *cam, const Ogre::Viewport *vp, const Ogre::Light *light, Ogre::Camera *texCam, size_t iteration) const |
Returns a LiSPSM shadow camera with PSSM splits base on iteration. | |
const SplitPointList & | getSplitPoints () const |
Returns the calculated split points. | |
Real | getOptimalAdjustFactor (size_t splitIndex) const |
Returns the optimal adjust factor for a given split. | |
Real | getOptimalAdjustFactor () const |
Overridden, recommended internal use only since depends on current iteration. | |
virtual void | setOptimalAdjustFactor (Real n) |
Adjusts the parameter n to produce optimal shadows. | |
virtual void | setUseSimpleOptimalAdjust (bool s) |
Sets whether or not to use a slightly simpler version of the camera near point derivation (default is true). | |
virtual bool | getUseSimpleOptimalAdjust () const |
Gets whether or not to use a slightly simpler version of the camera near point derivation (default is true). | |
virtual void | setCameraLightDirectionThreshold (Degree angle) |
Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew. | |
virtual Degree | getCameraLightDirectionThreshold () const |
Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew. | |
void | setUseAggressiveFocusRegion (bool aggressive) |
Sets whether or not to use the more aggressive approach to deciding on the focus region or not. | |
bool | getUseAggressiveFocusRegion () const |
void * | operator new (size_t sz, const char *file, int line, const char *func) |
operator new, with debug line info | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *ptr) |
placement operator new | |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info | |
void * | operator new[] (size_t sz) |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, void *) |
void | operator delete (void *ptr, const char *, int, const char *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, const char *, int, const char *) |
Protected Member Functions | |
Matrix4 | calculateLiSPSM (const Matrix4 &lightSpace, const PointListBody &bodyB, const PointListBody &bodyLVS, const SceneManager &sm, const Camera &cam, const Light &light) const |
Calculates the LiSPSM projection matrix P. | |
Real | calculateNOpt (const Matrix4 &lightSpace, const AxisAlignedBox &bodyBABB_ls, const PointListBody &bodyLVS, const Camera &cam) const |
Calculates the distance between camera position and near clipping plane. | |
Real | calculateNOptSimple (const PointListBody &bodyLVS, const Camera &cam) const |
Calculates a simpler version than the one above. | |
Vector3 | calculateZ0_ls (const Matrix4 &lightSpace, const Vector3 &e, Real bodyB_zMax_ls, const Camera &cam) const |
Calculates the visible point on the near plane for the n_opt calculation. | |
Matrix4 | buildFrustumProjection (Real left, Real right, Real bottom, Real top, Real near, Real far) const |
Builds a frustum matrix. | |
void | calculateShadowMappingMatrix (const SceneManager &sm, const Camera &cam, const Light &light, Matrix4 *out_view, Matrix4 *out_proj, Camera *out_cam) const |
Calculates the standard shadow mapping matrix. | |
void | calculateB (const SceneManager &sm, const Camera &cam, const Light &light, const AxisAlignedBox &sceneBB, const AxisAlignedBox &receiverBB, PointListBody *out_bodyB) const |
Calculates the intersection bodyB. | |
void | calculateLVS (const SceneManager &sm, const Camera &cam, const Light &light, const AxisAlignedBox &sceneBB, PointListBody *out_LVS) const |
Calculates the bodyLVS. | |
Vector3 | getLSProjViewDir (const Matrix4 &lightSpace, const Camera &cam, const PointListBody &bodyLVS) const |
Returns the projection view direction. | |
Vector3 | getNearCameraPoint_ws (const Matrix4 &viewMatrix, const PointListBody &bodyLVS) const |
Returns a valid near-point seen by the camera. | |
Matrix4 | transformToUnitCube (const Matrix4 &m, const PointListBody &body) const |
Transforms a given body to the unit cube (-1,-1,-1) / (+1,+1,+1) with a specific shadow matrix enabled. | |
Matrix4 | buildViewMatrix (const Vector3 &pos, const Vector3 &dir, const Vector3 &up) const |
Builds a view matrix. | |
Protected Attributes | |
size_t | mSplitCount |
SplitPointList | mSplitPoints |
OptimalAdjustFactorList | mOptimalAdjustFactors |
Real | mSplitPadding |
size_t | mCurrentIteration |
Real | mOptAdjustFactor |
Warp factor adjustment. | |
bool | mUseSimpleNOpt |
Use simple nopt derivation? | |
Real | mOptAdjustFactorTweak |
Extra calculated warp factor. | |
Real | mCosCamLightDirThreshold |
Threshold (cos angle) within which to start increasing the opt adjust as camera direction approaches light direction. | |
Frustum * | mTempFrustum |
Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix(). | |
Camera * | mLightFrustumCamera |
Temporary preallocated camera to set up a light frustum for clipping in calculateB. | |
bool | mLightFrustumCameraCalculated |
bool | mUseAggressiveRegion |
Use tighter focus region? | |
ConvexBody | mBodyB |
PointListBody | mPointListBodyB |
PointListBody | mPointListBodyLVS |
Static Protected Attributes | |
static const Matrix4 | msNormalToLightSpace |
Transform to or from light space as defined by Wimmer et al. | |
static const Matrix4 | msLightSpaceToNormal |
Parallel Split Shadow Map (PSSM) shadow camera setup.
Definition at line 55 of file OgreShadowCameraSetupPSSM.h.
typedef vector<Real>::type Ogre::PSSMShadowCameraSetup::OptimalAdjustFactorList |
Definition at line 59 of file OgreShadowCameraSetupPSSM.h.
typedef vector<Real>::type Ogre::PSSMShadowCameraSetup::SplitPointList |
Definition at line 58 of file OgreShadowCameraSetupPSSM.h.
Ogre::PSSMShadowCameraSetup::PSSMShadowCameraSetup | ( | ) |
Constructor, defaults to 3 splits.
Ogre::PSSMShadowCameraSetup::~PSSMShadowCameraSetup | ( | ) |
Matrix4 Ogre::LiSPSMShadowCameraSetup::buildFrustumProjection | ( | Real | left, | |
Real | right, | |||
Real | bottom, | |||
Real | top, | |||
Real | near, | |||
Real | far | |||
) | const [protected, inherited] |
Builds a frustum matrix.
Matrix4 Ogre::FocusedShadowCameraSetup::buildViewMatrix | ( | const Vector3 & | pos, | |
const Vector3 & | dir, | |||
const Vector3 & | up | |||
) | const [protected, inherited] |
Builds a view matrix.
void Ogre::FocusedShadowCameraSetup::calculateB | ( | const SceneManager & | sm, | |
const Camera & | cam, | |||
const Light & | light, | |||
const AxisAlignedBox & | sceneBB, | |||
const AxisAlignedBox & | receiverBB, | |||
PointListBody * | out_bodyB | |||
) | const [protected, inherited] |
Calculates the intersection bodyB.
sm,: | scene manager | |
cam,: | currently active camera | |
light,: | currently active light | |
sceneBB,: | scene bounding box for clipping operations | |
receiverAABB,: | bounding information for just the receivers | |
out_bodyB,: | final intersection bodyB point list |
Matrix4 Ogre::LiSPSMShadowCameraSetup::calculateLiSPSM | ( | const Matrix4 & | lightSpace, | |
const PointListBody & | bodyB, | |||
const PointListBody & | bodyLVS, | |||
const SceneManager & | sm, | |||
const Camera & | cam, | |||
const Light & | light | |||
) | const [protected, inherited] |
Calculates the LiSPSM projection matrix P.
lightSpace,: | matrix of the light space transformation | |
bodyB,: | intersection body B | |
bodyLVS,: | intersection body LVS (relevant space in front of the camera) | |
sm,: | scene manager | |
cam,: | currently active camera | |
light,: | currently active light |
void Ogre::FocusedShadowCameraSetup::calculateLVS | ( | const SceneManager & | sm, | |
const Camera & | cam, | |||
const Light & | light, | |||
const AxisAlignedBox & | sceneBB, | |||
PointListBody * | out_LVS | |||
) | const [protected, inherited] |
Calculates the bodyLVS.
scene,: | holds all potential occluders / receivers as one single bounding box of the currently active scene node | |
cam,: | current viewer camera | |
light,: | current light | |
out_LVS,: | intersection body LVS (world coordinates) |
Real Ogre::LiSPSMShadowCameraSetup::calculateNOpt | ( | const Matrix4 & | lightSpace, | |
const AxisAlignedBox & | bodyBABB_ls, | |||
const PointListBody & | bodyLVS, | |||
const Camera & | cam | |||
) | const [protected, inherited] |
Calculates the distance between camera position and near clipping plane.
Formula: d n_opt = --------------- sqrt(z1/z0) - 1
Parameters: d: distance between the near and the far clipping plane z0: located on the near clipping plane of the intersection body b z1: located on the far clipping plane with the same x/y values as z0
lightSpace,: | matrix of the light space transformation | |
bodyBABB_ls,: | bounding box of the transformed (light space) bodyB | |
bodyLVS,: | point list of the bodyLVS which describes the scene space which is in front of the light and the camera | |
cam,: | currently active camera |
Real Ogre::LiSPSMShadowCameraSetup::calculateNOptSimple | ( | const PointListBody & | bodyLVS, | |
const Camera & | cam | |||
) | const [protected, inherited] |
Calculates a simpler version than the one above.
void Ogre::FocusedShadowCameraSetup::calculateShadowMappingMatrix | ( | const SceneManager & | sm, | |
const Camera & | cam, | |||
const Light & | light, | |||
Matrix4 * | out_view, | |||
Matrix4 * | out_proj, | |||
Camera * | out_cam | |||
) | const [protected, inherited] |
Calculates the standard shadow mapping matrix.
sm,: | scene manager | |
cam,: | currently active camera | |
light,: | currently active light | |
out_view,: | calculated uniform view shadow mapping matrix (may be NULL) | |
out_proj,: | calculated uniform projection shadow mapping matrix (may be NULL) | |
out_cam,: | calculated uniform shadow camera (may be NULL) |
void Ogre::PSSMShadowCameraSetup::calculateSplitPoints | ( | size_t | splitCount, | |
Real | nearDist, | |||
Real | farDist, | |||
Real | lambda = 0.95 | |||
) |
Calculate a new splitting scheme.
splitCount | The number of splits to use | |
nearDist | The near plane to use for the first split | |
farDist | The far plane to use for the last split | |
lambda | Factor to use to reduce the split size |
Vector3 Ogre::LiSPSMShadowCameraSetup::calculateZ0_ls | ( | const Matrix4 & | lightSpace, | |
const Vector3 & | e, | |||
Real | bodyB_zMax_ls, | |||
const Camera & | cam | |||
) | const [protected, inherited] |
Calculates the visible point on the near plane for the n_opt calculation.
lightSpace,: | matrix of the light space transformation | |
e,: | the LiSPSM parameter e is located near or on the near clipping plane of the LiSPSM frustum C | |
bodyB_zMax_ls,: | maximum z-value of the light space bodyB bounding box | |
cam,: | currently active camera |
virtual Degree Ogre::LiSPSMShadowCameraSetup::getCameraLightDirectionThreshold | ( | ) | const [virtual, inherited] |
Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew.
Vector3 Ogre::FocusedShadowCameraSetup::getLSProjViewDir | ( | const Matrix4 & | lightSpace, | |
const Camera & | cam, | |||
const PointListBody & | bodyLVS | |||
) | const [protected, inherited] |
Returns the projection view direction.
lightSpace,: | matrix of the light space transformation | |
cam,: | current viewer camera | |
bodyLVS,: | intersection body LVS (relevant space in front of the camera) |
Vector3 Ogre::FocusedShadowCameraSetup::getNearCameraPoint_ws | ( | const Matrix4 & | viewMatrix, | |
const PointListBody & | bodyLVS | |||
) | const [protected, inherited] |
Returns a valid near-point seen by the camera.
viewMatrix,: | view matrix of the current camera | |
bodyLVS,: | intersection body LVS (relevant space in front of the camera) |
Real Ogre::PSSMShadowCameraSetup::getOptimalAdjustFactor | ( | ) | const [virtual] |
Overridden, recommended internal use only since depends on current iteration.
Reimplemented from Ogre::LiSPSMShadowCameraSetup.
Real Ogre::PSSMShadowCameraSetup::getOptimalAdjustFactor | ( | size_t | splitIndex | ) | const |
Returns the optimal adjust factor for a given split.
Definition at line 116 of file OgreShadowCameraSetupPSSM.h.
virtual void Ogre::PSSMShadowCameraSetup::getShadowCamera | ( | const Ogre::SceneManager * | sm, | |
const Ogre::Camera * | cam, | |||
const Ogre::Viewport * | vp, | |||
const Ogre::Light * | light, | |||
Ogre::Camera * | texCam, | |||
size_t | iteration | |||
) | const [virtual] |
Returns a LiSPSM shadow camera with PSSM splits base on iteration.
Reimplemented from Ogre::LiSPSMShadowCameraSetup.
size_t Ogre::PSSMShadowCameraSetup::getSplitCount | ( | ) | const |
Get the number of splits.
Definition at line 105 of file OgreShadowCameraSetupPSSM.h.
Real Ogre::PSSMShadowCameraSetup::getSplitPadding | ( | ) | const |
Get the padding factor to apply to the near & far distances when matching up splits to one another, to avoid 'cracks'.
Definition at line 103 of file OgreShadowCameraSetupPSSM.h.
const SplitPointList& Ogre::PSSMShadowCameraSetup::getSplitPoints | ( | ) | const |
Returns the calculated split points.
Definition at line 112 of file OgreShadowCameraSetupPSSM.h.
bool Ogre::FocusedShadowCameraSetup::getUseAggressiveFocusRegion | ( | ) | const [inherited] |
Definition at line 280 of file OgreShadowCameraSetupFocused.h.
virtual bool Ogre::LiSPSMShadowCameraSetup::getUseSimpleOptimalAdjust | ( | ) | const [virtual, inherited] |
Gets whether or not to use a slightly simpler version of the camera near point derivation (default is true).
Definition at line 228 of file OgreShadowCameraSetupLiSPSM.h.
void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr, | |
const char * | , | |||
int | , | |||
const char * | ||||
) | [inherited] |
Definition at line 107 of file OgreMemoryAllocatedObject.h.
void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr, | |
void * | ||||
) | [inherited] |
Definition at line 101 of file OgreMemoryAllocatedObject.h.
void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) | [inherited] |
Definition at line 95 of file OgreMemoryAllocatedObject.h.
void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr, | |
const char * | , | |||
int | , | |||
const char * | ||||
) | [inherited] |
Definition at line 118 of file OgreMemoryAllocatedObject.h.
void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) | [inherited] |
Definition at line 112 of file OgreMemoryAllocatedObject.h.
void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz, | |
void * | ptr | |||
) | [inherited] |
placement operator new
Definition at line 78 of file OgreMemoryAllocatedObject.h.
void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) | [inherited] |
Definition at line 72 of file OgreMemoryAllocatedObject.h.
void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz, | |
const char * | file, | |||
int | line, | |||
const char * | func | |||
) | [inherited] |
operator new, with debug line info
Definition at line 67 of file OgreMemoryAllocatedObject.h.
void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) | [inherited] |
Definition at line 90 of file OgreMemoryAllocatedObject.h.
void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz, | |
const char * | file, | |||
int | line, | |||
const char * | func | |||
) | [inherited] |
array operator new, with debug line info
Definition at line 85 of file OgreMemoryAllocatedObject.h.
virtual void Ogre::LiSPSMShadowCameraSetup::setCameraLightDirectionThreshold | ( | Degree | angle | ) | [virtual, inherited] |
Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew.
virtual void Ogre::LiSPSMShadowCameraSetup::setOptimalAdjustFactor | ( | Real | n | ) | [virtual, inherited] |
Adjusts the parameter n to produce optimal shadows.
n | The adjustment factor - default is 0.1f. |
Definition at line 216 of file OgreShadowCameraSetupLiSPSM.h.
void Ogre::PSSMShadowCameraSetup::setOptimalAdjustFactor | ( | size_t | splitIndex, | |
Real | factor | |||
) |
Set the LiSPSM optimal adjust factor for a given split (call after configuring splits).
void Ogre::PSSMShadowCameraSetup::setSplitPadding | ( | Real | pad | ) |
Set the padding factor to apply to the near & far distances when matching up splits to one another, to avoid 'cracks'.
Definition at line 98 of file OgreShadowCameraSetupPSSM.h.
void Ogre::PSSMShadowCameraSetup::setSplitPoints | ( | const SplitPointList & | newSplitPoints | ) |
Manually configure a new splitting scheme.
newSplitPoints | A list which is splitCount + 1 entries long, containing the split points. The first value is the near point, the last value is the far point, and each value in between is both a far point of the previous split, and a near point for the next one. |
void Ogre::FocusedShadowCameraSetup::setUseAggressiveFocusRegion | ( | bool | aggressive | ) | [inherited] |
Sets whether or not to use the more aggressive approach to deciding on the focus region or not.
aggressive | True to use the more aggressive approach, false otherwise. |
Definition at line 278 of file OgreShadowCameraSetupFocused.h.
virtual void Ogre::LiSPSMShadowCameraSetup::setUseSimpleOptimalAdjust | ( | bool | s | ) | [virtual, inherited] |
Sets whether or not to use a slightly simpler version of the camera near point derivation (default is true).
Definition at line 224 of file OgreShadowCameraSetupLiSPSM.h.
Matrix4 Ogre::FocusedShadowCameraSetup::transformToUnitCube | ( | const Matrix4 & | m, | |
const PointListBody & | body | |||
) | const [protected, inherited] |
Transforms a given body to the unit cube (-1,-1,-1) / (+1,+1,+1) with a specific shadow matrix enabled.
m,: | transformation matrix applied on the point list body | |
body,: | contains the points of the extends of all valid scene elements which are mapped to the unit cube |
ConvexBody Ogre::FocusedShadowCameraSetup::mBodyB [mutable, protected, inherited] |
Definition at line 144 of file OgreShadowCameraSetupFocused.h.
Real Ogre::LiSPSMShadowCameraSetup::mCosCamLightDirThreshold [protected, inherited] |
Threshold (cos angle) within which to start increasing the opt adjust as camera direction approaches light direction.
Definition at line 108 of file OgreShadowCameraSetupLiSPSM.h.
size_t Ogre::PSSMShadowCameraSetup::mCurrentIteration [mutable, protected] |
Definition at line 67 of file OgreShadowCameraSetupPSSM.h.
Camera* Ogre::FocusedShadowCameraSetup::mLightFrustumCamera [protected, inherited] |
Temporary preallocated camera to set up a light frustum for clipping in calculateB.
Definition at line 77 of file OgreShadowCameraSetupFocused.h.
bool Ogre::FocusedShadowCameraSetup::mLightFrustumCameraCalculated [mutable, protected, inherited] |
Definition at line 78 of file OgreShadowCameraSetupFocused.h.
Real Ogre::LiSPSMShadowCameraSetup::mOptAdjustFactor [protected, inherited] |
Warp factor adjustment.
Definition at line 102 of file OgreShadowCameraSetupLiSPSM.h.
Real Ogre::LiSPSMShadowCameraSetup::mOptAdjustFactorTweak [mutable, protected, inherited] |
Extra calculated warp factor.
Definition at line 106 of file OgreShadowCameraSetupLiSPSM.h.
Definition at line 64 of file OgreShadowCameraSetupPSSM.h.
PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyB [mutable, protected, inherited] |
Definition at line 145 of file OgreShadowCameraSetupFocused.h.
PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyLVS [mutable, protected, inherited] |
Definition at line 146 of file OgreShadowCameraSetupFocused.h.
const Matrix4 Ogre::FocusedShadowCameraSetup::msLightSpaceToNormal [static, protected, inherited] |
Definition at line 68 of file OgreShadowCameraSetupFocused.h.
const Matrix4 Ogre::FocusedShadowCameraSetup::msNormalToLightSpace [static, protected, inherited] |
Transform to or from light space as defined by Wimmer et al.
Definition at line 67 of file OgreShadowCameraSetupFocused.h.
size_t Ogre::PSSMShadowCameraSetup::mSplitCount [protected] |
Definition at line 62 of file OgreShadowCameraSetupPSSM.h.
Real Ogre::PSSMShadowCameraSetup::mSplitPadding [protected] |
Definition at line 65 of file OgreShadowCameraSetupPSSM.h.
Definition at line 63 of file OgreShadowCameraSetupPSSM.h.
Frustum* Ogre::FocusedShadowCameraSetup::mTempFrustum [protected, inherited] |
Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().
Definition at line 73 of file OgreShadowCameraSetupFocused.h.
bool Ogre::FocusedShadowCameraSetup::mUseAggressiveRegion [protected, inherited] |
Use tighter focus region?
Definition at line 81 of file OgreShadowCameraSetupFocused.h.
bool Ogre::LiSPSMShadowCameraSetup::mUseSimpleNOpt [protected, inherited] |
Use simple nopt derivation?
Definition at line 104 of file OgreShadowCameraSetupLiSPSM.h.
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:40:19 2012