Click or drag to resize
SoShadowGroup Class

Shadow casting group node.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 9.9.36.0 (9.9.36.0)
Syntax
public class SoShadowGroup : SoGroup

The SoShadowGroup type exposes the following members.

Constructors
  NameDescription
Public methodSoShadowGroup

Default constructor.

Public methodSoShadowGroup(Int32)

Constructor that takes approximate number of children.

Top
Methods
  NameDescription
Public methodAddChild

Adds a child as last one in group.

(Inherited from SoGroup.)
Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoNode.)
Public methodCallback
(Inherited from SoGroup.)
Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
(Inherited from SoGroup.)
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodFindChild

Finds index of given child within group.

(Inherited from SoGroup.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type).

(Inherited from SoNode.)
Public methodGetBoundingBox
(Inherited from SoGroup.)
Public methodGetChild

Returns pointer the child node with the given index.

(Inherited from SoGroup.)
Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMatrix
(Inherited from SoGroup.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetNumChildren

Returns number of children.

(Inherited from SoGroup.)
Public methodGetPrimitiveCount
(Inherited from SoGroup.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender

Called during GLRender action.

(Overrides SoGroupGLRender(SoGLRenderAction).)
Public methodGLRenderBelowPath
(Inherited from SoNode.)
Public methodGLRenderInPath
(Inherited from SoNode.)
Public methodGLRenderOffPath
(Inherited from SoNode.)
Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
(Inherited from SoGroup.)
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodInsertChild

Adds a child so that it becomes the one with the given index.

(Inherited from SoGroup.)
Public methodIsBoundingBoxIgnoring

Used by BoundingBoxAction to known if bounding box computation should be ignored or not.

(Inherited from SoGroup.)
Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override flag.

(Inherited from SoNode.)
Public methodStatic memberIsSupported
Calls IsSupported(OIV.Inventor.Nodes.SoShadowGroup.ShadowingMethods( .SoShadowGroup.SHADOW_MAP )).
Public methodStatic memberIsSupported(SoShadowGroupShadowingMethods)

Indicates if shadow casting is supported by your graphic board.

Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoGroup.)
Public methodRayPick
(Inherited from SoNode.)
Public methodRemoveAllChildren

Removes all children from group.

(Inherited from SoGroup.)
Public methodRemoveChild(Int32)

Removes child with given index from group.

(Inherited from SoGroup.)
Public methodRemoveChild(SoNode)

Removes first instance of given child from group.

(Inherited from SoGroup.)
Public methodReplaceChild(Int32, SoNode)

Replaces child with given index with new child.

(Inherited from SoGroup.)
Public methodReplaceChild(SoNode, SoNode)

Replaces first instance of given child with new child.

(Inherited from SoGroup.)
Public methodSearch
(Inherited from SoGroup.)
Public methodSet

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.

(Inherited from SoFieldContainer.)
Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Turns the override flag on or off.

(Inherited from SoNode.)
Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoGroup.)
Top
Properties
  NameDescription
Public propertyboundingBoxIgnoring

Whether to ignore this node during bounding box traversal.

(Inherited from SoGroup.)
Public propertyintensity
Public propertyisActive

Activates/deactivates the shadowing.

Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertyisShapesBefore Obsolete.

Indicates that there are shapes before this group.

Public propertylightBleedingReduction

Used only for VARIANCE_SHADOW_MAP.

Public propertymethod

Specifies the shadowing technique to use.

Public propertyminVariance

Used only for VARIANCE_SHADOW_MAP.

Public propertyprecision

Specifies the precision of the shadow.

Public propertyquality

Specifies the quality of the shadow.

Public propertyshadowCachingEnabled

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

Public propertysmoothFactor

Set the smoothness of shadows.

Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Public propertyvisibilityFlag

Specifies how visibilityRadius is interpreted.

Public propertyvisibilityRadius

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

Top
Remarks

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:

  • SHADOW_MAP: In this mode, shadows are not filtered and will display aliasing. Futhermore, it is not compatbile with VolumeViz nodes. All directional lights and spotlights (but not point lights) above this group node are used for computing the shadows. Adding lights as children of this group node will give incorrect results (lights must be defined above this node). Even when using the best quality setting (see quality), some aliasing artifacts will appear if you zoom in very close to the scene. Another way to increase the shadowing quality (decrease the aliasing effects), is to specify a spherical region centered at the camera position within which the shadowing will be computed (see visibilityRadius). The smaller the radius of this sphere, the better the shadow quality. This parameter is particularly useful for walk-through scenes.

VARIANCE_SHADOW_MAP : This mode allows to display soft shadows. The smoothFactor field can be used to increase or decrease the softness. Contrary to the SHADOW_MAP method, aliasing won't be displayed but on large scene, 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_FragData[0]. 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:

void OivSetupShadowVertex();
void main()
{
 ..userCode..
 //Needed for shadowing
 OivSetupShadowVertex();
}

uniform bool OivShadowPass;

void OivGenerateShadowMap();
float OivComputeShadow();
void main()
{
 if ( !OivShadowPass ) {
   ..compute fragment color here..
   // Define the final color
   gl_FragData[0].xyz = fragColor.xyz * OivComputeShadow();
   gl_FragData[0].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:

  • ADD, BLEND: 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).

  • ALL SORTED, ALL DELAYED, and SCREEN_DOOR: Same as previous case for VARIANCE_SHADOW_MAP. For SHADOW_MAP method transparent objects neither cast a shadow nor are shadowed.

  • SORTED_PIXELS_BLEND: This transparency mode is not compatible with SoShadowGroup. No shadows are computed.

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+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: 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.

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.

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.

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 SHADOW_MAP
lightBleedingReduction 0.01
}

See Also