/** * Denoise - * Smooths over grainy noise in dark images using an 9x9 box filter * weighted by color intensity, similar to a bilateral filter. */ export type DenoiseProps = { /** * The exponent of the color intensity difference, should be greater * than zero. A value of zero just gives an 9x9 box blur and high values * give the original image, but ideal values are usually around 10-20. */ strength?: number; }; export type DenoiseUniforms = DenoiseProps; /** * Denoise - * Smooths over grainy noise in dark images using an 9x9 box filter * weighted by color intensity, similar to a bilateral filter. */ export declare const denoise: { readonly props: DenoiseProps; readonly uniforms: DenoiseUniforms; readonly name: "denoise"; readonly uniformTypes: { readonly strength: "f32"; }; readonly propTypes: { readonly strength: { readonly format: "f32"; readonly value: 0.5; readonly min: 0; readonly max: 1; }; }; readonly source: "struct denoiseUniforms {\n strength: f32,\n};\n\n@group(0) @binding(auto) var denoise: denoiseUniforms;\n\nfn denoise_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);\n let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);\n var color = vec4f(0.0);\n var total = 0.0;\n\n for (var x = -4.0; x <= 4.0; x += 1.0) {\n for (var y = -4.0; y <= 4.0; y += 1.0) {\n let offsetColor = textureSample(\n sourceTexture,\n sourceTextureSampler,\n texCoord + vec2f(x, y) / texSize\n );\n let weight = pow(\n 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),\n adjustedExponent\n );\n color += offsetColor * weight;\n total += weight;\n }\n }\n\n return color / total;\n}\n"; readonly fs: "layout(std140) uniform denoiseUniforms {\n float strength;\n} denoise;\n\nvec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n float adjustedExponent = 3. + 200. * pow(1. - denoise.strength, 4.);\n\n vec4 center = texture(source, texCoord);\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (float x = -4.0; x <= 4.0; x += 1.0) {\n for (float y = -4.0; y <= 4.0; y += 1.0) {\n vec4 offsetColor = texture(source, texCoord + vec2(x, y) / texSize);\n float weight = 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3(0.25)));\n weight = pow(weight, adjustedExponent);\n color += offsetColor * weight;\n total += weight;\n }\n }\n\n return color / total;\n}\n"; readonly passes: [{ readonly sampler: true; }, { readonly sampler: true; }]; }; //# sourceMappingURL=denoise.d.ts.map