H3D API
2.4.1
|
The ShadowCaster node uses shadow volumes using stencil buffer to cast shadows from objects in a scene. More...
#include <H3D/ShadowCaster.h>
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... | |
![]() | |
X3DChildNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (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. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
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 Field * | getField (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... | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
Public Attributes | |
H3DUniquePtr< MFShadowObjectNode > | object |
The objects that should cast shadows. More... | |
H3DUniquePtr< MFLightNode > | light |
The lights that shines on the objects. More... | |
H3DUniquePtr< SFFloat > | shadowDarkness |
The shadowDarkness field controls the darkness of the shadow. More... | |
H3DUniquePtr< SFFloat > | shadowDepthOffset |
The shadowDepthOffset field controls the z offset of drawn shadow volumes. More... | |
H3DUniquePtr< SFString > | algorithm |
The algorithm field defines what shadow volume algorithm to use. More... | |
H3DUniquePtr< SFShaderNode > | 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. More... | |
H3DUniquePtr< SFBool > | 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 . More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
The DisplayList instance handling the OpenGL caching of this object. | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatablase object for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
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. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
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:
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.
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.
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:
|
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.
ti | The TraverseInfo object containing information about the traversal. |
Reimplemented from H3D::Node.
References H3D::TraverseInfo::addPostTraverseCallback().
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:
Access type: inputOutput
Default value: "ZPASS"
Valid values: "ZPASS" and "ZFAIL"
Referenced by H3D::H3DWindowNode::render(), and ShadowCaster().
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().
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().
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().
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().
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().
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