SoShadowGroup Class Reference

VSG extension Shadow casting group node More...

#include <Inventor/nodes/SoShadowGroup.h>

Inheritance diagram for SoShadowGroup:
SoGroup SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.


struct  Members

Public Types

enum  VisibilityFlag {
enum  ShadowingMethod {

Public Member Functions

virtual SoType getTypeId () const
 SoShadowGroup ()
 SoShadowGroup (int nChildren)

Static Public Member Functions

static SoType getClassTypeId ()
static SbBool isSupported (SoShadowGroup::ShadowingMethod method=SoShadowGroup::SHADOW_MAP)

Public Attributes

SoSFBool isActive
SoSFFloat intensity
SoSFFloat precision
SoSFFloat quality
SoSFBool shadowCachingEnabled
SoSFFloat visibilityRadius
SoSFEnum visibilityFlag
SoSFInt32 smoothFactor
SoSFFloat minVariance
SoSFFloat lightBleedingReduction
SoSFEnum method


SoDEPRECATED SoSFBool isShapesBefore

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 two shadowing methods which can be selected with the method field:

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:

In the fragment shader:

The following uniform is available in vertex and fragment shaders:

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

 // The vertex shader:
 void OivSetupShadowVertex();
 void main()
   //Needed for shadowing

 // 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_FragData[0].xyz = * OivComputeShadow();
     gl_FragData[0].w = fragColor.w;
   else {
     // Output the shadowmap during the shadow map pass

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

Texture units:
In SHADOW_MAP mode this node reserves texture units FXVIZ_SHADOW_TEXTURE_UNIT0 and FXVIZ_SHADOW_TEXTURE_UNIT1 for its rendering (see SoPreferences to set these). If these values are not set, texture units 1 and 2 are used. These values cannot be greater than 3.

In VARIANCE_SHADOW_MAP mode, this node reserves texture unit FXVIZ_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+SoShaderProgramgetNumReservedTextures()-1 inclusive are reserved for internal OpenInventor use. If OIV_FIRST_RESERVED_TEXTURE_UNIT is not set, its default value is SoFragmentShader::getMaxTextureImageUnit()-SoShaderProgramgetNumReservedTextures(). 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:
NOTE: In SHADOW_MAP mode, at least the Multi-Texture and Texture Environment Combine OpenGL extensions must be supported by your graphics board. Otherwise no shadows will be computed. These extensions are now standard in OpenGL 1.3 and later.
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.


Potential problems:
In SHADOW_MAP mode, performance issues and incorrect images have been observed with some OpenGL drivers due to the Texture Border Clamp OpenGL extension (standard in OpenGL 1.3), Try setting the OIV_TEXTURE_BORDER_CLAMP_ENABLE environment variable to 0 in this case.
With some graphics boards, especially older hardware like GeForce2, it may be necessary to also set the OIV_FORCE_DUAL_TEX_SHADOW environment variable to 1.




See related examples:

ShadowGroup, shadowShader, MedicalSimpleShadows, MedicalBonesMuscles, BonesMuscles, SimpleInteractiveParameters, SimpleShadows

Member Enumeration Documentation

Shadowing techniques.


Standard shadow mapping.


Deprecated since Open Inventor 9620

Shadows with soft edges.

visibilityRadius interpretation


visibilityRadius is interpreted as an absolute value.


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.

Constructor & Destructor Documentation

SoShadowGroup::SoShadowGroup (  ) 

Default constructor.

SoShadowGroup::SoShadowGroup ( int  nChildren  ) 

Constructor that takes approximate number of children.

Member Function Documentation

static SoType SoShadowGroup::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoGroup.

virtual SoType SoShadowGroup::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoGroup.

static SbBool SoShadowGroup::isSupported ( SoShadowGroup::ShadowingMethod  method = SoShadowGroup::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

Specifies the intensity of the shadow.

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

Activates/deactivates the shadowing.

If deactivated, this SoShadowGroup behaves like an SoGroup.

Indicates that there are shapes before this group.

Setting this value to TRUE may slow down the rendering because it causes a depth buffer save at each frame. Used only for SHADOW_MAP method.


Deprecated since Open Inventor 9620
Only used for SHADOW_MAP method, which is deprecated. Please use VARIANCE_SHADOW_MAP instead.


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

Specifies the shadowing technique to use.

Use enum ShadowingMethod. Default is SHADOW_MAP.

NOTE: field available since Open Inventor 8.1


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

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.

Specifies the quality of the shadow.

0 = lower quality, 1 = best quality.

For VARIANCE_SHADOW_MAP quality may be greater than 1 (texture used for shadowmap rendering will be of size 2*quality*ViewportSize)

Increasing the quality will reduce performance and increase memory consumption.

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.

Set the smoothness of shadows.

Higher values give smoother shadows. Default is 1. Used only for VARIANCE_SHADOW_MAP method.

NOTE: field available since Open Inventor 8.1

Specifies how visibilityRadius is interpreted.

Use enum VisibilityFlag. Default is LONGEST_BBOX_EDGE_FACTOR.

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.

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

Open Inventor Toolkit reference manual, generated on 1 Nov 2022
Copyright © Thermo Fisher Scientific All rights reserved.