Ogre::FocusedShadowCameraSetup Class Reference
Core » Scene

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

`#include <OgreShadowCameraSetupFocused.h>`

Inheritance diagram for Ogre::FocusedShadowCameraSetup:
[legend]

## 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
Camera * | mLightFrustumCamera
| Temporary preallocated camera to set up a light frustum for clipping in FocusedShadowCameraSetup::calculateB. More...
bool | mLightFrustumCameraCalculated
PointListBody | mPointListBodyB
PointListBody | mPointListBodyLVS
Frustum * | mTempFrustum
| 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

## FocusedShadowCameraSetup()

Ogre::FocusedShadowCameraSetup::FocusedShadowCameraSetup | ( | void |  | ) |

Default constructor.

Remarks
  Temporary frustum and camera set up here.

## ~FocusedShadowCameraSetup()

virtual Ogre::FocusedShadowCameraSetup::~FocusedShadowCameraSetup | ( | void |  | ) |

virtual

Default destructor.

Remarks
  Temporary frustum and camera destroyed here.

## Member Function Documentation

## buildViewMatrix()

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.

## calculateB()

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.
  receiverBB | Bounding information for just the receivers.
  out_bodyB | Final intersection bodyB point list.

## calculateLVS()

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

  cam | Current viewer camera.
  light | Current light.
  sceneBB | Holds all potential occluders / receivers as one single bounding box of the currently active scene node.
  out_LVS | Intersection body LVS (world coordinates).

## calculateShadowMappingMatrix()

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`).

## getLSProjViewDir()

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

## getNearCameraPoint_ws()

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

## getShadowCamera()

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.

## getUseAggressiveFocusRegion()

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

Definition at line 305 of file OgreShadowCameraSetupFocused.h.

## operator delete() [1/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) |

inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

## operator delete() [2/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  |

inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

## operator delete() [3/3]

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.

## operator delete[]() [1/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) |

inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [2/2]

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.

## operator new() [1/3]

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.

## operator new() [2/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) |

inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

## operator new() [3/3]

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.

## operator new[]() [1/2]

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.

## operator new[]() [2/2]

template<class Alloc >

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

inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

## setUseAggressiveFocusRegion()

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

## transformToUnitCube()

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

## mBodyB

ConvexBody Ogre::FocusedShadowCameraSetup::mBodyB

mutable protected

Definition at line 145 of file OgreShadowCameraSetupFocused.h.

## mLightFrustumCamera

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.

## mLightFrustumCameraCalculated

bool Ogre::FocusedShadowCameraSetup::mLightFrustumCameraCalculated

mutable protected

Definition at line 79 of file OgreShadowCameraSetupFocused.h.

## mPointListBodyB

PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyB

mutable protected

Definition at line 146 of file OgreShadowCameraSetupFocused.h.

## mPointListBodyLVS

PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyLVS

mutable protected

Definition at line 147 of file OgreShadowCameraSetupFocused.h.

## msLightSpaceToNormal

const Matrix4 Ogre::FocusedShadowCameraSetup::msLightSpaceToNormal

static protected

Definition at line 69 of file OgreShadowCameraSetupFocused.h.

## msNormalToLightSpace

const Matrix4 Ogre::FocusedShadowCameraSetup::msNormalToLightSpace

static protected

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.

## mTempFrustum

Frustum* Ogre::FocusedShadowCameraSetup::mTempFrustum

protected

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

Definition at line 74 of file OgreShadowCameraSetupFocused.h.

## mUseAggressiveRegion

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:

- OgreShadowCameraSetupFocused.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.