OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::FocusedShadowCameraSetup Class Reference

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

#include <OgreShadowCameraSetupFocused.h>

+ Inheritance diagram for Ogre::FocusedShadowCameraSetup:
+ Collaboration diagram for Ogre::FocusedShadowCameraSetup:

Classes

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

Public Member Functions

 FocusedShadowCameraSetup (void)
 Default constructor. More...
 
virtual ~FocusedShadowCameraSetup (void)
 Default destructor. More...
 
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. More...
 
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 More...
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
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. More...
 

Protected Member Functions

Matrix4 buildViewMatrix (const Vector3 &pos, const Vector3 &dir, const Vector3 &up) const
 Builds a view matrix. More...
 
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. More...
 
void calculateLVS (const SceneManager &sm, const Camera &cam, const Light &light, const AxisAlignedBox &sceneBB, PointListBody *out_LVS) const
 Calculates the bodyLVS. More...
 
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. More...
 
Vector3 getLSProjViewDir (const Matrix4 &lightSpace, const Camera &cam, const PointListBody &bodyLVS) const
 Returns the projection view direction. More...
 
Vector3 getNearCameraPoint_ws (const Matrix4 &viewMatrix, const PointListBody &bodyLVS) const
 Returns a valid near-point seen by the camera. More...
 
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. More...
 

Protected Attributes

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

Static Protected Attributes

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

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 matth.nosp@m.ias..nosp@m.fink@.nosp@m.web..nosp@m.de, 2006.

Definition at line 58 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
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.

bool Ogre::FocusedShadowCameraSetup::getUseAggressiveFocusRegion ( ) const
inline

Definition at line 305 of file OgreShadowCameraSetupFocused.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

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

Definition at line 102 of file OgreMemoryAllocatedObject.h.

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

Definition at line 108 of file OgreMemoryAllocatedObject.h.

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

Definition at line 113 of file OgreMemoryAllocatedObject.h.

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

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 
)
inlineinherited

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)
inlineinherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

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

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 
)
inlineinherited

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)
inlineinherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

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

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

ConvexBody Ogre::FocusedShadowCameraSetup::mBodyB
mutableprotected

Definition at line 145 of file OgreShadowCameraSetupFocused.h.

Camera* Ogre::FocusedShadowCameraSetup::mLightFrustumCamera
protected

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

Definition at line 78 of file OgreShadowCameraSetupFocused.h.

bool Ogre::FocusedShadowCameraSetup::mLightFrustumCameraCalculated
mutableprotected

Definition at line 79 of file OgreShadowCameraSetupFocused.h.

PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyB
mutableprotected

Definition at line 146 of file OgreShadowCameraSetupFocused.h.

PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyLVS
mutableprotected

Definition at line 147 of file OgreShadowCameraSetupFocused.h.

const Matrix4 Ogre::FocusedShadowCameraSetup::msLightSpaceToNormal
staticprotected

Definition at line 69 of file OgreShadowCameraSetupFocused.h.

const Matrix4 Ogre::FocusedShadowCameraSetup::msNormalToLightSpace
staticprotected

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.

Frustum* Ogre::FocusedShadowCameraSetup::mTempFrustum
protected

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

Definition at line 74 of file OgreShadowCameraSetupFocused.h.

bool Ogre::FocusedShadowCameraSetup::mUseAggressiveRegion
protected

Use tighter focus region?

Definition at line 82 of file OgreShadowCameraSetupFocused.h.


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