public class SoShadowGroup extends SoGroup
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:
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:
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() { ..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_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:
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:
SoLightModel
node sets the lighting model to BASE_COLOR.
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:
Modifier and Type | Class and Description |
---|---|
static class |
SoShadowGroup.ShadowingMethods
Shadowing techniques.
|
static class |
SoShadowGroup.VisibilityFlags
visibilityRadius interpretation |
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
ABSOLUTE_RADIUS
Deprecated.
Use
SoShadowGroup.VisibilityFlags.ABSOLUTE_RADIUS instead. |
SoSFFloat |
intensity
Specifies the intensity of the shadow.
|
SoSFBool |
isActive
Activates/deactivates the shadowing.
|
SoSFBool |
isShapesBefore
Deprecated.
As of Open Inventor 9620 See documentation for more details
|
static int |
LAST_METHOD
Deprecated.
Use
SoShadowGroup.ShadowingMethods.LAST_METHOD instead. |
SoSFFloat |
lightBleedingReduction
Used only for VARIANCE_SHADOW_MAP.
|
static int |
LONGEST_BBOX_EDGE_FACTOR
Deprecated.
|
SoSFEnum<SoShadowGroup.ShadowingMethods> |
method
Specifies the shadowing technique to use.
|
SoSFFloat |
minVariance
Used only for VARIANCE_SHADOW_MAP.
|
SoSFFloat |
precision
Specifies the precision of the shadow.
|
SoSFFloat |
quality
Specifies the quality of the shadow.
|
static int |
SHADOW_MAP
Deprecated.
Use
SoShadowGroup.ShadowingMethods.SHADOW_MAP instead. |
SoSFBool |
shadowCachingEnabled
Indicates if a cache should be used for computing the shadows.
|
SoSFInt32 |
smoothFactor
Set the smoothness of shadows.
|
static int |
VARIANCE_SHADOW_MAP
Deprecated.
Use
SoShadowGroup.ShadowingMethods.VARIANCE_SHADOW_MAP instead. |
SoSFEnum<SoShadowGroup.VisibilityFlags> |
visibilityFlag
Specifies how
visibilityRadius is interpreted. |
SoSFFloat |
visibilityRadius
Shadows are only computed within "visibility radius" distance from the camera position.
|
boundingBoxIgnoring
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoShadowGroup()
Default constructor.
|
SoShadowGroup(int nChildren)
Constructor that takes approximate number of children.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isSupported()
Calls isSupported(SoShadowGroup.ShadowingMethods.valueOf( SoShadowGroup.ShadowingMethods.SHADOW_MAP.getValue() )).
|
static boolean |
isSupported(SoShadowGroup.ShadowingMethods method)
Indicates if shadow casting is supported by your graphic board.
|
addChild, findChild, getChild, getNumChildren, insertChild, removeAllChildren, removeChild, removeChild, replaceChild, replaceChild
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int ABSOLUTE_RADIUS
SoShadowGroup.VisibilityFlags.ABSOLUTE_RADIUS
instead.@Deprecated public static final int LONGEST_BBOX_EDGE_FACTOR
SoShadowGroup.VisibilityFlags.LONGEST_BBOX_EDGE_FACTOR
instead.@Deprecated public static final int SHADOW_MAP
SoShadowGroup.ShadowingMethods.SHADOW_MAP
instead.@Deprecated public static final int VARIANCE_SHADOW_MAP
SoShadowGroup.ShadowingMethods.VARIANCE_SHADOW_MAP
instead.@Deprecated public static final int LAST_METHOD
SoShadowGroup.ShadowingMethods.LAST_METHOD
instead.public final SoSFBool isActive
SoShadowGroup
behaves like an SoGroup
.@Deprecated public final SoSFBool isShapesBefore
public final SoSFFloat intensity
public final SoSFFloat precision
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.
public final SoSFFloat 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.
public final SoSFBool shadowCachingEnabled
public final SoSFFloat visibilityRadius
visibilityRadius
if visibilityFlag
equals LONGEST_BBOX_EDGE_FACTOR
.
visibilityRadius
if visibilityFlag
equals ABSOLUTE_RADIUS
.
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.
public final SoSFEnum<SoShadowGroup.VisibilityFlags> visibilityFlag
visibilityRadius
is interpreted.
Use enum VisibilityFlag
. Default is LONGEST_BBOX_EDGE_FACTOR.public final SoSFInt32 smoothFactor
public final SoSFFloat minVariance
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].
public final SoSFFloat lightBleedingReduction
public final SoSFEnum<SoShadowGroup.ShadowingMethods> method
public SoShadowGroup(int nChildren)
public SoShadowGroup()
public static boolean isSupported()
public static boolean isSupported(SoShadowGroup.ShadowingMethods method)
SoGLExtension
for an example of using SoGLContext
to avoid them.Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com