"Warning"
VARIANCE_SHADOW_MAP:
This method supports soft shadows (see image below). The smoothness field can be used to increase or decrease the softness. Unlike the SHADOW_MAP method, aliasing is not a problem, but on large scenes, shadows will progressively fade away. Increasing the quality value will reduce this problem. Only one directional light, the last one traversed before the SoShadowGroup, is used to compute shadows with this method, other lights are ignored. In this mode VolumeViz nodes can cast and receive shadows.
Lights that are children of SoShadowGroup are ignored and can give unexpected or incorrect results.
The shadow casting feature is not yet compatible with the bump mapping feature. Trying to combine these two features will give you an incorrect visual result.
To simply apply shadows to your entire scene, replace the SoGroup containing your 3D scene (but not your camera and your light(s)) with an SoShadowGroup :
"Tip" Cylinder can cast a shadow and can be shadowed (**CASTS_SHADOW_AND_SHADOWED**), the sphere only casts a shadow (**CASTS_SHADOW**), and the cube can only be shadowed (**SHADOWED**).
Only the VARIANCE_SHADOW_MAP method is available with custom shaders. In order to use shadows with user defined shaders, a set of functions are available for GLSL shaders under a SoShadowGroup :
The vertex shader:
C++ :
The fragment shader:
See OIVHOME/src/Inventor/examples/Features/Shaders/shadowShader for a complete example.
Depending on your hardware capabilities, shadow casting may not be available. Shadows should be supported on any graphics board that support OpenGL 1.4 or higher, but can also work with previous OpenGL versions if specific OpenGL extensions are available. The static method SoShadowGroup::isSupported will indicate if shadow casting is supported by your graphics board.
On some older graphics boards, e.g., GeForce2, you will need to set the
environment variable OIV_FORCE_DUAL_TEX_SHADOW to 1.
On some older graphics boards, e.g., Rage 128, you will need to set SoShadowGroup::quality <= 0.25.