Sci-Fi Lens Flare Generator
Generate procedural sci-fi lens flares with customizable hotspot, streaks, iris, and halo. Export as transparent PNG for compositing.
About
Lens flares in visual effects are not random artifacts. They result from specific optical interactions: internal reflections between lens elements, diffraction around aperture blades, and scattering from coating imperfections. Replicating these phenomena procedurally requires modeling each component independently. The hotspot is a high-intensity radial gradient with exponential falloff governed by I = I0 β eβkr2. Streaks emerge from diffraction spikes whose angular distribution depends on aperture blade count. Iris ghosts are secondary reflections positioned along the optical axis at distances proportional to element spacing. This tool computes all four components (hotspot, streaks, iris, halo) on a Canvas element using a seeded PRNG (Mulberry32) for reproducibility. Output is a transparent PNG suitable for screen or add blend mode compositing. The tool approximates optical behavior. It does not simulate wave-optics diffraction patterns or real lens element geometry.
Formulas
The hotspot intensity at distance r from center follows a Gaussian-like radial falloff:
where I0 = peak intensity (normalized to 1.0), k = falloff coefficient controlling hotspot tightness, r = pixel distance from flare center.
Streak ray direction angles for an n-blade aperture:
where i β {0, 1, β¦, n β 1}, Ο = rotation offset. Each streak intensity decays linearly from center: Istreak = 1 β dL where d is distance along the ray and L is maximum streak length.
Iris ghost positions are reflected through the frame center. For a light source at position P and frame center C, ghost j appears at:
where tj is a spacing factor unique to each ghost element, typically sampled from a seeded PRNG.
The Mulberry32 PRNG used for deterministic seed-based generation:
t = (t &xor; (t >>> 15)) Γ (t | 1)
output = ((t &xor; (t + (t &xor; (t >>> 7)) Γ (t | 61))) >>> 0) Γ· 4294967296
All color computation uses HSL with the user-selected H as base hue. Chromatic dispersion in iris ghosts shifts hue by Β±30Β° per ghost index.
Reference Data
| Component | Optical Origin | Visual Character | Key Parameter | Typical Scale |
|---|---|---|---|---|
| Hotspot | Direct light source image | Bright core, soft falloff | Falloff exponent k | 0.5 - 2.0Γ source size |
| Diffraction Streaks | Aperture blade edges | Radial lines from center | Blade count, rotation | 4, 6, or 8 blades |
| Iris Ghosts | Inter-element reflections | Colored circles along axis | Element count, spacing | 3 - 12 ghosts |
| Halo Ring | Spherical aberration | Large soft circle | Ring radius, dispersion | 0.3 - 0.8Γ frame |
| Chromatic Ring | Lateral chromatic aberration | Rainbow-edged ring | Dispersion width | 2 - 10 px |
| Anamorphic Streak | Cylindrical lens element | Horizontal blue line | Aspect ratio, hue shift | Full frame width |
| Starburst | Filter cross-hatching | Fine radial rays | Ray count, thinness | 12 - 32 rays |
| Orb Ghost | Dust on front element | Large faint circle | Size, opacity | 50 - 200 px |
| Sensor Bloom | CCD/CMOS overflow | Vertical smear | Bloom height | 10 - 100% frame |
| Coating Flare | Anti-reflective coating failure | Green/magenta wash | Hue, coverage | Quadrant-scale |
| Veil Glare | Multi-surface scatter | Overall contrast reduction | Intensity | 5 - 25% opacity |
| Edge Flare | Lens barrel reflection | Bright crescent at frame edge | Position, curvature | Corner regions |