OGRE  14.3
Object-Oriented Graphics Rendering Engine
Ogre::LiSPSMShadowCameraSetup Class Reference

Implements the Light Space Perspective Shadow Mapping Algorithm [17]. More...

#include <OgreShadowCameraSetupLiSPSM.h>

+ Inheritance diagram for Ogre::LiSPSMShadowCameraSetup:

Public Member Functions

 LiSPSMShadowCameraSetup (Real n=0.1f, bool useSimpleNOpt=true, Degree angle=Radian(0.451f))
 
virtual ~LiSPSMShadowCameraSetup ()
 
virtual Degree getCameraLightDirectionThreshold () const
 Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew. More...
 
virtual Real getOptimalAdjustFactor () const
 Get the parameter n used to produce optimal shadows. More...
 
void getShadowCamera (const SceneManager *sm, const Camera *cam, const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const override
 Returns a LiSPSM shadow camera. More...
 
virtual bool getUseSimpleOptimalAdjust () const
 Gets whether or not to use a slightly simpler version of the camera near point derivation (default is true) More...
 
void setCameraLightDirectionThreshold (Degree angle)
 Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew. More...
 
virtual void setOptimalAdjustFactor (Real n)
 Adjusts the parameter n to produce optimal shadows. More...
 
virtual void setUseSimpleOptimalAdjust (bool s)
 Sets whether or not to use a slightly simpler version of the camera near point derivation (default is true) More...
 
- Public Member Functions inherited from Ogre::FocusedShadowCameraSetup
 FocusedShadowCameraSetup (bool useAggressiveRegion=true)
 
 ~FocusedShadowCameraSetup ()
 
bool getUseAggressiveFocusRegion () const
 
void setUseAggressiveFocusRegion (bool aggressive)
 Sets whether or not to use the more aggressive approach to deciding on the focus region or not. More...
 
- Public Member Functions inherited from Ogre::DefaultShadowCameraSetup
 DefaultShadowCameraSetup ()
 
virtual ~DefaultShadowCameraSetup ()
 
- Public Member Functions inherited from Ogre::ShadowCameraSetup
virtual ~ShadowCameraSetup ()
 Need virtual destructor in case subclasses use it. More...
 

Static Public Member Functions

static ShadowCameraSetupPtr create (Real n=0.1f, bool useSimpleNOpt=true, Degree angle=Radian(0.451f))
 
- Static Public Member Functions inherited from Ogre::FocusedShadowCameraSetup
static ShadowCameraSetupPtr create (bool useAggressiveRegion=true)
 Create an instance. More...
 
- Static Public Member Functions inherited from Ogre::DefaultShadowCameraSetup
static ShadowCameraSetupPtr create ()
 

Detailed Description

Implements the Light Space Perspective Shadow Mapping Algorithm [17].

Shadow mapping was introduced by Williams in 1978. First a depth image is rendered from the light's view and compared in a second pass with depth values of the normal camera view. In case the depth camera's depth value is greater than the depth seen by the light the fragment lies in the shadow. The concept has a major draw back named perspective aliasing. The shadow map distri- butes the samples uniformly meaning the position of the viewer is ignored. For the viewer however the perspective projection affects near objects to be displayed bigger than further away objects. The same thing happens with the shadow map texels: Near shadows appear very coarse and far away shadows are perfectly sampled. PSM [15] battles the perspective aliasing by distributing 50% of the shadow map texels for objects in the range of < near clipping plane > to < near clipping plane * 2 > which inverts the problem: The shadows near the viewer are perfectly sampled, however far away shadow may contain aliasing artefacts. A near clipping plane may be a problem. But this is not the only one. In the post-perspective space the light sources are non-intuitively mapped: Directional lights may become point light and point lights may become directional lights. Also light sinks (opposite of a light source) may appear. Another problem are shadow casters located behind the viewer. In post-projective space objects behind the viewer are mapped in front of him with a flipped up-vector. LiSPSM battles the light source problem of the post-projective space by rearranging the light space before transformation in such a way that no special cases appear. This is done by converting point/spot lights into directional lights. The light space is arranged in such a way that the light direction equals the inverse UNIT_Y. In this combination the directional light will neither change its type nor its direction. Furthermore all visible objects and shadow casters affecting the user's visible area lie in front of the shadow camera: After building the intersection body that contains all these objects (body intersection building was introduced with PSM; have a look at the description for the method "calculateB" for further info) a frustum around the body's light space bounding box is created. A parameter (called 'n') automatically adjusts the shadow map sample distribution by specifying the frustum's view point - near plane which affects the perspective warp. In case the distance is small the perspecive warp will be strong. As a consequence near objects will gain quality. However there are still problems. PSM as well as LiSPSM only devote to minimize perspective aliasing. Projection aliasing is still a problem, also 'swimming artefacts' still occur. The LiSPSM quality distribution is very good but not the best available: Some sources say logarithmic shadow mapping [7] is the non plus ultra, however others reject this thought.

More information can be found on the webpage of the TU Wien: http://www.cg.tuwien.ac.at/research/vr/lispsm/

Original implementation by Matthias Fink matth.nosp@m.ias..nosp@m.fink@.nosp@m.web..nosp@m.de, 2006.

Constructor & Destructor Documentation

◆ LiSPSMShadowCameraSetup()

Ogre::LiSPSMShadowCameraSetup::LiSPSMShadowCameraSetup ( Real  n = 0.1f,
bool  useSimpleNOpt = true,
Degree  angle = Radian(0.451f) 
)

◆ ~LiSPSMShadowCameraSetup()

virtual Ogre::LiSPSMShadowCameraSetup::~LiSPSMShadowCameraSetup ( )
virtual

Member Function Documentation

◆ create()

static ShadowCameraSetupPtr Ogre::LiSPSMShadowCameraSetup::create ( Real  n = 0.1f,
bool  useSimpleNOpt = true,
Degree  angle = Radian(0.451f) 
)
inlinestatic
Parameters
nThe adjustment factor
useSimpleNOpt
anglecamera Light Direction Threshold

◆ getShadowCamera()

void Ogre::LiSPSMShadowCameraSetup::getShadowCamera ( const SceneManager sm,
const Camera cam,
const Viewport vp,
const Light light,
Camera texCam,
size_t  iteration 
) const
overridevirtual

Returns a LiSPSM shadow camera.

Builds and returns a LiSPSM shadow camera. More information can be found on the webpage of the TU Wien: http://www.cg.tuwien.ac.at/research/vr/lispsm/

Reimplemented from Ogre::FocusedShadowCameraSetup.

Reimplemented in Ogre::PSSMShadowCameraSetup.

◆ setOptimalAdjustFactor()

virtual void Ogre::LiSPSMShadowCameraSetup::setOptimalAdjustFactor ( Real  n)
inlinevirtual

Adjusts the parameter n to produce optimal shadows.

The smaller the parameter n, the stronger the perspective warping effect. The consequence of a stronger warping is that the near shadows will gain quality while the far ones will lose it. Depending on your scene and light types you may want to tweak this value - for example directional lights tend to benefit from higher values of n than other types of light, especially if you expect to see more distant shadows (say if the viewpoint is higher above the ground plane). Remember that you can supply separate ShadowCameraSetup instances configured differently per light if you wish.

Parameters
nThe adjustment factor - default is 0.1f.

◆ getOptimalAdjustFactor()

virtual Real Ogre::LiSPSMShadowCameraSetup::getOptimalAdjustFactor ( ) const
inlinevirtual

Get the parameter n used to produce optimal shadows.

See also
setOptimalAdjustFactor

Reimplemented in Ogre::PSSMShadowCameraSetup.

◆ setUseSimpleOptimalAdjust()

virtual void Ogre::LiSPSMShadowCameraSetup::setUseSimpleOptimalAdjust ( bool  s)
inlinevirtual

Sets whether or not to use a slightly simpler version of the camera near point derivation (default is true)

◆ getUseSimpleOptimalAdjust()

virtual bool Ogre::LiSPSMShadowCameraSetup::getUseSimpleOptimalAdjust ( ) const
inlinevirtual

Gets whether or not to use a slightly simpler version of the camera near point derivation (default is true)

◆ setCameraLightDirectionThreshold()

void Ogre::LiSPSMShadowCameraSetup::setCameraLightDirectionThreshold ( Degree  angle)

Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew.

For example, setting this to 20 degrees will mean that as the difference between the light and camera direction reduces from 20 degrees to 0 degrees, the perspective skew will be proportionately removed.

◆ getCameraLightDirectionThreshold()

virtual Degree Ogre::LiSPSMShadowCameraSetup::getCameraLightDirectionThreshold ( ) const
virtual

Sets the threshold between the camera and the light direction below which the LiSPSM projection is 'flattened', since coincident light and camera projections cause problems with the perspective skew.


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