Post-processing
Updated
Post-processing effects change the whole image after the scene is drawn: a glow around bright lights, an old-photo sepia, darkened edges, film grain, a retro pixel look, a black-and-white flashback, a shock wave rippling out from an explosion, raindrops on the lens. Each effect is one component on a camera, with its own props, switched on and off like any other component. Together, a camera’s effects are that camera’s look.
Key concepts
Section titled “Key concepts”- Effect component. One effect, such as Sepia or Bloom, added to a camera entity. A camera has at most one of each.
- The camera’s look. The effects of the camera that is rendering. Cutting to another camera shows that camera’s effects instead.
- One-shot effects. Shock Wave and Lens Drops play when a script fires them; the others stay on while enabled.
Before you start
Section titled “Before you start”- Cameras. Effects go on camera entities, perspective or orthographic. To switch between cameras, scripts use
CameraDirector. See Cameras. - Components. Effects are read with
getComponent, changed withsetPropsand switched withsetEnabled. See Components. - Tweens. Smooth fades of effect props use
Tween.value. See Animation.
How it works
Section titled “How it works”- On a camera only. An effect on any other entity, the scene root included, does nothing and warns once in the console. A look shared by several cameras goes on each of them.
- The rendering camera’s effects show. The image shows the effects of the camera rendering it: the main camera, or the camera a script cut to with
CameraDirector.switchTo(...). A cut swaps effects from the same frame; a camera without effects shows none. - Ready before they show. Each camera’s effects are prepared while its scene loads, so a camera cut never stalls and never shows one camera’s view with another’s effects.
- Fixed order. Effects always run in this order, whatever the order of the components: Bloom, Shock Wave, Lens Drops, Pixelation, ASCII, Dot Screen, Hue/Saturation, Sepia, Grayscale, Scanline, Noise, Vignette, Glitch. A camera has at most one of each.
- In play. Effects show in play, and in the editor’s Preview render mode.
- In headsets too. Effects run in VR and AR. Each effect is drawn where both eyes agree, so a vignette or a drop on the lens sits at the same place for both eyes. Bloom glows within each eye.
- Live edits are cheap. A prop change is written straight to the running effect, so tweening a prop costs only the effect itself. Adding, removing, enabling or disabling an effect rebuilds its camera’s effect chain once, which can mean a shader compile the first time.
Camera shake, recoil and other camera motion effects are not post-processing; see Cameras.
Your first effect
Section titled “Your first effect”The simplest script adds a soft glow and darker edges to the camera, unless they were already added in the editor.
#pragma lifecycle(startup)
function startup() { const eye = findEntity('Main Camera');
if (!eye.getComponent(BloomEffectComponent)) { eye.addComponent(new BloomEffectComponent({ intensity: 0.8, luminanceThreshold: 0.7 })); } if (!eye.getComponent(VignetteEffectComponent)) { eye.addComponent(new VignetteEffectComponent({ darkness: 0.4, offset: 0.5 })); }}findEntity('Main Camera')finds the camera entity; effects work only on a camera.- Each effect is added only if it is missing, so the script does not replace a look tuned in the editor.
- Adding effects rebuilds the camera’s effect chain once; doing it in
startupkeeps that cost out of play.
Your first effect: a script adds Bloom and Vignette to the main camera, only when they are missing, so bright objects glow and the edges darken.
Look at the glowing shapes and the darker corners. Drag to orbit the camera, scroll to zoom.
Choosing
Section titled “Choosing”| If you want… | Use… | Read |
|---|---|---|
| An old-photo, black-and-white or recoloured image, or dark edges | Sepia, Grayscale, Hue/Saturation, Vignette | Colour effects |
| A pixel, ASCII, printed, CRT, grainy or glitchy look | Pixelation, ASCII, Dot Screen, Scanline, Noise, Glitch | Stylize effects |
| Glowing lights, an explosion ripple, rain on the lens | Bloom, Shock Wave, Lens Drops | Light and lens effects |
| Camera shake, recoil or sway | Camera effects (not post-processing) | Camera effects |
In scripts
Section titled “In scripts”| Global | What it is |
|---|---|
BloomEffectComponent | Makes bright parts of the image glow. |
ShockWaveEffectComponent | A ring that ripples the image outward from a world point, like a blast. One-shot: it stays enabled, draws nothing and costs nothing measurable while idle, and play sets it off. |
LensDropsEffectComponent | Raindrops on the camera's lens, drawn procedurally on the GPU. Switched on, count drops are on the lens at once and new ones land at rate a second for duration seconds; each dries over evaporation seconds. Big drops cling for up to cling seconds, then slide down the way the world's down falls across the view, as fast as gravity says, leaving droplets behind and wiping the drops in their path. Each drop bends the image like a small lens. Switched off, they are gone; on again, it starts over, moved advance seconds ahead. Once the last drop has dried it idles at a branch a pixel, still enabled; play starts it over, stop ends the rain early and clear wipes the lens at once. Kept enabled, its shaders are compiled with the scene, so a later play shows at once, with no stall. |
PixelationEffectComponent | Draws the image in large square pixels, like a retro game. |
SepiaEffectComponent | Tints the image brown, like an old photograph. |
GrayscaleEffectComponent | Renders the image in black and white. |
VignetteEffectComponent | Darkens the edges of the image. |
GlitchEffectComponent | Tears and shifts the image now and then, like a broken video signal. |
CameraDirector | Cut between cameras by name or id: switchTo(name), switchToMain(); current and main are the camera entities. |
Components
Section titled “Components”| Component | Type | What it does |
|---|---|---|
| Hue Saturation Effect | comp-hue-saturation-effect | Shifts the colours around the colour wheel and makes them duller or more vivid. |
| Sepia Effect | comp-sepia-effect | Tints the image brown, like an old photograph. |
| Grayscale Effect | comp-grayscale-effect | Renders the image in black and white. |
| Vignette Effect | comp-vignette-effect | Darkens the edges of the image. |
| Pixelation Effect | comp-pixelation-effect | Draws the image in large square pixels, like a retro game. |
| Ascii Effect | comp-ascii-effect | Redraws the image as text characters. |
| Dot Screen Effect | comp-dot-screen-effect | Redraws the image as halftone dots, like print. |
| Scanline Effect | comp-scanline-effect | Horizontal lines over the image, like an old screen. |
| Noise Effect | comp-noise-effect | Animated film grain over the image. |
| Glitch Effect | comp-glitch-effect | Tears and shifts the image now and then, like a broken video signal. |
| Bloom Effect | comp-bloom-effect | Makes bright parts of the image glow. |
| Shock Wave Effect | comp-shock-wave-effect | A ring that ripples the image outward from a world point, like a blast, set off by a script. |
| Lens Drops Effect | comp-lens-drops-effect | Raindrops on the camera lens that land, slide down and dry off. |
Performance
Section titled “Performance”Nothing runs per frame on the CPU beyond a few value writes. The graphics card does the work, in full-screen passes:
| Camera | Full-screen passes |
|---|---|
| No effects | 1: tone mapping and antialiasing together |
| With effects | 2: the effects and tone mapping, then antialiasing |
| With ASCII after another effect | 1 more |
| In a headset, with effects | the scene into a buffer, then 1 pass over both eyes, plus ASCII’s |
| In a headset, no effects | none |
- Every pass is full-resolution work, which matters most on phones and standalone headsets. In a headset, effects also turn off the headset’s fixed foveation for the scene buffer. Keep effects few on those devices.
- Bloom also blurs a chain of smaller buffers.
- Lens Drops draws a small map of its drops each frame while any are on the lens, and nothing once they have dried.
- Prefer props to toggles. For an effect you switch often, keep it enabled and drive a prop instead: Glitch’s
active, anintensityof 0, or Lens Drops’play()andclear().
Common mistakes
Section titled “Common mistakes”- Putting effects on the scene root or another entity. They do nothing there and warn once in the console. Move them to the camera.
- Toggling effects with
setEnabledin gameplay. Each switch rebuilds the camera’s chain and may compile shaders. Drive a prop instead. - Expecting effects to follow a camera cut. Each camera has its own look. Add the effect to every camera that should show it.
- Calling Shock Wave’s
play()while the effect is disabled. A disabled effect draws nothing; keep Shock Wave enabled and idle. - Expecting effects in the editor view. Effects show in play and in the editor’s Preview render mode only.
- Using post-processing for camera shake. Shake and recoil are camera effects; see Cameras.
In this section
Section titled “In this section”| Topic | Description |
|---|---|
| Colour effects | Sepia, Grayscale, Hue/Saturation and Vignette. |
| Stylize effects | Pixelation, ASCII, Dot Screen, Scanline, Noise and Glitch. |
| Light and lens effects | Bloom, Shock Wave and Lens Drops. |