Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# Ogre::FocusedShadowCameraSetup Class Reference

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

`#include <OgreShadowCameraSetupFocused.h>`

Inheritance diagram for Ogre::FocusedShadowCameraSetup:

[legend]
List of all members.

## 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) const
| Returns a uniform shadow camera with a focused view.
void | setUseAggressiveFocusRegion (bool aggressive)
| Sets whether or not to use the more agressive approach to deciding on the focus region or not.
bool | getUseAggressiveFocusRegion () const
## 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, 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
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
## Classes
class | PointListBody
| Internal class holding a point list representation of a convex body. 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 <matthias.fink@web.de>, 2006.

Definition at line 52 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,
|  | 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
  | 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
| ) | const`[virtual]`

| Returns a uniform shadow camera with a focused view. Implements Ogre::ShadowCameraSetup. Reimplemented in Ogre::LiSPSMShadowCameraSetup.

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

| Definition at line 274 of file OgreShadowCameraSetupFocused.h.

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

  | Sets whether or not to use the more agressive 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 agressive version. Parameters:
  | aggressive | True to use the more agressive approach, false otherwise.
Definition at line 272 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

ConvexBody Ogre::FocusedShadowCameraSetup::mBodyB`[mutable, protected]`

| Definition at line 139 of file OgreShadowCameraSetupFocused.h.

Camera* Ogre::FocusedShadowCameraSetup::mLightFrustumCamera`[protected]`

| Temporary preallocated camera to set up a light frustum for clipping in ::calculateB. Definition at line 72 of file OgreShadowCameraSetupFocused.h.

bool Ogre::FocusedShadowCameraSetup::mLightFrustumCameraCalculated`[mutable, protected]`

| Definition at line 73 of file OgreShadowCameraSetupFocused.h.

PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyB`[mutable, protected]`

| Definition at line 140 of file OgreShadowCameraSetupFocused.h.

PointListBody Ogre::FocusedShadowCameraSetup::mPointListBodyLVS`[mutable, protected]`

| Definition at line 141 of file OgreShadowCameraSetupFocused.h.

const Matrix4 Ogre::FocusedShadowCameraSetup::msLightSpaceToNormal`[static, protected]`

| Definition at line 63 of file OgreShadowCameraSetupFocused.h.

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

Frustum* Ogre::FocusedShadowCameraSetup::mTempFrustum`[protected]`

| Temporary preallocated frustum to set up a projection matrix in ::calculateShadowMappingMatrix(). Definition at line 68 of file OgreShadowCameraSetupFocused.h.

bool Ogre::FocusedShadowCameraSetup::mUseAggressiveRegion`[protected]`

| Use tighter focus region? Definition at line 76 of file OgreShadowCameraSetupFocused.h.

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

- OgreShadowCameraSetupFocused.h

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:48:49 2008