ShadowCaster Class Reference


Detailed Description

ShadowCaster represents all the information needed to generate a shadow map for a light.

It's used by a Light node.If a Light node can cast shadow, it should generate a ShadowCaster.

ShadowReceiver represents all the information needed render shadow for a surface. It's owned by a Appearance node which can receive shadow.

These two classes will listen to the deletion of each other, so that when the light is deleted or shadow disabled or when appearance disables shadow, they can be easily separated.

#include <ShadowCaster.h>

Inheritance diagram for ShadowCaster:
Inheritance graph
[legend]

List of all members.

Public Types

enum   DirtyFlag {
  kShadowType, kCasters, kReceivers, kLight,
  kSceneCamera, kParameters
}
enum   ShadowType { kSimpleShadowMap, kCascadedShadowMap, kSoftShadowMap, kEnvGroundShadowMap }

Public Member Functions

  ShadowCaster ()
  ShadowCaster (const ShadowCaster &)
void  setName (const awString::IString &shadowId)
const awString::IString &  getName () const
bool  isEnvLight () const
bool  isInELGS_Mode () const
void  resetCasterNodes ()
bool  addCasterNode (const awString::IString &nodeId)
bool  removeCasterNode (const awString::IString &nodeId)
const aw::unordered_set
< awString::IString > & 
getCasterNodeIds () const
int  getNumCasterNodes () const
void  updateRTCasters (bool update)
virtual void  resetAllRTCasters ()
void  resetReceiverNodes ()
bool  addReceiverNode (const awString::IString &nodeId)
const aw::unordered_set
< awString::IString > & 
getReceiverNodeIds () const
int  getNumReceiverNodes () const
bool  setLight (const awString::IString &lightId)
const awString::IString &  getLightId () const
bool  isDirty () const
  Returns true if any of the shadow specific dirty flags are set, or if the caster or the receiver were signalled as being modified.
void  setAllDirty (bool dirty)
bool  isDirty (DirtyFlag flag) const
void  setDirty (DirtyFlag flag, bool dirty)
void  notifyReceivers ()
void  notifyParentLight ()
bool  isValid () const
void  setValid (bool)
int  getViewportIndex () const
  For comparison mode.
VisibilityMask  getVisibilityMask () const
void  setViewportIndexAndVisibilityMask (int, VisibilityMask)
virtual void  rebind ()
  Rebind this shadowCaster to light and shadow receivers.
virtual bool  update ()
  The method will update internal resources when receiver or caster or light has changed indicated by the dirty flag Returns: wether the shadow map should be re-rendered.
bool  isEnabled () const
void  setIsEnabled (bool)
void  setShadowType (ShadowType type)
ShadowType  getShadowType () const
void  setShadowMapSize (int size)
int  getShadowMapSize () const
void  setShadowMapConstBias (float bias)
float  getShadowMapConstBias () const
void  setUseShadowMapSlopeBias (bool)
bool  getUseShadowMapSlopeBias () const
void  setShadowColour (float r, float g, float b)
  Pixels in-shadow are currently interpolated to some colour.
void  getShadowColour (float &r, float &g, float &b) const
void  setShadowDensity (float value)
  Controls the global density of the shadow.
float  getShadowDensity () const
void  setIsSoftEdgesEnabled (bool value)
bool  getIsSoftEdgesEnabled () const
void  setShadowSoftness (int value)
int  getShadowSoftness () const
void  setShadowExpFactor (float expPos, float expNeg)
  EVSM Soft shadow parameter, control the soft edge.
void  getShadowExpFactor (float &expPos, float &expNeg) const
void  setShadowThreshold (float value)
  Soft shadow parameter to improve light bleeding.
float  getShadowThreshold () const
void  setShadowSoftBorder (float value)
  The fraction of the shadow map size that should be excluded from sampling to account for shadow map blurring (softness).
float  getShadowSoftBorder () const
void  setLightRadius (float value)
  Light radius represents the relative blurring of the Environment Ground Shadows.
float  getLightRadius () const
void  setShadowFalloffRange (float value)
  FalloffRange represents the distance from the caster to the receiver at which the shadow should die off (i.e.
float  getShadowFalloffRange () const
void  setShadowFalloffPower (float value)
  FalloffPower controls the rate at which the shadow falls off based on a curve.
float  getShadowFalloffPower () const
void  setExposureScale (float m)
float  getExposureScale ()

Static Public Attributes

static const awString::IString  kShadowEnabled
static const awString::IString  kShadowMapSize
static const awString::IString  kShadowMapConstBias
static const awString::IString  kShadowMapUseSlopeBias
static const awString::IString  kShadowColour
static const awString::IString  kShadowDensity
static const awString::IString  kShadowSoftEdgeEnabled
static const awString::IString  kShadowSoftness
static const awString::IString  kShadowExpFactor
static const awString::IString  kShadowThreshold
static const awString::IString  kShadowSoftBorder
static const awString::IString  kShadowLightRadius
static const awString::IString  kShadowFalloffRange
static const awString::IString  kShadowFalloffPower

Protected Member Functions

virtual  ~ShadowCaster ()
virtual void  onNodeDirty (Node *node)
virtual void  onNodeDeleted (Node *node)
template<int size>
void  getFloatValues (const awString::IString &parameterName, float *value) const
  helper functions
template<int size>
bool  setFloatValues (const awString::IString &parameterName, float *value)
virtual void  onParameterChanged (const awString::IString &param)
void  updateReceiverAppearance (Node *, bool add)

Protected Attributes

ShadowType  myShadowType
awString::IString  myLightId
aw::unordered_set
< awString::IString > 
myCasterIds
aw::unordered_set
< awString::IString > 
myReceiverIds
awLinear::Range3d  myCastersBox
awLinear::Range3d  myReceiversBox
ShadowReceiverRef  myReceiver
awUtil::BitField32  myDirtyFlags
bool  myIsValid
bool  myIsEnabled
awSupport::ValueParameterGroupRef  myParameters
bool  myIsEnvLight
int  myViewportIndex
VisibilityMask  myVisibilityMask
float  myExposureScale
bool  myUpdateRT
bool  myResetRTCasters

Member Enumeration Documentation

Enumerator:
kShadowType 
kCasters 
kReceivers 
kLight 
kSceneCamera 
kParameters 
    {
        kShadowType,  // When shadow type changed
        kCasters,     // When the casters have changed, or their bounding box or visibility has changed.
        kReceivers,   // When the receivers have changed, or their properties have changed.
        kLight,       // When the light has changed, or its properties have changed.
        kSceneCamera, // When the scene camera has changed.
        kParameters,  // When the shadow parameters have changed.
    };

Constructor & Destructor Documentation

ShadowCaster ( const ShadowCaster )
virtual ~ShadowCaster ( ) [protected, virtual]

Member Function Documentation

void setName ( const awString::IString &  shadowId )
const awString::IString& getName ( ) const
bool isEnvLight ( ) const
bool isInELGS_Mode ( ) const
void resetCasterNodes ( )
bool addCasterNode ( const awString::IString &  nodeId )
bool removeCasterNode ( const awString::IString &  nodeId )
const aw::unordered_set<awString::IString>& getCasterNodeIds ( ) const
int getNumCasterNodes ( ) const
void updateRTCasters ( bool  update )
virtual void resetAllRTCasters ( ) [virtual]
void resetReceiverNodes ( )
bool addReceiverNode ( const awString::IString &  nodeId )
const aw::unordered_set<awString::IString>& getReceiverNodeIds ( ) const
int getNumReceiverNodes ( ) const
bool setLight ( const awString::IString &  lightId )
const awString::IString& getLightId ( ) const
bool isDirty ( ) const

Returns true if any of the shadow specific dirty flags are set, or if the caster or the receiver were signalled as being modified.

void setAllDirty ( bool  dirty )
bool isDirty ( DirtyFlag  flag ) const
void setDirty ( DirtyFlag  flag,
bool  dirty 
)
void notifyReceivers ( )
void notifyParentLight ( )
bool isValid ( ) const
void setValid ( bool  )
int getViewportIndex ( ) const

For comparison mode.

VisibilityMask getVisibilityMask ( ) const
void setViewportIndexAndVisibilityMask ( int  ,
VisibilityMask   
)
virtual void rebind ( ) [virtual]

Rebind this shadowCaster to light and shadow receivers.

virtual bool update ( ) [virtual]

The method will update internal resources when receiver or caster or light has changed indicated by the dirty flag Returns: wether the shadow map should be re-rendered.

bool isEnabled ( ) const
void setIsEnabled ( bool  )
void setShadowType ( ShadowType  type )
ShadowType getShadowType ( ) const
void setShadowMapSize ( int  size )
int getShadowMapSize ( ) const
void setShadowMapConstBias ( float  bias )
float getShadowMapConstBias ( ) const
void setUseShadowMapSlopeBias ( bool  )
bool getUseShadowMapSlopeBias ( ) const
void setShadowColour ( float  r,
float  g,
float  b 
)

Pixels in-shadow are currently interpolated to some colour.

By default, that colour is black, but you can make a blue shadow if you want.

void getShadowColour ( float &  r,
float &  g,
float &  b 
) const
void setShadowDensity ( float  value )

Controls the global density of the shadow.

A value of 1.0 would mean fully intense (pixels in shadow can become shadowColour), whereas a value of 0.5 would means half intensity.

float getShadowDensity ( ) const
void setIsSoftEdgesEnabled ( bool  value )
bool getIsSoftEdgesEnabled ( ) const
void setShadowSoftness ( int  value )
int getShadowSoftness ( ) const
void setShadowExpFactor ( float  expPos,
float  expNeg 
)

EVSM Soft shadow parameter, control the soft edge.

void getShadowExpFactor ( float &  expPos,
float &  expNeg 
) const
void setShadowThreshold ( float  value )

Soft shadow parameter to improve light bleeding.

The threshold has a range of 0.0 to 1.0. It clamps the light to zero at the threshold value. This also affects shadow edges, so the value really should not exceed 0.2 to keep the edges soft.

float getShadowThreshold ( ) const
void setShadowSoftBorder ( float  value )

The fraction of the shadow map size that should be excluded from sampling to account for shadow map blurring (softness).

float getShadowSoftBorder ( ) const
void setLightRadius ( float  value )

Light radius represents the relative blurring of the Environment Ground Shadows.

float getLightRadius ( ) const
void setShadowFalloffRange ( float  value )

FalloffRange represents the distance from the caster to the receiver at which the shadow should die off (i.e.

no shadow). See also setShadowFalloffPower().

float getShadowFalloffRange ( ) const
void setShadowFalloffPower ( float  value )

FalloffPower controls the rate at which the shadow falls off based on a curve.

For example, a value of 0.5 means the shadow falls off quadratically, while a value of 1.0 means the shadow falls off linearly. See also setShadowFalloffRange().

float getShadowFalloffPower ( ) const
void setExposureScale ( float  m )
float getExposureScale ( )
virtual void onNodeDirty ( Node node ) [protected, virtual]
virtual void onNodeDeleted ( Node node ) [protected, virtual]
void getFloatValues ( const awString::IString &  parameterName,
float *  value 
) const [protected]

helper functions

bool setFloatValues ( const awString::IString &  parameterName,
float *  value 
) [protected]
virtual void onParameterChanged ( const awString::IString &  param ) [protected, virtual]
void updateReceiverAppearance ( Node ,
bool  add 
) [protected]

Member Data Documentation

const awString::IString kShadowEnabled [static]
const awString::IString kShadowMapSize [static]
const awString::IString kShadowMapConstBias [static]
const awString::IString kShadowMapUseSlopeBias [static]
const awString::IString kShadowColour [static]
const awString::IString kShadowDensity [static]
const awString::IString kShadowSoftEdgeEnabled [static]
const awString::IString kShadowSoftness [static]
const awString::IString kShadowExpFactor [static]
const awString::IString kShadowThreshold [static]
const awString::IString kShadowSoftBorder [static]
const awString::IString kShadowLightRadius [static]
const awString::IString kShadowFalloffRange [static]
const awString::IString kShadowFalloffPower [static]
awString::IString myLightId [protected]
aw::unordered_set<awString::IString> myCasterIds [protected]
aw::unordered_set<awString::IString> myReceiverIds [protected]
awLinear::Range3d myCastersBox [protected]
awLinear::Range3d myReceiversBox [protected]

ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster
ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster ShadowCaster