Ogre::FocusedShadowCameraSetup Class Reference
[Scene]

Implements the uniform shadow mapping algorithm in focused mode. More...

#include <OgreShadowCameraSetupFocused.h>

Inheritance diagram for Ogre::FocusedShadowCameraSetup:
Inheritance graph
[legend]

List of all members.

Classes

class  PointListBody
 Internal class holding a point list representation of a convex body. More...

Public Member Functions

 FocusedShadowCameraSetup (void)
 Default constructor.
virtual ~FocusedShadowCameraSetup (void)
 Default destructor.
virtual void getShadowCamera (const SceneManager *sm, const Camera *cam, const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const
 Returns a uniform shadow camera with a focused view.
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

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

FrustummTempFrustum
 Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().
CameramLightFrustumCamera
 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

Detailed Description

Implements the uniform shadow mapping algorithm in focused mode.

Remarks:
Differs from the default shadow mapping projection in that it focuses the shadow map on the visible areas of the scene. This results in better shadow map texel usage, at the expense of some 'swimming' of the shadow texture on receivers as the basis is constantly being reevaluated.
Note:
Original implementation by Matthias Fink <matthias.fink@web.de>, 2006.

Definition at line 57 of file OgreShadowCameraSetupFocused.h.


Constructor & Destructor Documentation

Ogre::FocusedShadowCameraSetup::FocusedShadowCameraSetup ( void   ) 

Default constructor.

Remarks:
Temporary frustum and camera set up here.
virtual Ogre::FocusedShadowCameraSetup::~FocusedShadowCameraSetup ( void   )  [virtual]

Default destructor.

Remarks:
Temporary frustum and camera destroyed here.

Member Function Documentation

Matrix4 Ogre::FocusedShadowCameraSetup::buildViewMatrix ( const Vector3 pos,
const Vector3 dir,
const Vector3 up 
) const [protected]

Builds a view matrix.

Remarks:
Builds a standard view matrix out of a given position, direction and up vector.
void Ogre::FocusedShadowCameraSetup::calculateB ( const SceneManager sm,
const Camera cam,
const Light light,
const AxisAlignedBox sceneBB,
const AxisAlignedBox receiverBB,
PointListBody out_bodyB 
) const [protected]

Calculates the intersection bodyB.

Remarks:
The intersection bodyB consists of the concatenation the cam frustum clipped by the scene bounding box followed by a convex hullification with the light's position and the clipping with the scene bounding box and the light frustum: ((V S) + l) S L (: convex intersection, +: convex hull operation). For directional lights the bodyB is assembled out of the camera frustum clipped by the scene bounding box followed by the extrusion of all available bodyB points towards the negative light direction. The rays are intersected by a maximum bounding box and added to the bodyB points to form the final intersection bodyB point list.
Parameters:
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
void Ogre::FocusedShadowCameraSetup::calculateLVS ( const SceneManager sm,
const Camera cam,
const Light light,
const AxisAlignedBox sceneBB,
PointListBody out_LVS 
) const [protected]

Calculates the bodyLVS.

Remarks:
Calculates the bodyLVS which consists of the convex intersection operation affecting the light frustum, the view frustum, and the current scene bounding box is used to find suitable positions in the viewer's frustum to build the rotation matrix L_r. This matrix is applied after the projection matrix L_p to avoid an accidental flip of the frustum orientation for views tilted with respect to the shadow map.
Parameters:
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)
void Ogre::FocusedShadowCameraSetup::calculateShadowMappingMatrix ( const SceneManager sm,
const Camera cam,
const Light light,
Matrix4 out_view,
Matrix4 out_proj,
Camera out_cam 
) const [protected]

Calculates the standard shadow mapping matrix.

Remarks:
Provides the view and projection matrix for standard shadow mapping.
Note:
You can choose which things you want to have: view matrix and/or projection matrix and/or shadow camera. Passing a NULL value as parameter ignores the generation of this specific value.
Parameters:
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)
Vector3 Ogre::FocusedShadowCameraSetup::getLSProjViewDir ( const Matrix4 lightSpace,
const Camera cam,
const PointListBody bodyLVS 
) const [protected]

Returns the projection view direction.

Remarks:
After the matrix L_p is applied the orientation of the light space may tilt for non-identity projections. To prevent a false shadow cast the real view direction is evaluated and applied to the light matrix L.
Parameters:
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]

Returns a valid near-point seen by the camera.

Remarks:
Returns a point that is situated near the camera by analyzing the bodyLVS that contains all the relevant scene space in front of the light and the camera in a point list array. The view matrix is relevant because the nearest point in front of the camera should be determined.
Parameters:
viewMatrix,: view matrix of the current camera
bodyLVS,: intersection body LVS (relevant space in front of the camera)
virtual void Ogre::FocusedShadowCameraSetup::getShadowCamera ( const SceneManager sm,
const Camera cam,
const Viewport vp,
const Light light,
Camera texCam,
size_t  iteration 
) const [virtual]

Returns a uniform shadow camera with a focused view.

Implements Ogre::ShadowCameraSetup.

Reimplemented in Ogre::LiSPSMShadowCameraSetup, and Ogre::PSSMShadowCameraSetup.

bool Ogre::FocusedShadowCameraSetup::getUseAggressiveFocusRegion (  )  const

Definition at line 280 of file OgreShadowCameraSetupFocused.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
) [inherited]

Definition at line 107 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
) [inherited]

Definition at line 101 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr  )  [inherited]

Definition at line 95 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
) [inherited]

Definition at line 118 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr  )  [inherited]

Definition at line 112 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
) [inherited]

placement operator new

Definition at line 78 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz  )  [inherited]

Definition at line 72 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
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.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz  )  [inherited]

Definition at line 90 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
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.

void Ogre::FocusedShadowCameraSetup::setUseAggressiveFocusRegion ( bool  aggressive  ) 

Sets whether or not to use the more aggressive approach to deciding on the focus region or not.

Note:
There are 2 approaches that can be used to define the focus region, the more aggressive way introduced by Wimmer et al, or the original way as described in Stamminger et al. Wimmer et al's way tends to come up with a tighter focus region but in rare cases (mostly highly glancing angles) can cause some shadow casters to be clipped incorrectly. By default the more aggressive approach is used since it leads to significantly better results in most cases, but if you experience clipping issues, you can use the less aggressive version.
Parameters:
aggressive True to use the more aggressive approach, false otherwise.

Definition at line 278 of file OgreShadowCameraSetupFocused.h.

Matrix4 Ogre::FocusedShadowCameraSetup::transformToUnitCube ( const Matrix4 m,
const PointListBody body 
) const [protected]

Transforms a given body to the unit cube (-1,-1,-1) / (+1,+1,+1) with a specific shadow matrix enabled.

Remarks:
Transforms a given point list body object with the matrix m and then maps its extends to a (-1,-1,-1) / (+1,+1,+1) unit cube
Parameters:
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

Member Data Documentation

Definition at line 144 of file OgreShadowCameraSetupFocused.h.

Temporary preallocated camera to set up a light frustum for clipping in calculateB.

Definition at line 77 of file OgreShadowCameraSetupFocused.h.

Definition at line 78 of file OgreShadowCameraSetupFocused.h.

Definition at line 145 of file OgreShadowCameraSetupFocused.h.

Definition at line 146 of file OgreShadowCameraSetupFocused.h.

Definition at line 68 of file OgreShadowCameraSetupFocused.h.

Transform to or from light space as defined by Wimmer et al.

Remarks:
Point and spot lights need to be converted to directional lights to enable a 1:1 light mapping. Otherwise a directional light may become a point light or a point sink (opposite of a light source) or point/spot lights may become directional lights or light sinks. The light direction is always -y.

Definition at line 67 of file OgreShadowCameraSetupFocused.h.

Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().

Definition at line 73 of file OgreShadowCameraSetupFocused.h.

Use tighter focus region?

Definition at line 81 of file OgreShadowCameraSetupFocused.h.


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

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:40:17 2012