Shaders for Shadows
Shader code for rendering shadows of translucent occluders, soft shadows and single scattering with moment shadow maps.
 All Classes Files Functions Variables Pages
Functions
ShadowUtility.fx File Reference

Go to the source code of this file.

Functions

void ComputePCFShadowIntensity (out float OutShadowIntensity, Texture2D ShadowMap, SamplerState ShadowMapSampler, float2 ShadowMapTexCoord, float FragmentDepth, float4 ShadowMapSize, const float StandardDeviation, const int KernelRadius, float DepthBias)
 
void ComputePCFShadowIntensityBilinear (out float OutShadowIntensity, Texture2D< float > ShadowMap, SamplerComparisonState ShadowMapSampler, float2 ShadowMapTexCoord, float FragmentDepth, float4 ShadowMapSize, const float StandardDeviation, const int KernelRadius, float DepthBias)
 
float2 GetRoots (float3 Coefficients)
 
float GetHankelDeterminant (float4 Moments)
 
float GetFourthMomentOffset (float4 Moments)
 

Detailed Description

This header defines utility functions for Shadow.fx.

Definition in file ShadowUtility.fx.

Function Documentation

void ComputePCFShadowIntensity ( out float  OutShadowIntensity,
Texture2D  ShadowMap,
SamplerState  ShadowMapSampler,
float2  ShadowMapTexCoord,
float  FragmentDepth,
float4  ShadowMapSize,
const float  StandardDeviation,
const int  KernelRadius,
float  DepthBias 
)

Given a sampler for the shadow map, the texture coordinate for the center of the kernel and a computed shadow map depth for a point at the same location this function outputs 1.0, if the fragment is in shadow, 0.0f, if the fragment is lit and an intermediate value for partial shadow. It also requires the shadow map size in pixels and its reciproque. It implements PCF with bilinear filtering using a Gaussian kernel with the given standard deviation, which is cut off at the specified radius (both in texels).

Definition at line 11 of file ShadowUtility.fx.

void ComputePCFShadowIntensityBilinear ( out float  OutShadowIntensity,
Texture2D< float >  ShadowMap,
SamplerComparisonState  ShadowMapSampler,
float2  ShadowMapTexCoord,
float  FragmentDepth,
float4  ShadowMapSize,
const float  StandardDeviation,
const int  KernelRadius,
float  DepthBias 
)

Variant of ComputePCFShadowIntensity() which makes use of SampleCmp() to improve the performance.

Definition at line 48 of file ShadowUtility.fx.

float GetFourthMomentOffset ( float4  Moments)

Computes the determinant of the Hankel matrix induced by the given four moments divided by the variance. This coincides with the amount by which the fourth moment is greater than the minimal possible value.

Definition at line 124 of file ShadowUtility.fx.

float GetHankelDeterminant ( float4  Moments)

Computes the determinant of the Hankel matrix induced by the given four moments robustly by using a Cholesky decomposition.

Definition at line 113 of file ShadowUtility.fx.

float2 GetRoots ( float3  Coefficients)

Solves the polynomial Coefficients[0]+Coefficients[1]*x+Coefficients[2]*x^2 for x and returns a vector consisting of the two solutions. The returned solutions are sorted. Behavior is undefined if the polynomial has no roots. A root with multiplicity is returned twice.

Definition at line 101 of file ShadowUtility.fx.