---
id: "lens-flare"
title: "Pseudo lens flare"
domain: "post"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal]
year_introduced: 2013
inputs: [hdr-image]
outputs: [hdr-image]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Chapman"
url: "https://texelatlas.vercel.app/t/lens-flare/"
sources_verified_at: "2026-11-29"
---
# Pseudo lens flare (Chapman)

> Screen-space approximation of lens ghosts and halo: mirror the bright parts of the image about the screen centre, tint and chain them, and add the result back to the HDR buffer.

## Reach for it when

- bright lights look flat with no lens artefacts
- want cheap cinematic ghosts and halos
- need flare effect without occlusion queries
- scene sun should create camera-like streaks

## How it works

A thresholded, downsampled copy of the HDR image provides the bright features. For each of N ghosts, a sample coordinate is mirrored around the image centre and scaled by an increasing factor, producing copies of the light sources along the line through the centre. A radial weight fades ghosts near the edges. A halo is formed by sampling along the direction to the centre at a fixed radius and weighting by a ring function. Each ghost is tinted via a 1D gradient texture and chromatic dispersion offsets of the three channels. The result is blurred slightly, optionally multiplied by a dirt texture, and added back before tonemapping.

## When to use it

Choose it for a cheap cinematic lens artefact driven by whatever is bright in the frame, with no occlusion queries.

Prefer sprite-based flares with occlusion for hero art-directed suns. For soft glow without ghosts use [Dual-filter and progressive-downsample bloom](https://texelatlas.vercel.app/t/dual-filter-bloom.md).

## Cost

cheap — A handful of fetches per pixel at quarter resolution, qualitative.
Measured GPU Weight: 3.16× baseline (light) — 0.104 ms median / 0.1088 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 2.78× baseline (light) — 0.0442 ms median (2.35× faster on L4).
Ampere A100 scaling: 2.02× baseline (light) — 0.0581 ms median (1.79× faster on A100).

## Failure modes

- Ghosts appear for any bright pixel, so specular glints produce unintended flare
- Flicker when a light moves off screen and its ghosts pop out
- Looks artificial and repetitive without a lens dirt or aperture shape
- Costs and result depend on the threshold, which is scene specific

## Engine support

- babylonjs: builtin — `new BABYLON.LensFlareSystem('lf', emitter, scene)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/LensFlares/lensFlareSystem.ts, checked 2026-12-01)
- blender: builtin — `Compositor > Add > Filter > Glare, Glare Type = Ghosts (or Streaks)` (evidence: https://docs.blender.org/manual/en/5.2/compositing/types/filter/glare.html, checked 2026-12-01) — Image-space glare in the compositor.
- threejs: official — `import { lensflare } from 'three/addons/tsl/display/LensflareNode.js' (WebGL: Lensflare object)` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/tsl/display/LensflareNode.js, checked 2026-12-01)
- unity: builtin — `GameObject > Effects > Lens Flare (SRP); Volume > Screen Space Lens Flare` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare.md, checked 2026-12-01) — Data-driven lens flare asset plus a screen-space lens flare override, URP and HDRP.
- unreal: builtin — `Post Process Volume > Lens > Lens Flares` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/post-process-effects-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: hdr-image
- Outputs: hdr-image
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal

## Presets

### Left: bright lights only. Right: screen-space ghosts (image re-sampled through the centre at several scales) with chromatic offset (glsl-fragment; rendered 2026-11-29)

```json
{
  "GAIN": 0.8,
  "CA": 0.03
}
```

```glsl
float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}
float lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}
vec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}

const float GAIN=0.8; // P
const float CA=0.03; // P
const vec4 M=vec4(-2.2,-1.2,-0.75,0.65); // P
vec3 B(vec2 p){
  vec2 a=p-vec2(.3,.18),b=p+vec2(.28,.2);
  return vec3(.012,.014,.022)+vec3(1.,.85,.6)*.004/(dot(a,a)+.0006)+vec3(.6,.8,1.)*.002/(dot(b,b)+.0006);}
vec3 bp(vec2 p){return max(B(p)-1.,vec3(0.));}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
  vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;
  vec3 col=B(uv);
  if(R){vec3 fl=vec3(0.);
    for(int i=0;i<4;i++){float m=M[i];
      float w=pow(1.-clamp(length(uv)*1.5,0.,1.),1.5);
      vec3 g=vec3(bp(uv*m*(1.+CA)).r,bp(uv*m).g,bp(uv*m*(1.-CA)).b);
      fl+=g*w*mix(vec3(1.,.8,.6),vec3(.6,.8,1.),float(i)/3.);}
    col+=fl*GAIN;}
  col=col/(1.+col);
  if(abs(uv.x)<.0015)col=vec3(1.);
  fragColor=vec4(gam(col),1.);
}
```

Attribution: written for this index

## Combines with

- [Dual-filter and progressive-downsample bloom](https://texelatlas.vercel.app/t/dual-filter-bloom.md): Ghosts are sampled from the bloom downsample chain.

## Sources

1. [primary] John Chapman Pseudo Lens Flare. john-chapman-graphics.blogspot.com. https://john-chapman-graphics.blogspot.com/2013/02/pseudo-lens-flare.html (verified via http on 2026-11-29)
2. [implementation] Unity-Technologies (2016) Unity-Technologies/PostProcessing. https://github.com/Unity-Technologies/PostProcessing License: NOASSERTION. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Pseudo lens flare." https://texelatlas.vercel.app/t/lens-flare/ (accessed 2026-12-01).
