Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
Ogre::FocusedShadowCameraSetup Class Reference

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.
bool getUseAggressiveFocusRegion () const
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 *)
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 setUseAggressiveFocusRegion (bool aggressive)
 Sets whether or not to use the more aggressive approach to deciding on the focus region or not.

Protected Member Functions

Matrix4 buildViewMatrix (const Vector3 &pos, const Vector3 &dir, const Vector3 &up) const
 Builds a view 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.
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.
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.

Protected Attributes

ConvexBody mBodyB
CameramLightFrustumCamera
 Temporary preallocated camera to set up a light frustum for clipping in FocusedShadowCameraSetup::calculateB.
bool mLightFrustumCameraCalculated
PointListBody mPointListBodyB
PointListBody mPointListBodyLVS
FrustummTempFrustum
 Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().
bool mUseAggressiveRegion
 Use tighter focus region?

Static Protected Attributes

static const Matrix4 msLightSpaceToNormal
static const Matrix4 msNormalToLightSpace
 Transform to or from light space as defined by Wimmer et al.

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 58 of file OgreShadowCameraSetupFocused.h.


Constructor & Destructor Documentation

Default constructor.

Remarks:
Temporary frustum and camera set up here.

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:
smScene manager.
camCurrently active camera.
lightCurrently active light.
sceneBBScene bounding box for clipping operations.
receiverBBBounding information for just the receivers.
out_bodyBFinal 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:
camCurrent viewer camera.
lightCurrent light.
sceneBBHolds all potential occluders / receivers as one single bounding box of the currently active scene node.
out_LVSIntersection 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:
smScene manager.
camCurrently active camera.
lightCurrently active light.
out_viewCalculated uniform view shadow mapping matrix (may be NULL).
out_projCalculated uniform projection shadow mapping matrix (may be NULL).
out_camCalculated 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:
lightSpaceMatrix of the light space transformation.
camCurrent viewer camera.
bodyLVSIntersection 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:
viewMatrixView matrix of the current camera.
bodyLVSIntersection 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.

Definition at line 305 of file OgreShadowCameraSetupFocused.h.

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

Definition at line 96 of file OgreMemoryAllocatedObject.h.

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

Definition at line 102 of file OgreMemoryAllocatedObject.h.

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

Definition at line 108 of file OgreMemoryAllocatedObject.h.

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

Definition at line 113 of file OgreMemoryAllocatedObject.h.

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

Definition at line 119 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 68 of file OgreMemoryAllocatedObject.h.

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

Definition at line 73 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 79 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 86 of file OgreMemoryAllocatedObject.h.

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

Definition at line 91 of file OgreMemoryAllocatedObject.h.

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:
aggressiveTrue to use the more aggressive approach, false otherwise.

Definition at line 303 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:
mTransformation matrix applied on the point list body.
bodyContains the points of the extends of all valid scene elements which are mapped to the unit cube.

Member Data Documentation

Definition at line 145 of file OgreShadowCameraSetupFocused.h.

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

Definition at line 78 of file OgreShadowCameraSetupFocused.h.

Definition at line 79 of file OgreShadowCameraSetupFocused.h.

Definition at line 146 of file OgreShadowCameraSetupFocused.h.

Definition at line 147 of file OgreShadowCameraSetupFocused.h.

Definition at line 69 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 68 of file OgreShadowCameraSetupFocused.h.

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

Definition at line 74 of file OgreShadowCameraSetupFocused.h.

Use tighter focus region?

Definition at line 82 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 Mon Jul 27 2020 13:41:02