Skip to content

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.

  • 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.
  • 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 with setProps and switched with setEnabled. See Components.
  • Tweens. Smooth fades of effect props use Tween.value. See Animation.
  • 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.

The simplest script adds a soft glow and darker edges to the camera, unless they were already added in the editor.

CameraLook.jx
#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 startup keeps that cost out of play.
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
GlobalWhat it is
BloomEffectComponentMakes bright parts of the image glow.
ShockWaveEffectComponentA 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.
LensDropsEffectComponentRaindrops 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.
PixelationEffectComponentDraws the image in large square pixels, like a retro game.
SepiaEffectComponentTints the image brown, like an old photograph.
GrayscaleEffectComponentRenders the image in black and white.
VignetteEffectComponentDarkens the edges of the image.
GlitchEffectComponentTears and shifts the image now and then, like a broken video signal.
CameraDirectorCut between cameras by name or id: switchTo(name), switchToMain(); current and main are the camera entities.
ComponentTypeWhat it does
Hue Saturation Effectcomp-hue-saturation-effectShifts the colours around the colour wheel and makes them duller or more vivid.
Sepia Effectcomp-sepia-effectTints the image brown, like an old photograph.
Grayscale Effectcomp-grayscale-effectRenders the image in black and white.
Vignette Effectcomp-vignette-effectDarkens the edges of the image.
Pixelation Effectcomp-pixelation-effectDraws the image in large square pixels, like a retro game.
Ascii Effectcomp-ascii-effectRedraws the image as text characters.
Dot Screen Effectcomp-dot-screen-effectRedraws the image as halftone dots, like print.
Scanline Effectcomp-scanline-effectHorizontal lines over the image, like an old screen.
Noise Effectcomp-noise-effectAnimated film grain over the image.
Glitch Effectcomp-glitch-effectTears and shifts the image now and then, like a broken video signal.
Bloom Effectcomp-bloom-effectMakes bright parts of the image glow.
Shock Wave Effectcomp-shock-wave-effectA ring that ripples the image outward from a world point, like a blast, set off by a script.
Lens Drops Effectcomp-lens-drops-effectRaindrops on the camera lens that land, slide down and dry off.

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, an intensity of 0, or Lens Drops’ play() and clear().
  • 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 setEnabled in 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.
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.