Volumetric Spotlight Lab (r183 roadmap)

Dense spotlight beam demo combining real spotlight shadows with additive volumetric cone scattering and animated occluders for dynamic light shafts.

Key topics: three.js volumetric spotlight, fog beam, spotlight shadows, light shafts, volumetric lighting

Overview

Stage lights, searchlights and light through a church window all share a look: a visible beam, with moving objects casting dark streaks through it. This lab builds that look without the cost of full volumetric rendering by pairing a real shadow-casting SpotLight with an additive beam mesh, and animating occluders through the light so you can see the interaction.

How it works

The effect has two layers that are tuned together:

  • The light. A SpotLight with shadows enabled lights the floor and objects. Its angle and penumbra define the cone, and its shadow camera is a perspective camera that matches that cone, so the shadows of the moving blockers land correctly on the floor.
  • The beam. A cone mesh aligned with the light uses additive blending and partial transparency to represent light scattered by the air. Combined with FogExp2, distant parts of the scene fade into haze so the beam has something to "light up".

The moving boxes cast real shadows on the floor while passing through the visible cone, which is what persuades the eye that the beam is a volume of light. A SpotLightHelper can be shown to visualise the cone geometry the two layers share.

Exploring the demo

Change the cone angle and penumbra and watch the beam and the pool on the floor change together. Raise fog density for a smoky, concert-like look, and lower it for a subtle shaft. Follow a moving blocker: its floor shadow is real, but the beam itself does not darken behind it, which is the main limitation of a mesh-based beam compared with raymarching.

Where to go next

True volumetric lighting raymarches through the beam, sampling the shadow map at each step, so occluders cut dark gaps into the shaft itself. That is more expensive but sometimes worth it for hero shots. Compare the simpler god rays and fog scattering demos, see measured real-world beam shapes in IES profiles, and explore full volumes in raymarched clouds.

What this code does

- Hybrid Volumetric Setup: uses a real `SpotLight` for shadows plus an additive cone mesh to approximate volumetric scattering.
- Shadow Interaction: moving blockers cast visible shadow patterns through the beam, improving depth perception.
- Fog Coupling: scene fog density and beam opacity are tuned together to control shaft readability.
- Penumbra + Angle Controls: spotlight shape parameters directly affect beam edge softness and cone footprint.
- Practical Pattern: useful for stage lights, searchlights, and dramatic interior lighting without heavy volumetric raymarching.

JavaScript Implementation

ES6+
import * as THREE from 'three'

const spot = new THREE.SpotLight(0xc7ddff, 24, 48, Math.PI / 7, 0.45, 1.15)
spot.castShadow = true
scene.add(spot)

const beam = new THREE.Mesh(
  new THREE.ConeGeometry(2.0, 9.8, 56, 1, true),
  new THREE.MeshBasicMaterial({
    color: 0xc5dbff,
    transparent: true,
    opacity: 0.56,
    blending: THREE.AdditiveBlending,
    depthWrite: false,
    side: THREE.DoubleSide
  })
)
beam.position.copy(spot.position)
beam.lookAt(spot.target.position)
scene.add(beam)

Related demos

Trending this week

Most popular