Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoShadowGroup Class Reference

VSG extension Shadow casting group node More...

#include <Inventor/nodes/SoShadowGroup.h>

+ Inheritance diagram for SoShadowGroup:

Public Types

enum  VisibilityFlag {
  ABSOLUTE_RADIUS ,
  LONGEST_BBOX_EDGE_FACTOR
}
 visibilityRadius interpretation More...
 
enum  ShadowingMethod { VARIANCE_SHADOW_MAP }
 Shadowing techniques. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoShadowGroup ()
 Default constructor.
 
 SoShadowGroup (int nChildren)
 Constructor that takes approximate number of children.
 
- Public Member Functions inherited from SoGroup
 SoGroup ()
 Creates an empty group node.
 
 SoGroup (int nChildren)
 Constructor that takes approximate number of children.
 
virtual void addChild (SoNode *child)
 Adds a child as last one in group.
 
virtual void insertChild (SoNode *child, int newChildIndex)
 Adds a child so that it becomes the one with the given index.
 
virtual SoNodegetChild (int index) const
 Returns pointer the child node with the given index.
 
virtual int findChild (const SoNode *child) const
 Finds index of given child within group.
 
virtual int getNumChildren () const
 Returns number of children.
 
virtual void removeChild (int index)
 Removes child with given index from group.
 
virtual void removeChild (SoNode *child)
 Removes first instance of given child from group.
 
virtual void removeAllChildren ()
 Removes all children from group.
 
virtual void replaceChild (int index, SoNode *newChild)
 Replaces child with given index with new child.
 
virtual void replaceChild (SoNode *oldChild, SoNode *newChild)
 Replaces first instance of given child with new child.
 
- Public Member Functions inherited from SoNode
virtual void setOverride (const SbBool state)
 Turns the override flag on or off.
 
virtual SbBool isOverride () const
 Returns the state of the override flag.
 
virtual SoNodecopy (SbBool copyConnections=FALSE) const
 Creates and returns an exact copy of the node.
 
virtual SbBool affectsState () const
 Returns TRUE if a node has an effect on the state during traversal.
 
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SbBool isSupported (SoShadowGroup::ShadowingMethod method=SoShadowGroup::VARIANCE_SHADOW_MAP)
 Indicates if shadow casting is supported by your graphic board.
 
- Static Public Member Functions inherited from SoGroup
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (const SbName &name)
 A node's name can be set using SoBase::setName().
 
static int getByName (const SbName &name, SoNodeList &list)
 A node's name can be set using SoBase::setName().
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoSFBool isActive
 Activates/deactivates the shadowing.
 
SoSFFloat intensity
 Specifies the intensity of the shadow.
 
SoSFFloat precision
 Specifies the precision of the shadow.
 
SoSFFloat quality
 Specifies the quality of the shadow.
 
SoSFBool shadowCachingEnabled
 Indicates if a cache should be used for computing the shadows.
 
SoSFFloat visibilityRadius
 Shadows are only computed within "visibility radius" distance from the camera position.
 
SoSFEnum visibilityFlag
 Specifies how visibilityRadius is interpreted.
 
SoSFInt32 smoothFactor
 Set the smoothness of shadows.
 
SoSFFloat minVariance
 Increasing this value will decrease possible self-shadowing artifacts but will make shadows fade away.
 
SoSFFloat lightBleedingReduction
 In some cases, a halo may appear around shadows intersecting each other.
 
SoSFEnum method
 Specifies the shadowing technique to use.
 
- Public Attributes inherited from SoGroup
SoSFBool boundingBoxIgnoring
 Whether to ignore this node during bounding box traversal.
 

Detailed Description

VSG extension Shadow casting group node

This group node performs real-time shadow casting. Because shadows depends on a lot of OpenInventor elements, it is recommended to put children of this group under a SoSeparator in order to have a cache. Each shape within this group will be included in the shadow casting computation. A shape may cast a shadow on other shapes or on itself (self-shadowing), and/or may be shadowed by other shapes within the group. The current shadow style is used to determine if shapes cast a shadow and/or can be shadowed (see SoShadowStyle).

This class defines a single shadowing method. The method field allows for future shadowing methods to be added.

  • VARIANCE_SHADOW_MAP : This mode allows to display soft shadows. The smoothFactor field can be used to increase or decrease the softness. Aliasing won't be displayed, but on large scenes shadows will progressively fade away. Increasing quality will reduce this problem. Only the last on state directional light is used during rendering, other lights are ignored.

    Shaders
    Only the VARIANCE_SHADOW_MAP method is available with shaders (custom or internal). In order to use shadows with user defined GLSL shaders (SoShaderProgram or SoVolumeShader), the following functions must be used in the shader programs.
    In the vertex shader:

    • void OivSetupShadowVertex(): Must be called in the vertex shader.

    In the fragment shader:

    • float OivComputeShadow(): Returns a scalar in [0-1]. 0 means fragment is fully shadowed, 1 means no shadow. Should be used to modify the fragment color.
    • void OivGenerateShadowMap(): Must be called during the shadowmap pass in order to create the shadowmap. During this pass, the shader must not write to gl_FragColor. Use the uniform OivShadowPass to know when the shadowmap is being computed.

    The following uniform is available in vertex and fragment shaders:

    • uniform bool OivShadowPass: Is true if the shadowmap is currently being rendered

    The following code can be used as a skeleton for a GLSL shader that works with shadows:

    // The vertex shader:
    void OivSetupShadowVertex();
    void main()
    {
    ..userCode..
    //Needed for shadowing
    OivSetupShadowVertex();
    }
    // The fragment shader:
    //If true we are in shadowmap generation pass
    uniform bool OivShadowPass;
    void OivGenerateShadowMap();
    float OivComputeShadow();
    void main()
    {
    if ( !OivShadowPass ) {
    ..compute fragment color here..
    // Define the final color
    gl_FragColor.xyz = fragColor.xyz * OivComputeShadow();
    gl_FragColor.w = fragColor.w;
    }
    else {
    // Output the shadowmap during the shadow map pass
    OivGenerateShadowMap();
    }
    }

    Transparency:
    Transparent objects are treated as follows, depending on the transparency type:

    • NO_SORT: Transparent objects cast a shadow and are shadowed but the shadow intensity doesn't depend on the transparency value (the same shadow is displayed for full transparent shapes and opaque shapes).
    • OPAQUE_FIRST, SORTED_OBJECT and SORTED_PIXEL: Same as previous case for VARIANCE_SHADOW_MAP.

    Texture units:
    In VARIANCE_SHADOW_MAP mode, this node reserves texture unit OIV_SHADOW_TEXTURE_UNIT0 for its rendering (see SoPreferences to set these). If this value is not set the application can specify which texture units OpenInventor should automatically use by setting environment variables (see SoPreferences). The texture units between OIV_FIRST_RESERVED_TEXTURE_UNIT and OIV_FIRST_RESERVED_TEXTURE_UNIT + SoShaderProgram::getNumReservedTextures() -1 inclusive are reserved for internal OpenInventor use. If OIV_FIRST_RESERVED_TEXTURE_UNIT is not set, its default value is SoFragmentShader::getMaxTextureImageUnit()-SoShaderProgram::getNumReservedTextures(). Note: The value returned by SoShaderProgram::getNumReservedTextures() may change between OpenInventor versions. The total number of available texture units depends on the graphics hardware.

    Hardware requirements:
    The Shadow and Depth Texture OpenGL extensions (standard in OpenGL 1.4) are used if they are available and generally improve performance.
    In order to increase quality and performance of the shadows, OpenGL PBuffers are used. PBuffers are a limited resource on some systems. Set OIV_PBUFFER_ENABLE to 0 to disallow use of PBuffers.

    A DirectX 10 graphics board is needed to support VARIANCE_SHADOW_MAP.

    Use the isSupported() static method to determine if the current graphics board supports shadowing.

    Limitations

    Notes:

    • Geometry cannot receive shadows if lighting is disabled.
      For example if an SoLightModel node sets the lighting model to BASE_COLOR.
    • Geometry cannot receive shadows if a texture is applied using the DECAL or REPLACE models.

FILE FORMAT/DEFAULT

    ShadowGroup {
    isActive TRUE
    isShapesBefore FALSE
    intensity 0.5
    precision 0.5
    quality 0.5
    shadowCachingEnabled TRUE
    visibilityRadius 1.0
    visibilityFlag LONGEST_BBOX_EDGE_FACTOR
    smoothFactor 1
    minVariance 1e-5
    method VARIANCE_SHADOW_MAP
    lightBleedingReduction 0.01
    }

SEE ALSO

SoShadowStyle

Definition at line 180 of file SoShadowGroup.h.

Member Enumeration Documentation

◆ ShadowingMethod

Shadowing techniques.

Enumerator
VARIANCE_SHADOW_MAP 

Shadows with soft edges.

Definition at line 209 of file SoShadowGroup.h.

◆ VisibilityFlag

visibilityRadius interpretation

Enumerator
ABSOLUTE_RADIUS 

visibilityRadius is interpreted as an absolute value.

LONGEST_BBOX_EDGE_FACTOR 

The longest edge of the scene bounding box will be multiplied by the value of visibilityRadius.

The resulting value will be the radius within which shadows are computed.

Definition at line 189 of file SoShadowGroup.h.

Constructor & Destructor Documentation

◆ SoShadowGroup() [1/2]

SoShadowGroup::SoShadowGroup ( )

Default constructor.

◆ SoShadowGroup() [2/2]

SoShadowGroup::SoShadowGroup ( int  nChildren)

Constructor that takes approximate number of children.

Member Function Documentation

◆ getClassTypeId()

static SoType SoShadowGroup::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoShadowGroup::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoGroup.

◆ isSupported()

static SbBool SoShadowGroup::isSupported ( SoShadowGroup::ShadowingMethod  method = SoShadowGroup::VARIANCE_SHADOW_MAP)
static

Indicates if shadow casting is supported by your graphic board.

When using a debug build of Open Inventor, some "no context available" warning messages may be generated. You can ignore them or see SoGLExtension for an example of using SoGLContext to avoid them.

Member Data Documentation

◆ intensity

SoSFFloat SoShadowGroup::intensity

Specifies the intensity of the shadow.

0 = lowest intensity (the shadow is invisible), 1 = highest intensity (the shadow is solid black).

Definition at line 240 of file SoShadowGroup.h.

◆ isActive

SoSFBool SoShadowGroup::isActive

Activates/deactivates the shadowing.

If deactivated, this SoShadowGroup behaves like an SoGroup.

Definition at line 233 of file SoShadowGroup.h.

◆ lightBleedingReduction

SoSFFloat SoShadowGroup::lightBleedingReduction

In some cases, a halo may appear around shadows intersecting each other.

Increasing this value will decrease this effect. Default value is safe for most scenes. Default is 0.01 and range is [0-1].

NOTE: field available since Open Inventor 8.1

Definition at line 322 of file SoShadowGroup.h.

◆ method

SoSFEnum SoShadowGroup::method

Specifies the shadowing technique to use.

Use enum ShadowingMethod. Default is VARIANCE_SHADOW_MAP.

NOTE: field available since Open Inventor 8.1

Definition at line 330 of file SoShadowGroup.h.

◆ minVariance

SoSFFloat SoShadowGroup::minVariance

Increasing this value will decrease possible self-shadowing artifacts but will make shadows fade away.

The default value is safe for most scenes. Increasing the quality field is also preferable before tweaking this value. A special case is for SoVolumeRender node which has a minimum of 0.001 or IVVR_SHADOW_MIN_VARIANCE if set. Default is 1e-5 and range is [0-1].

NOTE: field available since Open Inventor 8.1

Definition at line 312 of file SoShadowGroup.h.

◆ precision

SoSFFloat SoShadowGroup::precision

Specifies the precision of the shadow.

0 = lowest precision, 1 = highest precision. With lower precisions, some parts of the scene may be unlit where they should be lit, or vice versa. Increasing the precision will reduce performance.

NOTE: If your graphics driver does not support the required OpenGL extensions, you may see low precision results even when this field is set to the highest precision.

Definition at line 253 of file SoShadowGroup.h.

◆ quality

SoSFFloat SoShadowGroup::quality

Specifies the quality of the shadow.

The texture used for shadowmap rendering will be of size 2*quality*ViewportSize. Increasing the quality will reduce performance and increase memory consumption.

Definition at line 261 of file SoShadowGroup.h.

◆ shadowCachingEnabled

SoSFBool SoShadowGroup::shadowCachingEnabled

Indicates if a cache should be used for computing the shadows.

Using a cache will improve rendering performance if the lights of your scene and your scene under this group node do not change.

Definition at line 268 of file SoShadowGroup.h.

◆ smoothFactor

SoSFInt32 SoShadowGroup::smoothFactor

Set the smoothness of shadows.

Higher values give smoother shadows. Default is 1.

NOTE: field available since Open Inventor 8.1

Definition at line 300 of file SoShadowGroup.h.

◆ visibilityFlag

SoSFEnum SoShadowGroup::visibilityFlag

Specifies how visibilityRadius is interpreted.

Use enum VisibilityFlag. Default is LONGEST_BBOX_EDGE_FACTOR.

Definition at line 291 of file SoShadowGroup.h.

◆ visibilityRadius

SoSFFloat SoShadowGroup::visibilityRadius

Shadows are only computed within "visibility radius" distance from the camera position.

This radius equals:

When visibilityRadius = 1 and visibilityFlag = LONGEST_BBOX_EDGE_FACTOR (default values), shadowing is computed throughout the entire scene.

Note: With VARIANCE_SHADOW_MAP method, try to increase the quality field first.

Definition at line 285 of file SoShadowGroup.h.


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