Variance |
public class VarianceShadowRenderingProvider : ShadowRenderingProviderBase
The VarianceShadowRenderingProvider type exposes the following members.
Name | Description | |
---|---|---|
VarianceShadowRenderingProvider | Constructor |
Name | Description | |
---|---|---|
ChangeBackBufferRenderingStep | Gets a ChangeBackBufferRenderingStep that changes render targets from shadow depth rendering to rendering 3D scene. | |
DepthBlurPostProcessingRenderingStep | Gets a RenderPostProcessingRenderingStep that runs a post process that blurs the shadow depth map. | |
PrepareShadowDepthRenderingStep | Gets a PrepareVarianceShadowMappingRenderingStep that prepares render targets for variance shadow depth rendering. | |
RenderNonShadowObjectsRenderingStep | Gets a RenderObjectsRenderingStep that renders all objects that do not cast shadow. | |
RenderShadowDepthRenderingStep | Gets a RenderObjectsRenderingStep that renders shadow depth map - render objects from the light perspective and writes a distance from the light to a shadow depth map. This rendering step uses VarianceShadowDepthEffect to render objects (it is set to OverrideEffect property), filters object setting FilterObjectsFunction to FilterShadowCastingObjectsFunction(RenderablePrimitiveBase) and filters lights to use only the first shadow light (using FilterLightsFunction property). | |
ShadowDepthBias | Gets or sets a float value that offsets the depth of the lights (distance from the lights to the object) and can help reduce the show artifacts in the corners. The value does not work for all 3D scenes because it depends on the size of the scene. Default value is 0 that does not apply any bias. | |
ShadowDepthBluringSize | Gets or sets an integer that specifies the blur amount that is applied on the shadow depth map and can produce shadows with nice soft edges. Default value is 4. | |
ShadowMapSize | Gets or sets and integer value that represents the size of a shadow depth map texture. Default value is 512 and means that by default a 512 x 512 texture will be used. | |
ShadowRenderingStepsGroup | Gets a RenderingStepsGroup that groups rendering step that render shadow map. | |
ShadowThreshold | Gets or sets a float value that helps prevent light bleeding (having areas that should be in shadow fully illuminated) for variance shadow mapping. Default value is 0.2f. | |
ShadowTreshold | Obsolete. Gets or sets a float value that helps prevent light bleeding (having areas that should be in shadow fully illuminated) for variance shadow mapping. Default value is 0.2f. |
Name | Description | |
---|---|---|
ChangeRenderTargetRenderingStepName | Name for ChangeRenderTargetRenderingStep | |
DepthBlurPostProcessingRenderingStepName | Name for DepthBlurPostProcessingRenderingStep | |
PrepareVarianceShadowMappingRenderingStepsName | Name of the PrepareVarianceShadowMappingRenderingStep that prepares parameters for other rendering steps in shadow depth rendering. | |
RenderNonShadowObjectsRenderingStepName | Name for RenderNonShadowObjectsRenderingStep | |
RenderShadowDepthRenderingStepName | Name for RenderShadowDepthRenderingStep | |
ShadowDepthMapRenderingStepsGroupName | Name of the RenderingStepsGroup that contains rendering steps that render shadow depth map. |
VarianceShadowRenderingProvider provides support for rendering shadows with using Variance shadow rendering technique.
The used algorithm is based on the GPU Gems3 "Chapter 8. Summed-Area Variance Shadow Maps" (https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch08.html)
Currently only one SpotLight or one DirectionalLight shadow casting light are supported.
To enable shadow rendering the InitializeShadowRendering(ShadowRenderingProviderBase) method must be called with an instance of VarianceShadowRenderingProvider. Then the light that casts the shadow needs to be specified with setting the DXAttributeType.IsCastingShadow attribute on the light. The following code shows that:
// Create new VarianceShadowRenderingProvider var varianceShadowRenderingProvider = new VarianceShadowRenderingProvider() { ShadowMapSize = 512, ShadowDepthBluringSize = 4, ShadowThreshold = 0.2f }; // Initialize shadow rendering with DXEngine MainDXViewportView.DXScene.InitializeShadowRendering(varianceShadowRenderingProvider); // Create a SpotLight var shadowSpotLight = new SpotLight() { Position = new Point3D(0, 100, -500), Direction = new Vector3D(0, -1, 5) }; // Mark it for casting shadow (set IsCastingShadow DXEngine attribute to true) shadowSpotLight.SetDXAttribute(DXAttributeType.IsCastingShadow, true);