H3D API  2.4.1
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
H3D::ShadowCaster Class Reference

The ShadowCaster node uses shadow volumes using stencil buffer to cast shadows from objects in a scene. More...

#include <H3D/ShadowCaster.h>

Inheritance diagram for H3D::ShadowCaster:
Inheritance graph

Public Member Functions

 ShadowCaster (Inst< SFNode > _metadata=0, Inst< MFShadowObjectNode > _object=0, Inst< MFLightNode > _light=0, Inst< SFFloat > _shadowDarkness=0, Inst< SFFloat > _shadowDepthOffset=0, Inst< DisplayList > _displayList=0, Inst< SFString > _algorithm=0, Inst< SFShaderNode > _shadowShader=0, Inst< SFBool > _multiThreading=0)
 Constructor.
 
virtual void render ()
 OpenGL render function.
 
virtual void traverseSG (TraverseInfo &ti)
 traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More...
 
- Public Member Functions inherited from H3D::X3DChildNode
 X3DChildNode (Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
- Public Member Functions inherited from H3D::H3DDisplayListObject
 H3DDisplayListObject (Inst< DisplayList > _displayList=0)
 Constructor.
 

Public Attributes

H3DUniquePtr< MFShadowObjectNodeobject
 The objects that should cast shadows. More...
 
H3DUniquePtr< MFLightNodelight
 The lights that shines on the objects. More...
 
H3DUniquePtr< SFFloatshadowDarkness
 The shadowDarkness field controls the darkness of the shadow. More...
 
H3DUniquePtr< SFFloatshadowDepthOffset
 The shadowDepthOffset field controls the z offset of drawn shadow volumes. More...
 
H3DUniquePtr< SFStringalgorithm
 The algorithm field defines what shadow volume algorithm to use. More...
 
H3DUniquePtr< SFShaderNodeshadowShader
 The shadowShader field can contain a shader to perform effects on the shadow volume texture(stencil buffer) before it is applied to the scene. More...
 
H3DUniquePtr< SFBoolmultiThreading
 Field that decides to use a separate thread for collecting shadow volume information NOTE: applies only if shadows are done on CPU Access type: inputOutput
Default value: false
. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 
- Public Attributes inherited from H3D::H3DDisplayListObject
H3DUniquePtr< DisplayListdisplayList
 The DisplayList instance handling the OpenGL caching of this object.
 

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatablase object for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Additional Inherited Members

- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 

Detailed Description

The ShadowCaster node uses shadow volumes using stencil buffer to cast shadows from objects in a scene.

NOTE! Do not use this node unless you really need to. If you just want to use shadows please use the shadow field in the Appearance node for a much easier way of adding shadows.

The object field specifies objects that should cast shadows.

The light field specifies the lights from which the objects should cast shadows.

The shadowDarkness field specifies how dark the shadow should be with 1 being totally black.

The algorithm field defines what shadow volume algorithm to use. Possible values are "ZPASS" and "ZFAIL". Both have their pros and cons:

The shadowShader field can contain a shader to perform effects on the shadow volume texture(stencil buffer) before it is applied to the scene. Can be used e.g. with a GaussianFilterShader to make softer edges. Any shader put into the shadowShader field needs to have the field "texture" in it which will be used as input to the shadow volume texture.

The ShadowCaster node is affected by the transform hierarchy that it is in and all objects and lighs are specified in local coordinates.

Examples:

Internal routes:

Member Function Documentation

◆ traverseSG()

void ShadowCaster::traverseSG ( TraverseInfo ti)
virtual

traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph.

During this traversal things can be updated in the node and HapticObject instances to be rendered should be added to the TraverseInfo object.

Parameters
tiThe TraverseInfo object containing information about the traversal.

Reimplemented from H3D::Node.

References H3D::TraverseInfo::addPostTraverseCallback().

Member Data Documentation

◆ algorithm

H3DUniquePtr< SFString > H3D::ShadowCaster::algorithm

The algorithm field defines what shadow volume algorithm to use.

Possible values are "ZPASS" and "ZFAIL". Both have their pros and cons:

  • ZPASS is faster, but is not robust in all cases and fails if the viewer is in shadow.
  • ZFAIL is slower, but more robust. To make it work properly the far clip plane has to be set to infinity(done by setting visibilityLimit to -1 in NavigationInfo). This will decrease the precision of the depth buffer, with all the problems that comes with that.

Access type: inputOutput
Default value: "ZPASS"
Valid values: "ZPASS" and "ZFAIL"

Referenced by H3D::H3DWindowNode::render(), and ShadowCaster().

◆ light

H3DUniquePtr< MFLightNode > H3D::ShadowCaster::light

The lights that shines on the objects.

Only PointLight and DirectionalLight is supporeted at this time.

Access type: inputOutput

Referenced by render(), H3D::H3DWindowNode::render(), H3D::DirectionalLight::traverseSG(), and H3D::PointLight::traverseSG().

◆ multiThreading

H3DUniquePtr< SFBool > H3D::ShadowCaster::multiThreading

Field that decides to use a separate thread for collecting shadow volume information NOTE: applies only if shadows are done on CPU Access type: inputOutput
Default value: false
.

Referenced by ShadowCaster().

◆ object

H3DUniquePtr< MFShadowObjectNode > H3D::ShadowCaster::object

The objects that should cast shadows.

Access type: inputOutput

Referenced by H3D::FrameBufferTextureGenerator::render(), render(), H3D::H3DWindowNode::render(), and H3D::X3DShapeNode::traverseSG().

◆ shadowDarkness

H3DUniquePtr< SFFloat > H3D::ShadowCaster::shadowDarkness

The shadowDarkness field controls the darkness of the shadow.

A value of 1 will draw a completely black shadow, while a value of 0 will cast no shadow at all.

Access type: inputOutput
Default value: 0.4

Referenced by H3D::FrameBufferTextureGenerator::render(), and ShadowCaster().

◆ shadowDepthOffset

H3DUniquePtr< SFFloat > H3D::ShadowCaster::shadowDepthOffset

The shadowDepthOffset field controls the z offset of drawn shadow volumes.

The z offset will be r * defaultShadowDepthOffset where r is the smallest value that is guaranteed to produce a resolvable z offset for a given implementation. If this value is set to too small there will be z-fighting between shadow and object that casts the shadow(flickering). If this happens increase this value. The value needed depends on the precision of the depth buffer.

Default value: 6
Access type: inputOutput

Referenced by H3D::FrameBufferTextureGenerator::render(), and ShadowCaster().

◆ shadowShader

H3DUniquePtr< SFShaderNode > H3D::ShadowCaster::shadowShader

The shadowShader field can contain a shader to perform effects on the shadow volume texture(stencil buffer) before it is applied to the scene.

Can be used e.g. with a GaussianFilterShader to make softer edges. Any shader put into the shadowShader field needs to have the field "texture" in it which will be used as input to the shadow volume texture.

Access type: inputOutput
Default value: NULL


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