Skip to content

Pass Effects

What This Example Shows

This example demonstrates the Pass Effect system for full-screen post-processing. Switch between 5 presets to see different effect chains applied to a sprite scene:

PresetPassesDescription
Clean0No post-processing
CRT Arcade1Full CRT composite — curvature, scanlines, bloom, vignette, and color bleed
Handheld4Posterize + LCD grid + backlight bleed + vignette
VHS Tape3VHS distortion + static noise + chromatic aberration
Retro PC3Color quantize + scanlines + vignette

Defining Pass Effects

Use createPassEffect with a schema for parameters and a TSL node builder:

import { createPassEffect } from 'three-flatland'
import { crtComplete } from '@three-flatland/nodes'
import { convertToTexture } from 'three/tsl'
const CRTPass = createPassEffect({
name: 'crt',
schema: {
curvature: 0.08,
scanlineIntensity: 0.18,
vignetteIntensity: 0.3,
bloomIntensity: 0.15,
colorBleed: 0.0012,
},
pass: ({ uniforms }) => (input, uv) => {
const tex = convertToTexture(input)
return crtComplete(tex, uv, {
curvature: uniforms.curvature,
scanlineIntensity: uniforms.scanlineIntensity,
vignetteIntensity: uniforms.vignetteIntensity,
bloomIntensity: uniforms.bloomIntensity,
colorBleed: uniforms.colorBleed,
})
},
})

Adding Passes at Runtime

Instantiate a pass and add it to Flatland. Passes chain in order — each receives the previous output:

const crt = new CRTPass()
flatland.addPass(crt)
// Animate parameters in the render loop
crt.curvature = 0.12
// Swap presets by clearing and adding new passes
flatland.clearPasses()
flatland.addPass(new PosterizePass()).addPass(new VignettePass())

Next Steps