export declare const speckleTemporalSupersamplingFrag = "\n    uniform float height;\n    uniform float width;\n    uniform sampler2D tDiffuse;\n    uniform sampler2D tLastFrame;\n    varying vec2 Uv;\n\n    #define LuminanceEncodeApprox vec3(0.2126, 0.7152, 0.0722)\n    float getLuminance(vec3 color) {\n        return clamp(dot(color, LuminanceEncodeApprox), 0., 1.);\n    }\n    \n    void main() {\n        vec4 texel = texture2D(tDiffuse, Uv);\n        vec2 oldPixelUv = Uv;\n        vec4 oldTexel = texture2D(tLastFrame, oldPixelUv);\n\n        // Use simple neighbor clamping\n        vec4 maxNeighbor = vec4(0.0, 0.0, 0.0, 1.0);\n        vec4 minNeighbor = vec4(1.0);\n        vec4 average = vec4(0.0);\n        for (int x = -1; x <= 1; x++) {\n            for (int y = -1; y <= 1; y++) {\n                vec2 neighborUv = Uv + vec2(float(x) / width, float(y) / height);\n                vec4 neighborTexel = texture2D(tDiffuse, neighborUv);\n                maxNeighbor = max(maxNeighbor, neighborTexel);\n                minNeighbor = min(minNeighbor, neighborTexel);\n                average += neighborTexel / 9.0;\n            }\n        }\n        float lum0 = getLuminance(texel.rgb);\n        float lum1 = getLuminance(oldTexel.rgb);\n\n        float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));\n        float unbiased_weight = 1.0 - unbiased_diff;\n        float unbiased_weight_sqr = unbiased_weight * unbiased_weight;\n        float k_feedback = mix(0.8800, 0.9700, unbiased_weight_sqr);\n        \n        // UE Method to get rid of flickering. Weight frame mixing amount\n        // based on local contrast.\n        float contrast = distance(average, texel);\n        float weight = 0.05 * contrast;\n\n        float blendFactor = mix(1. - weight, k_feedback, 1.);\n        vec4 compositeColor = mix(texel, oldTexel, blendFactor);\n    \n        gl_FragColor = compositeColor;\n    }";
