Advanced Anaglyph Stereo Techniques (r183)

Red-cyan stereoscopic demo using `AnaglyphEffect` with configurable depth presets to compare subtle, balanced, and deep parallax setups.

Key topics: three.js anaglyph, stereoscopic rendering, anaglyph effect, red cyan 3d, r183

Overview

Anaglyph 3D, the red-cyan glasses kind, is the oldest and most accessible form of stereoscopic display: it needs no special screen, just cheap filter glasses. This demo renders a deep tunnel of rings and layered objects through Three.js's AnaglyphEffect, with depth presets that let you compare subtle and dramatic stereo, plus a mono fallback for comparison.

How it works

Stereo vision works because your eyes see the world from two slightly different positions, and your brain fuses the two images into depth. An anaglyph renders the scene twice, from left-eye and right-eye cameras separated by a small distance, then encodes each image into different colour channels: left in red, right in green and blue (cyan). The glasses filter each eye so it sees only its image.

AnaglyphEffect wraps the renderer and does this automatically using a StereoCamera, rendering each eye into a render target and combining them with a colour matrix chosen to reduce ghosting (crosstalk between the eyes). The demo's depth presets scale how much parallax the scene produces: subtle keeps everything close to the screen plane for comfort, balanced is a good default, and deep exaggerates separation for impact at the cost of eye strain.

Exploring the demo

If you have red-cyan glasses, put them on (red over the left eye) and switch between presets while looking down the tunnel. Without glasses, toggle between mono and anaglyph to see the colour fringes, which are the parallax itself: the further an object is from the screen plane, the wider its red and cyan offsets.

Practical advice

Saturated reds and cyans look odd in anaglyph because each eye loses part of the colour, so muted palettes work best. Avoid very close objects with big parallax, which cause discomfort. To control eye separation and convergence directly, use the stereo rig sandbox; for headset-based stereo, see the VR preview.

What this code does

- AnaglyphEffect Pipeline: renders stereoscopic red/cyan output for classic 3D-glasses viewing.
- Depth Preset Comparison: subtle, balanced, and deep profiles scale scene parallax for comfort vs intensity tradeoffs.
- Mono Fallback: switch between mono and anaglyph to inspect depth cue differences instantly.
- Spatial Composition: tunnel rings and layered objects are distributed across depth for strong stereo readability.
- Practical Use: helps tune stereoscopic comfort before shipping camera or XR-adjacent visual experiments.

JavaScript Implementation

ES6+
import * as THREE from 'three'
import { AnaglyphEffect } from 'three/examples/jsm/effects/AnaglyphEffect.js'

const renderer = new THREE.WebGLRenderer({ antialias: true })
renderer.setSize(width, height)
const effect = new AnaglyphEffect(renderer)
effect.setSize(width, height)

function animate () {
  requestAnimationFrame(animate)
  effect.render(scene, camera) // red/cyan stereo output
}
animate()

Related demos

Trending this week

Most popular