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: 2024.2.2.0 (10.16.2.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 methodGetRenderEngineMode

Returns the supported Render engine mode.

(Inherited from SoNode.)
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.VARIANCE_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

Specifies the intensity of the shadow.

Public propertyisActive

Activates/deactivates the shadowing.

Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertylightBleedingReduction

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

Public propertymethod

Specifies the shadowing technique to use.

Public propertyminVariance

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

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
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 OIV.Inventor.Nodes.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 OIV.Inventor.Nodes.SoShadowStyle).

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

  • VARIANCE_SHADOW_MAP : This mode allows to display soft shadows. The OIV.Inventor.Nodes.SoShadowGroup.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 OIV.Inventor.Nodes.SoShadowGroup.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 (OIV.Inventor.Nodes.SoShaderProgram or OIV.VolumeViz.Nodes.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:

    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_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 OIV.Inventor.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 OIV.Inventor.SoPreferences). The texture units between OIV_FIRST_RESERVED_TEXTURE_UNIT and OIV_FIRST_RESERVED_TEXTURE_UNIT + OIV.Inventor.Nodes.SoShaderProgram.GetNumReservedTextures() -1 inclusive are reserved for internal OpenInventor use. If OIV_FIRST_RESERVED_TEXTURE_UNIT is not set, its default value is OIV.Inventor.Nodes.SoFragmentShader.GetMaxTextureImageUnit()-SoShaderProgram.getNumReservedTextures(). Note: The value returned by OIV.Inventor.Nodes.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 OIV.Inventor.Nodes.SoShadowGroup.IsSupported(OIV.Inventor.Nodes.SoShadowGroup.ShadowingMethods) static method to determine if the current graphics board supports shadowing.

    Limitations

    • OIV.Inventor.Nodes.SoShadowGroup cannot be nested by design.

    Notes:

    • Geometry cannot receive shadows if lighting is disabled. For example if an OIV.Inventor.Nodes.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