123456789101112131415161718192021222324252627282930313233343536373839404142 |
- export default /* glsl */`
- uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- float mean = 0.0;
- float squared_mean = 0.0;
-
- // This seems totally useless but it's a crazy work around for a Adreno compiler bug
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
- for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
- #ifdef HORIZONAL_PASS
- vec2 distribution = decodeHalfRGBA ( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean * HALF_SAMPLE_RATE;
- squared_mean = squared_mean * HALF_SAMPLE_RATE;
- float std_dev = pow( squared_mean - mean * mean, 0.5 );
- gl_FragColor = encodeHalfRGBA( vec2( mean, std_dev ) );
- }
- `;
|