# Screen-Space Atmospheric Light Scattering (Volumetric Glow Without Ray Marching) in Three.js

> Volumetric glow around point lights from one additive full-screen quad in the scene: each light is projected to the screen and gets a perspective-corrected inverse-power falloff, broken up by view-direction FBM and split per colour channel. No ray marching, no render targets; an optional ray test fades lights behind geometry.

- **Canonical page:** https://gamecrew.ai/techniques/three/screen-space-light-scattering
- **Techniques hub:** https://gamecrew.ai/techniques
- **Engine:** Three.js
- **Category:** atmosphere
- **Tags:** `volumetric`, `glow`, `scattering`, `fog`, `point lights`, `halo`, `atmosphere`, `screen-space`, `night`
- **Author:** @maddmann (https://gamecrew.ai/makers/maddmann), reviewed before it was shared
- **Revision:** 2 (2026-11-28)
- **Demo:** Demo passed on r2: [play it](https://play.gamecrew.ai/t/MkPNQQmO8U8q-GJFIt4XAkFHczP0v2NU/) ([picture](https://gamecrew.ai/techniques/three/screen-space-light-scattering/demo.png))

# Screen-space atmospheric light scattering

## When to use it

A handful of point lights (lanterns, headlights, spell orbs, street lamps) should look as if they light the air around them, and a ray-marched volume is too expensive or too much machinery. This draws that glow with one full-screen quad whose cost does not depend on scene complexity. It suits night scenes, fog, dust and stylised haze.

It is not a volume. It draws no shafts through gaps in geometry and no shadows cast into the fog, and a halo is never cut to the outline of something in front of it. For light beams through windows or leaves, a ray-marched or radial-blur technique is the right tool. It also assumes few lights: the quad loops over every light for every pixel, so it is built for one to four. It is for a flat screen; in a headset the quad would draw the same picture in both eyes.

## The idea

Scattering from a point light, seen from outside, looks close to a radial gradient centred on the light. So the technique skips the volume entirely:

1. **Project each light to the screen.** Here the vertex shader of the quad does it, with the camera matrices three.js already supplies, and hands the fragment shader each light's screen position, depth scale and strength. A light behind the camera has strength zero.
2. **Measure screen distance, then correct it for perspective.** With `d_screen` the aspect-corrected distance from the pixel to the light in UV units, and `z` the camera-to-light distance:

   `d = d_screen * max(z, 0.1) / referenceDepth`

   Without this the halo keeps a fixed screen size, so it seems to grow as the camera backs away. `referenceDepth` is the distance at which the halo has its authored size; it is a scene-scale knob.
3. **Inverse-power falloff.** `I = 1 / (1 + (d * scale)^falloff)`. The `1 +` caps the centre at 1 and avoids the singularity. A falloff of 2 is the inverse-square shape; lower is a softer, wider haze, higher a tighter core.
4. **Edge fade.** A light that leaves the screen fades out over one and a half screens instead of popping: with `o = max(abs(lightUv - 0.5) - 0.5, 0)` per axis, the weight is `(1 - smoothstep(0, 1.5, o.x)) * (1 - smoothstep(0, 1.5, o.y))`.
5. **Noise that belongs to the view direction, not the screen.** Each pixel's world-space view ray is the lookup position for 3D value-noise FBM. Turning the camera slides the pattern with the world, which reads as haze in the air. A per-light offset decorrelates the lights, and a slow time term drifts it. One `noiseDetail` value in 0..1 fades the second and third octaves in, so a phone can run one octave.
6. **Per-channel reach.** Each colour channel gets its own falloff radius from a scatter rate (0.3, 0.5, 1.0 for red, green, blue by default): `reach = sqrt(mean(rate) / rate)` multiplies the distance. Blue reaches further than red, so a blue lamp has a wider halo than an amber one and a white lamp's rim shifts cool.
7. **Add it to the frame.** The summed glow goes through a soft Reinhard curve, `c / (c + 0.6)`, so overlapping halos roll off instead of clipping, and is added to the finished picture.

### How it sits in a kit game

The glow is a mesh, not a post-processing pass. A two-by-two plane with additive blending, no depth test and a high `renderOrder` is added to the scene; its vertex shader ignores the camera and fills the screen. The game's own `game.render()` draws it last, over the tone-mapped frame, so nothing about the render loop changes and no render target is needed. Its `onBeforeRender` hook refreshes the uniforms for whichever camera is drawing.

### What is reconstructed and what is added

The source article gives the outline, the formulas for steps 2 to 4, the tone curve and the parameter values. It does not give the noise function, how noise enters the falloff, or how the scatter rates are applied. Here noise displaces the distance (`d += n * strength * scale`, with `n` in -1..1, eased to zero at the centre so the core stays round) and the rates set the per-channel radius in step 6. Both are this guide's choices. The article's vignette and background floor belong to its own full-screen page and are left out.

Occlusion is an addition. The article's glow ignores geometry, so a light behind a wall shines straight through it. Here the game may supply a ray test; each frame one ray per light runs from the camera to just short of the light, and the halo's strength eases towards 0 or 1 over `occlusionFade` seconds. A camera cut (a jump of more than a unit) snaps it. The whole halo dims; it is not cut to the occluder's shape.

### Colour space

The glow is authored display-referred, as in the article, so the parameters keep their look. The quad writes its values as they are (it is not tone mapped or colour converted) on top of a frame the renderer has already tone mapped and encoded, and it takes each light's colour as an sRGB value for the same reason.

## Implementation

```ts
import * as THREE from 'three';

export interface ScatterLight {
  position: THREE.Vector3; // world space
  color: THREE.Color;
  intensity: number;
}

export interface ScatterParams {
  intensity: number; // overall glow brightness
  falloff: number; // exponent; 2 is inverse-square
  scale: number; // distance scale; higher is a smaller halo
  saturation: number; // > 1 pushes light colours past their own saturation
  noiseScale: number; // noise frequency along the view direction
  noiseStrength: number; // how far noise displaces the falloff distance; 0 skips the noise
  noiseDetail: number; // 0..1, fades octaves two and three in
  noiseDrift: number; // noise units per second
  scatter: THREE.Vector3; // per-channel scatter rate
  referenceDepth: number; // camera-to-light distance at which the halo has its authored size
  occlusionFade: number; // seconds a halo takes to fade when its light goes behind something
}

/** True when something solid lies within `distance` of `origin` along `direction` (unit length). */
export type Blocked = (origin: THREE.Vector3, direction: THREE.Vector3, distance: number) => boolean;

const VERT = /* glsl */ `
uniform vec3 uLightPos[SCATTER_LIGHTS];
uniform float uLightPower[SCATTER_LIGHTS];
uniform float uRefDepth;
varying vec2 vUv;
varying vec3 vRay;
varying float vAspect;
varying vec4 vLight[SCATTER_LIGHTS]; // xy: the light on screen, z: depth scale, w: strength

// 1 while the light is on screen, fading to 0 over one and a half screens beyond the edge.
float edgeWeight(vec2 lightUv) {
  vec2 outside = max(abs(lightUv - 0.5) - 0.5, 0.0);
  vec2 w = 1.0 - smoothstep(vec2(0.0), vec2(1.5), outside);
  return w.x * w.y;
}

void main() {
  vUv = position.xy * 0.5 + 0.5;
  // The world-space view ray through this corner; the rasteriser interpolates it across the frame.
  vec4 v = inverse(projectionMatrix) * vec4(position.xy, 1.0, 1.0);
  vRay = transpose(mat3(viewMatrix)) * (v.xyz / v.w);
  vAspect = projectionMatrix[1][1] / projectionMatrix[0][0];
  // Each light is projected here, once per corner, and is the same at all four.
  for (int i = 0; i < SCATTER_LIGHTS; i++) {
    vec4 viewPos = viewMatrix * vec4(uLightPos[i], 1.0);
    vec4 clip = projectionMatrix * viewPos;
    vec2 lightUv = clip.xy / max(clip.w, 1e-4) * 0.5 + 0.5;
    float front = clamp(-viewPos.z / 0.6, 0.0, 1.0); // 0 behind the lens, eased so a passing light does not pop
    float depthScale = max(length(viewPos.xyz), 0.1) / uRefDepth;
    vLight[i] = vec4(lightUv, depthScale, uLightPower[i] * front * edgeWeight(lightUv));
  }
  gl_Position = vec4(position.xy, 0.0, 1.0);
}
`;

const FRAG = /* glsl */ `
uniform vec3 uLightColor[SCATTER_LIGHTS];
uniform float uTime;
uniform float uIntensity;
uniform float uFalloff;
uniform float uScale;
uniform float uSaturation;
uniform float uNoiseScale;
uniform float uNoiseStrength;
uniform float uNoiseDetail;
uniform float uNoiseDrift;
uniform vec3 uScatter;
uniform float uSolo;
varying vec2 vUv;
varying vec3 vRay;
varying float vAspect;
varying vec4 vLight[SCATTER_LIGHTS];

float cellRand(vec3 c) { return fract(sin(dot(c, vec3(127.1, 311.7, 74.7))) * 43758.5453); }

float valueNoise(vec3 x) {
  vec3 i = floor(x);
  vec3 f = fract(x);
  f = f * f * (3.0 - 2.0 * f);
  float a = mix(cellRand(i), cellRand(i + vec3(1.0, 0.0, 0.0)), f.x);
  float b = mix(cellRand(i + vec3(0.0, 1.0, 0.0)), cellRand(i + vec3(1.0, 1.0, 0.0)), f.x);
  float c = mix(cellRand(i + vec3(0.0, 0.0, 1.0)), cellRand(i + vec3(1.0, 0.0, 1.0)), f.x);
  float d = mix(cellRand(i + vec3(0.0, 1.0, 1.0)), cellRand(i + vec3(1.0, 1.0, 1.0)), f.x);
  return mix(mix(a, b, f.y), mix(c, d, f.y), f.z);
}

// Three octaves; uNoiseDetail fades the second in over 0..0.5 and the third over 0.5..1.
float haze(vec3 p) {
  float w2 = clamp(uNoiseDetail * 2.0, 0.0, 1.0) * 0.25;
  float w3 = clamp(uNoiseDetail * 2.0 - 1.0, 0.0, 1.0) * 0.125;
  float sum = valueNoise(p) * 0.5;
  if (w2 > 0.0) sum += valueNoise(p * 2.0) * w2;
  if (w3 > 0.0) sum += valueNoise(p * 4.0) * w3;
  return sum / (0.5 + w2 + w3);
}

float grain(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }

void main() {
  vec3 viewDir = normalize(vRay);
  vec3 rate = max(uScatter, vec3(0.02));
  vec3 reach = sqrt(vec3((rate.r + rate.g + rate.b) / 3.0) / rate); // blue reaches further than red
  vec3 total = vec3(0.0);

  for (int i = 0; i < SCATTER_LIGHTS; i++) {
    float power = vLight[i].w;
    if (power < 0.01) continue;

    vec2 delta = vUv - vLight[i].xy;
    delta.x *= vAspect;
    float d = length(delta) * vLight[i].z * uScale; // screen distance, corrected for the light's depth

    // Noise only where the light still contributes.
    if (uNoiseStrength > 0.0 && 1.0 / (1.0 + pow(d + 1e-5, uFalloff)) > 0.004) {
      vec3 np = viewDir * uNoiseScale + vec3(0.0, 0.0, float(i) * 50.0 + uTime * uNoiseDrift);
      float n = haze(np) * 2.0 - 1.0;
      d = max(d + n * uNoiseStrength * uScale * smoothstep(0.0, 0.2, d), 0.0);
    }

    vec3 glow = 1.0 / (1.0 + pow(vec3(d + 1e-5) * reach, vec3(uFalloff)));
    float luma = dot(uLightColor[i], vec3(0.299, 0.587, 0.114));
    vec3 tint = max(mix(vec3(luma), uLightColor[i], uSaturation), 0.0);
    total += tint * glow * power * uIntensity;
  }

  vec3 c = total / (total + vec3(0.6)); // soft Reinhard: overlapping halos roll off instead of clipping
  if (uSolo > 0.5) c = max(c, vec3(0.039, 0.059, 0.078));
  c += (grain(gl_FragCoord.xy) - 0.5) / 255.0; // dither: wide dim gradients band at 8 bits
  gl_FragColor = vec4(max(c, 0.0), 1.0);
}
`;

type Uniforms = {
  uLightPos: { value: THREE.Vector3[] };
  uLightColor: { value: THREE.Vector3[] };
  uLightPower: { value: number[] };
  uRefDepth: { value: number };
  uTime: { value: number };
  uIntensity: { value: number };
  uFalloff: { value: number };
  uScale: { value: number };
  uSaturation: { value: number };
  uNoiseScale: { value: number };
  uNoiseStrength: { value: number };
  uNoiseDetail: { value: number };
  uNoiseDrift: { value: number };
  uScatter: { value: THREE.Vector3 };
  uSolo: { value: number };
};

export class ScreenScatter {
  readonly params: ScatterParams = {
    intensity: 1,
    falloff: 2,
    scale: 3,
    saturation: 1.8,
    noiseScale: 4,
    noiseStrength: 0.12,
    noiseDetail: 0.5,
    noiseDrift: 0.02,
    scatter: new THREE.Vector3(0.3, 0.5, 1.0),
    referenceDepth: 2.5,
    occlusionFade: 0.12,
  };
  /** The quad. Add it to the scene once; it draws itself last, over the finished frame. */
  readonly mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.ShaderMaterial>;
  readonly lights: ScatterLight[];
  /** A ray test against the world. Without one, lights glow through geometry. */
  blocked: Blocked | undefined;

  private readonly u: Uniforms;
  private readonly seen: number[];
  private readonly camPos = new THREE.Vector3();
  private readonly lastCam = new THREE.Vector3();
  private readonly dir = new THREE.Vector3();
  private readonly col = new THREE.Color();
  private lastTime = -1;
  private time = 0;

  constructor(lights: ScatterLight[]) {
    if (lights.length < 1 || lights.length > 4) throw new Error('ScreenScatter takes 1 to 4 lights');
    this.lights = lights;
    this.seen = lights.map(() => 1);
    this.u = {
      uLightPos: { value: lights.map(() => new THREE.Vector3()) },
      uLightColor: { value: lights.map(() => new THREE.Vector3()) },
      uLightPower: { value: lights.map(() => 0) },
      uRefDepth: { value: 1 },
      uTime: { value: 0 },
      uIntensity: { value: 1 },
      uFalloff: { value: 2 },
      uScale: { value: 3 },
      uSaturation: { value: 1.8 },
      uNoiseScale: { value: 4 },
      uNoiseStrength: { value: 0.12 },
      uNoiseDetail: { value: 0.5 },
      uNoiseDrift: { value: 0.02 },
      uScatter: { value: new THREE.Vector3() },
      uSolo: { value: 0 },
    };
    const material = new THREE.ShaderMaterial({
      defines: { SCATTER_LIGHTS: lights.length },
      uniforms: this.u,
      vertexShader: VERT,
      fragmentShader: FRAG,
      transparent: true,
      blending: THREE.AdditiveBlending,
      depthTest: false,
      depthWrite: false,
      toneMapped: false,
    });
    this.mesh = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), material);
    this.mesh.name = 'ScreenScatter';
    this.mesh.frustumCulled = false; // its vertices ignore the camera, so its bounds mean nothing
    this.mesh.renderOrder = 9999;
    this.mesh.onBeforeRender = (_renderer, _scene, camera) => this.refresh(camera);
  }

  /** Draw the glow alone on the background colour (to inspect it) instead of adding it to the frame. */
  get solo(): boolean {
    return this.u.uSolo.value > 0.5;
  }
  set solo(on: boolean) {
    this.u.uSolo.value = on ? 1 : 0;
    this.mesh.material.blending = on ? THREE.NormalBlending : THREE.AdditiveBlending;
  }

  /** How much of light i's halo is showing, 0..1 (1 with nothing in the way). */
  visibility(i: number): number {
    return this.seen[i] ?? 0;
  }

  /**
   * Brings the uniforms up to date for this camera. The quad calls it before each draw; a test may call it with its
   * own dt (seconds).
   */
  refresh(camera: THREE.Camera, dt?: number): void {
    const now = performance.now() / 1000;
    const step = dt ?? (this.lastTime < 0 ? 0 : Math.min(now - this.lastTime, 0.1));
    const first = this.lastTime < 0;
    this.lastTime = now;
    this.time += step;

    const p = this.params;
    const u = this.u;
    u.uTime.value = this.time;
    u.uRefDepth.value = p.referenceDepth;
    u.uIntensity.value = p.intensity;
    u.uFalloff.value = p.falloff;
    u.uScale.value = p.scale;
    u.uSaturation.value = p.saturation;
    u.uNoiseScale.value = p.noiseScale;
    u.uNoiseStrength.value = p.noiseStrength;
    u.uNoiseDetail.value = p.noiseDetail;
    u.uNoiseDrift.value = p.noiseDrift;
    u.uScatter.value.copy(p.scatter);

    // A camera cut snaps the fades; otherwise each halo eases towards what the ray test says.
    this.camPos.setFromMatrixPosition(camera.matrixWorld);
    const cut = first || this.camPos.distanceTo(this.lastCam) > 1;
    this.lastCam.copy(this.camPos);
    const ease = cut || p.occlusionFade <= 0 ? 1 : 1 - Math.exp(-step / p.occlusionFade);

    for (let i = 0; i < this.lights.length; i++) {
      const light = this.lights[i];
      let open = 1;
      if (this.blocked) {
        this.dir.copy(light.position).sub(this.camPos);
        const distance = this.dir.length() - 0.3; // stop short, so the light's own bulb never hides it
        if (distance > 0 && this.blocked(this.camPos, this.dir.normalize(), distance)) open = 0;
      }
      this.seen[i] += (open - this.seen[i]) * ease;
      u.uLightPos.value[i].copy(light.position);
      // The glow is authored for the display, so it takes the colour as an sRGB value.
      this.col.copy(light.color).convertLinearToSRGB();
      u.uLightColor.value[i].set(this.col.r, this.col.g, this.col.b);
      u.uLightPower.value[i] = Math.max(light.intensity, 0) * this.seen[i];
    }
  }

  dispose(): void {
    this.mesh.geometry.dispose();
    this.mesh.material.dispose();
  }
}
```

In `start(game)`, with `lamps` the game's point lights (at the top of the scene, so their position is their world position) and `walls` the meshes that should hide a light:

```ts
const lights: ScatterLight[] = lamps.map((lamp) => ({ position: lamp.position, color: lamp.color, intensity: 1 }));
const scatter = new ScreenScatter(lights);

const ray = new THREE.Raycaster();
scatter.blocked = (origin, direction, distance) => {
  ray.set(origin, direction);
  ray.far = distance;
  return ray.intersectObjects(walls, false).length > 0;
};

game.scene.add(scatter.mesh);
```

That is all of the wiring: the light positions are shared vectors, and the quad refreshes itself when it is drawn. A lamp that is a child of something moving needs its world position copied into `lights[i].position` each step. Any ray test fits `blocked`; a game that already has a `CollisionWorld` can use its `raycast` instead of a `THREE.Raycaster`.

## Tuning

| Parameter | Default | Effect |
| --- | --- | --- |
| `intensity` | 1.0 | Overall glow brightness |
| `falloff` | 2.0 | Below 2 a wide soft haze, above 2 a tight core |
| `scale` | 3.0 | Halo size; higher is smaller |
| `saturation` | 1.8 | Pushes the light colour past its own saturation |
| `noiseScale` | 4.0 | Noise frequency |
| `noiseStrength` | 0.12 | How ragged the halo edge is; 0 skips the noise entirely |
| `noiseDetail` | 0.5 | Octaves: about 0.3 on a phone, 0.5 to 0.7 on a desktop |
| `noiseDrift` | 0.02 | How fast the haze drifts |
| `scatter` | 0.3, 0.5, 1.0 | Equal values remove the colour fringe |
| `referenceDepth` | 2.5 | Smaller shrinks every halo; set it for the scene's scale and usual camera distance |
| `occlusionFade` | 0.12 | Seconds; 0 switches instantly |

## Performance traps

- **The noise is the cost.** Each light can take up to three value-noise lookups of eight hashes each per pixel, at full resolution. The shader skips noise where a light's falloff is under 0.004 and skips lights whose strength is under 0.01. `noiseStrength: 0` removes the cost and the effect still reads.
- **It always draws at the frame's resolution.** Being a quad in the scene, it cannot render small and upsample the way a separate pass could. On a weak GPU the levers are `noiseDetail`, `noiseStrength` and the light count.
- **Light count is a compile-time constant** (`SCATTER_LIGHTS`). Changing it means a new `ScreenScatter`. Past four lights the per-pixel loop stops being cheap, and the class refuses more.
- **Banding.** A wide, dim gradient on a near-black frame bands at 8 bits. The shader adds half a level of dither; keep it.
- **Ray tests against detailed meshes.** One ray per light per frame is cheap against boxes or a BVH and slow against raw high-poly meshes. Test against simple blockers.
- **Bloom changes the maths.** With `game.enableBloom()` the scene is drawn into a linear buffer and tone mapped afterwards, so the quad's display-referred values would be added before tone mapping and come out stronger and wider. The demo runs without bloom, and the guide's values are tuned for that.
- **Transparent things draw under it.** The quad is last in the frame, so its glow lies over particles and glass as well as over solid geometry.

## How to check it

- **Glow alone** (`scatter.solo = true`): each halo is centred on its light and is round when `noiseStrength` is 0.
- **Perspective:** move the camera back from the lights. The halos shrink on screen with the lamps.
- **Edge fade:** turn until a light leaves the frame. Its glow still reaches in from that side and fades as the turn continues; it does not cut off at the edge.
- **Behind the camera:** orbit until a light is behind the lens. No mirrored halo appears on the opposite side of the screen.
- **View-anchored noise:** rotate the camera in place. The ragged halo edge slides with the world instead of sticking to the screen.
- **Occlusion:** move so a blocker sits between the camera and a light. `visibility(i)` falls to 0 and the halo fades; with `blocked` unset it shines through.
- **Colour fringe:** a blue lamp's halo is wider than an amber one's. With equal scatter rates they match.

## Official references

- Charles Grassi, Screen-Space Atmospheric Light Scattering: Rendering Volumetric God Rays Without Ray Marching (blog post, 29 December 2025)
- three.js manual: ShaderMaterial, Object3D.onBeforeRender and Raycaster

## Open-source sources

- Takes an idea from Screen-Space Atmospheric Light Scattering (blog post) by Charles Grassi, https://charlesgrassi.dev/blog/screen-space-atmospheric-scattering/ (The technique and its recommended parameter values; the code here is written fresh for three.js.)

Games built with this guide carry these credits, and the licence notices they ask for, in their third-party notices.

## Who made it

This guide is by @maddmann.

- @maddmann (https://gamecrew.ai/makers/maddmann): owner, 2 revisions
