import type { Texture } from '@luma.gl/core'; import type { ShaderPass } from '@luma.gl/shadertools'; export declare const MAX_BLOOM_LENS_GHOSTS = 6; export declare const MAX_BLOOM_LENS_SPIKES = 8; /** Optional photographic lens artifacts generated from the extracted HDR highlights. */ export type BloomLensEffectsOptions = { /** Brightness of aperture-diffraction streaks. Defaults to zero. */ starburstIntensity?: number; /** Number of diffraction rays. Rounded to an even value between two and eight. */ starburstSpikes?: number; /** Length of each diffraction ray in half-resolution source texels. Defaults to 48. */ starburstLength?: number; /** Rotation of the diffraction pattern, in radians. Defaults to zero. */ starburstRotation?: number; /** Brightness of chromatic lens-element reflections. Defaults to zero. */ ghostIntensity?: number; /** Number of reflected lens ghosts, clamped between one and six. Defaults to three. */ ghostCount?: number; /** Distance between successive lens-element reflections. Defaults to 0.32. */ ghostSpacing?: number; /** Brightness of the radial lens halo. Defaults to zero. */ haloIntensity?: number; /** Radius of the radial lens halo in normalized texture coordinates. Defaults to 0.34. */ haloRadius?: number; /** Spectral separation applied to ghosts and halos. Defaults to zero. */ chromaticAberration?: number; /** * Brightness of the sampled lens dirt mask. When positive, provide a sampled texture through * `ShaderPassRenderer.renderToTexture({bindings: {lensDirtTexture}})` or `renderToScreen()`. */ dirtIntensity?: number; }; type BloomLensUniforms = { starburstIntensity: number; starburstSpikes: number; starburstLength: number; starburstRotation: number; ghostIntensity: number; ghostCount: number; ghostSpacing: number; haloIntensity: number; haloRadius: number; chromaticAberration: number; }; type BloomLensBindings = { glowTexture?: Texture; }; export declare const bloomLensArtifactsPass: { readonly name: "bloomLens"; readonly source: "\nconst BLOOM_LENS_MAX_GHOSTS = 6;\nconst BLOOM_LENS_MAX_DIRECTIONS = 4;\nconst BLOOM_LENS_STREAK_SAMPLES = 8;\n\nstruct bloomLensUniforms {\n starburstIntensity: f32,\n starburstSpikes: f32,\n starburstLength: f32,\n starburstRotation: f32,\n ghostIntensity: f32,\n ghostCount: f32,\n ghostSpacing: f32,\n haloIntensity: f32,\n haloRadius: f32,\n chromaticAberration: f32,\n};\n\n@group(0) @binding(auto) var bloomLens: bloomLensUniforms;\n@group(0) @binding(auto) var glowTexture: texture_2d;\n@group(0) @binding(auto) var glowTextureSampler: sampler;\n\nfn bloomLens_sampleSpectralHighlight(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n coordinate: vec2f,\n direction: vec2f\n) -> vec3f {\n if (any(coordinate < vec2f(0.0)) || any(coordinate > vec2f(1.0))) {\n return vec3f(0.0);\n }\n\n if (bloomLens.chromaticAberration <= 0.0) {\n return textureSampleLevel(sourceTexture, sourceTextureSampler, coordinate, 0.0).rgb;\n }\n\n let spectralOffset = direction * bloomLens.chromaticAberration * 0.018;\n return vec3f(\n textureSampleLevel(sourceTexture, sourceTextureSampler, coordinate + spectralOffset, 0.0).r,\n textureSampleLevel(sourceTexture, sourceTextureSampler, coordinate, 0.0).g,\n textureSampleLevel(sourceTexture, sourceTextureSampler, coordinate - spectralOffset, 0.0).b\n );\n}\n\nfn bloomLens_sampleStarburst(texCoord: vec2f) -> vec3f {\n let directionCount = max(bloomLens.starburstSpikes * 0.5, 1.0);\n let glowDimensions = vec2f(textureDimensions(glowTexture));\n var streakColor = vec3f(0.0);\n var totalWeight = 0.0;\n\n for (var directionIndex = 0; directionIndex < BLOOM_LENS_MAX_DIRECTIONS; directionIndex += 1) {\n if (f32(directionIndex) >= directionCount) {\n continue;\n }\n\n let angle = bloomLens.starburstRotation + f32(directionIndex) * 3.14159265359 / directionCount;\n let direction = vec2f(cos(angle), sin(angle));\n for (var sampleIndex = 1; sampleIndex <= BLOOM_LENS_STREAK_SAMPLES; sampleIndex += 1) {\n let sampleDistance = f32(sampleIndex) / f32(BLOOM_LENS_STREAK_SAMPLES);\n let offset = direction * bloomLens.starburstLength * sampleDistance / glowDimensions;\n let sampleWeight = exp(-sampleDistance * 2.4);\n let positiveColor = textureSampleLevel(\n glowTexture,\n glowTextureSampler,\n clamp(texCoord + offset, vec2f(0.0), vec2f(1.0)),\n 0.0\n ).rgb;\n let negativeColor = textureSampleLevel(\n glowTexture,\n glowTextureSampler,\n clamp(texCoord - offset, vec2f(0.0), vec2f(1.0)),\n 0.0\n ).rgb;\n streakColor += (positiveColor + negativeColor) * sampleWeight;\n totalWeight += sampleWeight * 2.0;\n }\n }\n\n return streakColor / max(totalWeight, 0.00001);\n}\n\nfn bloomLens_sampleGhosts(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texCoord: vec2f,\n radialDirection: vec2f\n) -> vec3f {\n let centeredCoordinate = texCoord - vec2f(0.5);\n let reflectedCoordinate = vec2f(1.0) - texCoord;\n var ghostColor = vec3f(0.0);\n var totalWeight = 0.0;\n\n for (var ghostIndex = 0; ghostIndex < BLOOM_LENS_MAX_GHOSTS; ghostIndex += 1) {\n if (f32(ghostIndex) >= bloomLens.ghostCount) {\n continue;\n }\n\n let ghostCoordinate = reflectedCoordinate +\n centeredCoordinate * f32(ghostIndex) * bloomLens.ghostSpacing;\n let radialFalloff = max(1.0 - length(ghostCoordinate - vec2f(0.5)) * 1.41421356, 0.0);\n let ghostWeight = radialFalloff * (1.0 - f32(ghostIndex) / (bloomLens.ghostCount + 1.0));\n ghostColor += bloomLens_sampleSpectralHighlight(\n sourceTexture,\n sourceTextureSampler,\n ghostCoordinate,\n radialDirection\n ) * ghostWeight;\n totalWeight += ghostWeight;\n }\n\n return ghostColor / max(totalWeight, 0.00001);\n}\n\nfn bloomLens_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let centeredCoordinate = texCoord - vec2f(0.5);\n let radialDirection = centeredCoordinate / max(length(centeredCoordinate), 0.00001);\n var lensColor = vec3f(0.0);\n\n if (bloomLens.starburstIntensity > 0.0) {\n lensColor += bloomLens_sampleStarburst(texCoord) * bloomLens.starburstIntensity;\n }\n if (bloomLens.ghostIntensity > 0.0) {\n lensColor += bloomLens_sampleGhosts(\n sourceTexture,\n sourceTextureSampler,\n texCoord,\n radialDirection\n ) * bloomLens.ghostIntensity;\n }\n if (bloomLens.haloIntensity > 0.0) {\n let haloCoordinate = texCoord - radialDirection * bloomLens.haloRadius;\n let haloFalloff = max(1.0 - length(centeredCoordinate) * 1.41421356, 0.0);\n lensColor += bloomLens_sampleSpectralHighlight(\n sourceTexture,\n sourceTextureSampler,\n haloCoordinate,\n radialDirection\n ) * bloomLens.haloIntensity * haloFalloff;\n }\n\n return vec4f(lensColor, 1.0);\n}\n"; readonly fs: "\n#define BLOOM_LENS_MAX_GHOSTS 6\n#define BLOOM_LENS_MAX_DIRECTIONS 4\n#define BLOOM_LENS_STREAK_SAMPLES 8\n\nlayout(std140) uniform bloomLensUniforms {\n float starburstIntensity;\n float starburstSpikes;\n float starburstLength;\n float starburstRotation;\n float ghostIntensity;\n float ghostCount;\n float ghostSpacing;\n float haloIntensity;\n float haloRadius;\n float chromaticAberration;\n} bloomLens;\n\nuniform sampler2D glowTexture;\n\nvec3 bloomLens_sampleSpectralHighlight(\n sampler2D sourceTexture,\n vec2 coordinate,\n vec2 direction\n) {\n if (any(lessThan(coordinate, vec2(0.0))) || any(greaterThan(coordinate, vec2(1.0)))) {\n return vec3(0.0);\n }\n\n if (bloomLens.chromaticAberration <= 0.0) {\n return textureLod(sourceTexture, coordinate, 0.0).rgb;\n }\n\n vec2 spectralOffset = direction * bloomLens.chromaticAberration * 0.018;\n return vec3(\n textureLod(sourceTexture, coordinate + spectralOffset, 0.0).r,\n textureLod(sourceTexture, coordinate, 0.0).g,\n textureLod(sourceTexture, coordinate - spectralOffset, 0.0).b\n );\n}\n\nvec3 bloomLens_sampleStarburst(vec2 texCoord) {\n float directionCount = max(bloomLens.starburstSpikes * 0.5, 1.0);\n vec2 glowDimensions = vec2(textureSize(glowTexture, 0));\n vec3 streakColor = vec3(0.0);\n float totalWeight = 0.0;\n\n for (int directionIndex = 0; directionIndex < BLOOM_LENS_MAX_DIRECTIONS; directionIndex++) {\n if (float(directionIndex) >= directionCount) {\n continue;\n }\n\n float angle = bloomLens.starburstRotation + float(directionIndex) * 3.14159265359 / directionCount;\n vec2 direction = vec2(cos(angle), sin(angle));\n for (int sampleIndex = 1; sampleIndex <= BLOOM_LENS_STREAK_SAMPLES; sampleIndex++) {\n float sampleDistance = float(sampleIndex) / float(BLOOM_LENS_STREAK_SAMPLES);\n vec2 offset = direction * bloomLens.starburstLength * sampleDistance / glowDimensions;\n float sampleWeight = exp(-sampleDistance * 2.4);\n vec3 positiveColor = textureLod(\n glowTexture,\n clamp(texCoord + offset, vec2(0.0), vec2(1.0)),\n 0.0\n ).rgb;\n vec3 negativeColor = textureLod(\n glowTexture,\n clamp(texCoord - offset, vec2(0.0), vec2(1.0)),\n 0.0\n ).rgb;\n streakColor += (positiveColor + negativeColor) * sampleWeight;\n totalWeight += sampleWeight * 2.0;\n }\n }\n\n return streakColor / max(totalWeight, 0.00001);\n}\n\nvec3 bloomLens_sampleGhosts(\n sampler2D sourceTexture,\n vec2 texCoord,\n vec2 radialDirection\n) {\n vec2 centeredCoordinate = texCoord - vec2(0.5);\n vec2 reflectedCoordinate = vec2(1.0) - texCoord;\n vec3 ghostColor = vec3(0.0);\n float totalWeight = 0.0;\n\n for (int ghostIndex = 0; ghostIndex < BLOOM_LENS_MAX_GHOSTS; ghostIndex++) {\n if (float(ghostIndex) >= bloomLens.ghostCount) {\n continue;\n }\n\n vec2 ghostCoordinate = reflectedCoordinate +\n centeredCoordinate * float(ghostIndex) * bloomLens.ghostSpacing;\n float radialFalloff = max(1.0 - length(ghostCoordinate - vec2(0.5)) * 1.41421356, 0.0);\n float ghostWeight = radialFalloff * (1.0 - float(ghostIndex) / (bloomLens.ghostCount + 1.0));\n ghostColor += bloomLens_sampleSpectralHighlight(\n sourceTexture,\n ghostCoordinate,\n radialDirection\n ) * ghostWeight;\n totalWeight += ghostWeight;\n }\n\n return ghostColor / max(totalWeight, 0.00001);\n}\n\nvec4 bloomLens_sampleColor(sampler2D sourceTexture, vec2 texSize, vec2 texCoord) {\n vec2 centeredCoordinate = texCoord - vec2(0.5);\n vec2 radialDirection = centeredCoordinate / max(length(centeredCoordinate), 0.00001);\n vec3 lensColor = vec3(0.0);\n\n if (bloomLens.starburstIntensity > 0.0) {\n lensColor += bloomLens_sampleStarburst(texCoord) * bloomLens.starburstIntensity;\n }\n if (bloomLens.ghostIntensity > 0.0) {\n lensColor += bloomLens_sampleGhosts(\n sourceTexture,\n texCoord,\n radialDirection\n ) * bloomLens.ghostIntensity;\n }\n if (bloomLens.haloIntensity > 0.0) {\n vec2 haloCoordinate = texCoord - radialDirection * bloomLens.haloRadius;\n float haloFalloff = max(1.0 - length(centeredCoordinate) * 1.41421356, 0.0);\n lensColor += bloomLens_sampleSpectralHighlight(\n sourceTexture,\n haloCoordinate,\n radialDirection\n ) * bloomLens.haloIntensity * haloFalloff;\n }\n\n return vec4(lensColor, 1.0);\n}\n"; readonly bindingLayout: readonly [{ readonly name: "glowTexture"; readonly group: 0; }]; readonly uniforms: BloomLensUniforms; readonly bindings: BloomLensBindings; readonly uniformTypes: { readonly starburstIntensity: "f32"; readonly starburstSpikes: "f32"; readonly starburstLength: "f32"; readonly starburstRotation: "f32"; readonly ghostIntensity: "f32"; readonly ghostCount: "f32"; readonly ghostSpacing: "f32"; readonly haloIntensity: "f32"; readonly haloRadius: "f32"; readonly chromaticAberration: "f32"; }; readonly defaultUniforms: { readonly starburstIntensity: 0; readonly starburstSpikes: 4; readonly starburstLength: 48; readonly starburstRotation: 0; readonly ghostIntensity: 0; readonly ghostCount: 3; readonly ghostSpacing: 0.32; readonly haloIntensity: 0; readonly haloRadius: 0.34; readonly chromaticAberration: 0; }; readonly passes: [{ readonly sampler: true; }]; }; type BloomTemporalBindings = { historyTexture?: Texture; velocityTexture?: Texture; depthTexture?: Texture; }; type BloomTemporalUniforms = { stability: number; depthThreshold: number; exposureScale: number; }; /** Builds optional motion-aware history without requiring scene textures in the portable mode. */ export declare function createBloomTemporalPass(motionReprojection: boolean): ShaderPass & BloomTemporalBindings, BloomTemporalUniforms, BloomTemporalBindings>; export declare const bloomTemporalPass: ShaderPass & BloomTemporalBindings, BloomTemporalUniforms, BloomTemporalBindings>; type BloomLensCompositeUniforms = { tint: [number, number, number]; intensity: number; dirtIntensity: number; energyConserving: number; }; type BloomLensCompositeBindings = { glowTexture?: Texture; lensTexture?: Texture; lensDirtTexture?: Texture; }; export declare function createBloomLensCompositePass(includeLensArtifacts: boolean, includeLensDirt: boolean): ShaderPass & BloomLensCompositeBindings, BloomLensCompositeUniforms, BloomLensCompositeBindings>; export {}; //# sourceMappingURL=bloom-lens-effects.d.ts.map