1 #ifndef R2_SHADOW_VARIANCE_H 2 #define R2_SHADOW_VARIANCE_H 43 float p = float (depth <= moments.x);
44 float variance = max (s.
variance_minimum, moments.y - (moments.x * moments.x));
45 float delta = depth - moments.x;
46 float p_max = variance / (variance + (delta * delta));
47 return max (p, p_max);
67 float msm = max - min;
68 return clamp (vsm / msm, 0.0, 1.0);
99 float pos_light_depth =
119 #endif // R2_SHADOW_VARIANCE_H vec4 surface_light_eye
The surface position in light-eye-space.
float R2_logDepthEncodePartial(const float z, const float depth_coefficient)
Vectors used when calculating projective lighting.
sampler2D map
The variance shadow map.
float variance_minimum
The minimum variance level. Used to eliminate shadow bias. Typically 0.00002f will suffice for all sc...
vec2 surface_light_uv
The surface position as UV coordinates from the perspective of the light.
float R2_varianceShadowFactor(const R2_shadow_variance_t s, const R2_light_projective_vectors_t v)
float R2_varianceLinearStep(const float min, const float max, const float x)
float R2_varianceLightBleedReduction(const R2_shadow_variance_t s, const float p_max)
float bleed_reduction
The amount of bleed reduction (typically [0.2, 1.0]). Setting this value too high results in loss of ...
float R2_logDepthPrepareEyeZ(const float z)
Logarithmic depth functions.
float depth_coefficient
The logarithmic depth coefficient that was used to encode depth values.
float factor_minimum
The minimum level of attenuation by the shadow (0.0 means "completely attenuated", 1.0 means "no attenuation")
float R2_varianceChebyshevUpperBound(const R2_shadow_variance_t s, const vec2 moments, const float depth)