/** * Bloom - Adds a glow to bright areas of the image. */ export type BloomProps = { /** Radius of the sampling kernel in pixels. */ radius?: number; /** Luminance threshold above which a pixel contributes to bloom. */ threshold?: number; /** Strength of the bloom contribution. */ intensity?: number; }; export type BloomUniforms = BloomProps; /** * Bloom * Adds a glow to bright areas of the image. */ export declare const bloom: { readonly name: "bloom"; readonly source: "struct bloomUniforms {\n radius: f32,\n threshold: f32,\n intensity: f32,\n};\n\n@group(0) @binding(auto) var bloom: bloomUniforms;\n\nfn bloom_extract(sampleColor: vec3f) -> vec3f {\n let luminance = dot(sampleColor, vec3f(0.2126, 0.7152, 0.0722));\n let normalizedThreshold = max(1.0 - bloom.threshold, 0.00001);\n let bloomAmount = clamp((luminance - bloom.threshold) / normalizedThreshold, 0.0, 1.0);\n return sampleColor * bloomAmount;\n}\n\nfn bloom_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let baseColor = textureSample(sourceTexture, sourceTextureSampler, texCoord);\n let texel = vec2f(bloom.radius) / texSize;\n var bloomColor = vec3f(0.0);\n var total = 0.0;\n\n for (var x = -1.0; x <= 1.0; x += 1.0) {\n for (var y = -1.0; y <= 1.0; y += 1.0) {\n var weight: f32;\n if (x == 0.0 && y == 0.0) {\n weight = 4.0;\n } else if (x == 0.0 || y == 0.0) {\n weight = 2.0;\n } else {\n weight = 1.0;\n }\n\n let offset = vec2f(x, y) * texel;\n let sampleColor = textureSample(sourceTexture, sourceTextureSampler, texCoord + offset).rgb;\n bloomColor += bloom_extract(sampleColor) * weight;\n total += weight;\n }\n }\n\n bloomColor /= total;\n return vec4f(baseColor.rgb + bloomColor * bloom.intensity, baseColor.a);\n}\n"; readonly fs: "layout(std140) uniform bloomUniforms {\n float radius;\n float threshold;\n float intensity;\n} bloom;\n\nvec3 bloom_extract(vec3 sampleColor) {\n float luminance = dot(sampleColor, vec3(0.2126, 0.7152, 0.0722));\n float normalizedThreshold = max(1.0 - bloom.threshold, 0.00001);\n float bloomAmount = clamp((luminance - bloom.threshold) / normalizedThreshold, 0.0, 1.0);\n return sampleColor * bloomAmount;\n}\n\nvec4 bloom_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 baseColor = texture(source, texCoord);\n vec2 texel = vec2(bloom.radius) / texSize;\n vec3 bloomColor = vec3(0.0);\n float total = 0.0;\n\n for (float x = -1.0; x <= 1.0; x++) {\n for (float y = -1.0; y <= 1.0; y++) {\n float weight = (x == 0.0 && y == 0.0) ? 4.0 : ((x == 0.0 || y == 0.0) ? 2.0 : 1.0);\n vec2 offset = vec2(x, y) * texel;\n vec3 sampleColor = texture(source, texCoord + offset).rgb;\n bloomColor += bloom_extract(sampleColor) * weight;\n total += weight;\n }\n }\n\n bloomColor /= total;\n return vec4(baseColor.rgb + bloomColor * bloom.intensity, baseColor.a);\n}\n"; readonly props: BloomProps; readonly uniforms: BloomUniforms; readonly uniformTypes: { readonly radius: "f32"; readonly threshold: "f32"; readonly intensity: "f32"; }; readonly propTypes: { readonly radius: { readonly value: 4; readonly min: 0; readonly softMax: 20; }; readonly threshold: { readonly value: 0.8; readonly min: 0; readonly max: 1; }; readonly intensity: { readonly value: 1; readonly min: 0; readonly softMax: 3; }; }; readonly passes: [{ readonly sampler: true; }]; }; //# sourceMappingURL=bloom.d.ts.map