diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index ceea4d1d32..66d2937deb 100644 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -11,6 +11,9 @@ <@if not SHADOW_SLH@> <@def SHADOW_SLH@> +#define SHADOW_NOISE_ENABLED 0 +#define SHADOW_SCREEN_SPACE_DITHER 1 + // the shadow texture uniform sampler2DShadow shadowMap; @@ -65,17 +68,20 @@ float evalShadowNoise(vec4 seed) { float evalShadowAttenuationPCF(vec4 position, vec4 shadowTexcoord) { float shadowScale = getShadowScale(); -#if 0 +#if SHADOW_SCREEN_SPACE_DITHER // Pattern dithering in screen space ivec2 coords = ivec2(gl_FragCoord.xy); #else // Pattern dithering in world space (mm resolution) ivec2 coords = ivec2(position.x, position.y+position.z); #endif + +#if SHADOW_NOISE_ENABLED // Add some noise to break dithering int index = int(4.0*evalShadowNoise(gl_FragCoord.xyyx))%4; coords.x += index & 1; coords.y += (index & 2) >> 1; +#endif // Offset for efficient PCF, see http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html ivec2 offset = coords & ivec2(1,1);