Skip to main content

Declarative fullscreen effects

See Scene attachments for effects for capture, graph integration, and temporal history.

An effect definition is a typed object you can export from a module and reuse with multiple renderers. It describes the textures and draws needed for an effect. EffectRenderer allocates the textures, runs the passes, and manages history. The API is a prototype for fullscreen processing of rendered scene textures.

Apply effects to a scene​

Render the scene to sampleable color and depth textures. If you use shadow maps, render those and bind them to the scene materials during scene shading. The fullscreen stack then processes the shaded scene color.

import {EffectRenderer} from '@luma.gl/engine';
import {bloomLow, ssao} from '@luma.gl/engine/effects';

const effects = new EffectRenderer(device, {
effects: [ssao, bloomLow],
colorFormat: 'rgba16float'
});

effects.resize([width, height]);

// Run after scene rendering on each frame.
effects.renderToScreen({
sourceTexture: sceneColor,
bindings: {depthTexture: sceneDepth},
uniforms: {
ssaoEvaluate: {nearPlane: 0.1, farPlane: 200},
bloomComposite: {intensity: 0.75}
}
});

The effects run in array order. SSAO samples the scene depth and updates the color image. Bloom reads that updated image and adds glow. Use renderToTexture when another stage needs to sample the result. Call resize when the output dimensions change and destroy when the stack is no longer needed. The scene supplies and owns the input textures.

To use camera-reprojection TAA, add cameraReprojectionTaa between SSAO and bloom. Supply the camera matrices and jitter each frame as cameraReprojectionTaaResolve uniforms. After a camera cut, call resetHistory() before rendering the next frame. See the camera-reprojection shader definition for its camera uniform types.

The other fullscreen definitions include motionBlur, taa, and depthOfField. Motion blur and standard TAA use the scene velocity texture. Depth of field uses scene depth and camera and lens uniforms. Use depthOfField for separable blur or bokehDofEffect for a circular aperture. depthAwareBlurEffect runs horizontal and vertical filtering with scene depth and preserves edges across depth discontinuities. For a display-ready chain, place toneMappingEffect after HDR bloom and fxaaEffect after tone mapping.

Finish camera output​

The effects below run on WebGPU and WebGL and retain the input alpha. A typical chain applies HDR bloom, tone mapping, grading, antialiasing or sharpening, and finally output dithering.

  • lutColorGradingEffect reads the caller-owned colorLut texture. Pack an N³ LUT into an N² by N texture, with red advancing across each slice, green advancing down the rows, and blue selecting the horizontal slice. The shader interpolates across all three axes. Use a numeric format such as rgba8unorm or rgba16float so GPU sRGB decoding does not alter LUT entries. The LUT author defines the input and output color spaces. The effect applies no transfer function and clamps lookup coordinates to [0, 1]. Set options.intensity to blend with the input.
  • sharpenEffect uses a five-tap neighborhood with bounded overshoot and keeps coverage edges intact. Set options.strength from zero to one.
  • chromaticAberrationEffect shifts red and blue in opposite radial directions over the full image. options.amount controls each channel's displacement in source pixels at a corner (default two). The offset fades to zero at the center. Green and alpha stay at the original sample. Place it before output dithering.
  • outputDitheringEffect uses a stable 4 × 4 ordered pattern. Set options.bitDepth to the target RGB precision, from one to sixteen (default eight). Run it at output resolution after the display transfer function when targeting encoded RGB. Use a non-sRGB destination for already encoded colors. The pass quantizes RGB and leaves alpha intact.

Apply a decoded color lookup table​

Use a 3D cube to map RGB jointly, or a 1D shaper to map channels separately. Adobe Cube files can contain either table. Resolve-style files can contain both, with the shaper applied first. Decode files with the loaders.gl Cube loader. The renderer consumes the resulting numerical samples and domain metadata.

packColorLut fills a numeric texture without converting its color space or clipping the samples. Pass device.limits.maxTextureDimension2D. The packer uses the original single-row slice layout when it fits and adds tile rows for wider tables. Set lutSize or shaperSize to the decoded size when a table spans multiple rows.

import {load} from '@loaders.gl/core';
import {CubeLUTLoader} from '@loaders.gl/images/color-lut';
import {EffectRenderer} from '@luma.gl/engine';
import {lutColorGradingEffect, packColorLut} from '@luma.gl/engine/effects';

const lookup = await load('look.cube', CubeLUTLoader);
const cube = lookup.dimension === 3 ? lookup : undefined;
const shaper = cube ? cube.shaper : lookup;
const maxTextureDimension = device.limits.maxTextureDimension2D;
const asDomain = ([red, green, blue]: readonly number[]) => [red, green, blue] as const;

const colorLut = cube && device.createTexture(packColorLut(cube.data, {
size: cube.size, maxTextureDimension
}));
const colorLutShaper = shaper && device.createTexture(packColorLut(shaper.data, {
dimension: 'shaper', size: shaper.size, maxTextureDimension
}));

const grade = new EffectRenderer(device, {
effects: [{
effect: lutColorGradingEffect,
options: {
mode: cube ? (shaper ? 'shaper-cube' : 'cube') : 'shaper',
interpolation: 'tetrahedral',
lutSize: cube?.size,
domainMin: cube && asDomain(cube.domainMinimum),
domainMax: cube && asDomain(cube.domainMaximum),
shaperSize: shaper?.size,
shaperDomainMin: shaper && asDomain(shaper.domainMinimum),
shaperDomainMax: shaper && asDomain(shaper.domainMaximum)
}
}]
});
grade.resize([width, height]);
const gradedColor = grade.renderToTexture({
sourceTexture: sceneColor,
bindings: {...(colorLut && {colorLut}), ...(colorLutShaper && {colorLutShaper})}
});

For Adobe Cube, select tetrahedral interpolation for the 3D stage. The 1D stage uses linear interpolation. Integer textures with normalized formats already give the shader input values on a zero-to-one scale. Supply each table's authored input domain. Values outside that domain use the nearest endpoint. Choose a floating-point output when retaining HDR values, and destroy both borrowed lookup textures when done.

Smooth jagged edges with SMAA​

Subpixel Morphological Antialiasing (SMAA) detects jagged edges in a rendered image, measures their shapes, and blends neighboring pixels to smooth the stair steps. SMAA 1× works on a single frame without motion vectors or history. It is useful for map lines, labels, and thin geometry.

smaaEffect runs three passes on WebGPU and WebGL. This implementation uses the reference Medium preset's orthogonal path. Use it in place of FXAA at output resolution, after tone mapping and before output dithering.

Loading interactive example…

Add {effect: smaaEffect, options: {threshold: 0.1}} to the effect chain. Supply the reference lookup tables as bindings named smaaAreaTexture (160 × 560, rg8unorm) and smaaSearchTexture (64 × 16, r8unorm). Upload the raw table bytes in their original row order and use linear clamp-to-edge sampling for both. The example loader shows the upload.

Sharpen and inspect spatial detail​

Use these effects on normalized RGB after tone mapping. Each preserves source alpha and avoids adding colored detail across a change in coverage.

  • Bounded sharpening stays the default for sharpenEffect. Its five samples are suitable for crisp labels and other fine edges.
  • Unsharp Mask is an optional mode of sharpenEffect. It subtracts a separable Gaussian blur and adds that difference back to the source. Set the radius in source pixels, adjust the strength, and raise the threshold to suppress weak detail such as noise.
  • Local Contrast adjusts each pixel according to the luminance of its neighborhood. Use a wider radius than for edge sharpening and adjust the strength to shape larger tonal transitions.
  • High Pass displays the difference from the blurred image. Flat regions map to neutral gray by default. Use it to inspect a frequency band or as a starting texture for a later compositing stage.
import {sharpenEffect} from '@luma.gl/engine/effects';

const unsharp = {
effect: sharpenEffect,
options: {mode: 'unsharp-mask', radius: 8, strength: 0.45, threshold: 0.03}
} as const;
Loading interactive example…

Adjust image levels​

Add levelsEffect to adjust normalized RGB. Each channel maps its input black point to its output black point and its input white point to its output white point. Gamma above one brightens the midtones. Use equal components to apply the same adjustment to all three channels. Use it after tone mapping for display-referred adjustments. The effect preserves alpha.

import {levelsEffect} from '@luma.gl/engine/effects';

const levels = {
effect: levelsEffect,
options: {
inputBlack: [0.06, 0.06, 0.06],
inputWhite: [0.92, 0.92, 0.92],
gamma: [1.15, 1, 0.94]
}
} as const;
// Include levels in the EffectRenderer effects array.
Loading interactive example…

Grade color and recover tonal detail​

  • Curves uses a caller-owned curveTexture. Pack equally spaced input samples across the width of a numeric RGBA texture with one row. Store the red, green, and blue response curves in RGB. Optionally store the master curve in alpha and enable options.useMaster to apply it first. Use a linear clamp sampler. The output preserves the source image alpha.
  • Lift, Gamma, Gain adjusts shadows, midtones, and overall channel levels in that order. Lift tapers to zero at white. Gamma above one brightens midtones. Gain multiplies the result. Set the same values in all three channels for global controls, or vary them to adjust the color balance.
  • Shadows and Highlights uses the blurred local luminance to decide where to lift shadows or reduce highlights. The final pass adjusts the full-resolution color. Use this effect on normalized RGB after tone mapping. Set the radius in half-resolution texels.
import {curvesEffect, liftGammaGainEffect, shadowsHighlightsEffect} from '@luma.gl/engine/effects';

const grading = [
{effect: liftGammaGainEffect, options: {gamma: [1.1, 1, 0.95]}},
{effect: shadowsHighlightsEffect, options: {shadows: 0.2, highlights: 0.15}},
{effect: curvesEffect, options: {useMaster: true}}
] as const;
// Pass grading to EffectRenderer, and bind curveTexture on the frame.
Loading interactive example…

Apply glfx image filters​

Loading interactive example…

Import sepiaEffect, vignetteEffect, or another glfx definition from @luma.gl/engine/effects and add it to the stack. Use uniforms keyed by the shader name, for example uniforms: {sepia: {amount: 0.6}}.

CategoryDefinitions
AdjustbrightnessContrastEffect, denoiseEffect, hueSaturationEffect, noiseEffect, persistence, sepiaEffect, vibranceEffect, vignetteEffect
BlurbloomEffect, gaussianBlurEffect, tiltShiftEffect, triangleBlurEffect, zoomBlurEffect
StylizecolorHalftoneEffect, dotScreenEffect, edgeWorkEffect, hexagonalPixelateEffect, inkEffect, magnifyEffect
WarpbulgePinchEffect, swirlEffect

Use bloomEffect for the simple image filter and bloomLow for the HDR pyramid. Separable and repeated glfx filters declare both draws and reuse the shared color chain between them.

Stylize and warp images​

These effects use the same fullscreen stack as the camera effects and run on WebGPU and WebGL.

  • Threshold turns the image black and white using Rec. 709-weighted luma in the input encoding. Set options.threshold from zero to one. Pixels at or above the cutoff become white. Alpha passes through.
  • Posterize rounds each normalized RGB channel to a fixed number of levels, including black and white. Set options.levels from two to 256. To posterize display colors, apply it after tone mapping.
  • Displacement Map shifts where the source image and alpha are sampled. Supply a numeric 2D texture as the displacementTexture binding. Red and green encode horizontal and vertical source offsets. Half intensity is neutral, with zero and one representing the negative and positive limits. Set options.scale in source pixels. For a smooth warp, use a linear sampler on the map.
import {EffectRenderer} from '@luma.gl/engine';
import {displacementMapEffect, posterizeEffect} from '@luma.gl/engine/effects';

const renderer = new EffectRenderer(device, {
effects: [
{effect: displacementMapEffect, options: {scale: [24, 12]}},
{effect: posterizeEffect, options: {levels: 5}}
]
});

renderer.resize([width, height]);
renderer.renderToScreen({sourceTexture, bindings: {displacementTexture}});
Loading interactive example…
Loading interactive example…
Loading interactive example…

Style an alpha layer​

Apply bevelEffect to add a highlight and shade along opposite sides of an alpha edge. The radius sets the edge width in source pixels. Strength controls the amount of shading, and angle gives its direction in radians.

Add dropShadowEffect to blur the layer's alpha, translate it, and composite a tinted shadow behind the image. Set the radius, offset, opacity, and color independently. Leave transparent space around the layer for the shadow. For per-frame shadow controls, set the radius under uniforms.dropShadowBlur and the offset, opacity, and color under uniforms.dropShadow. Both effects take straight-alpha color and return straight-alpha color. When stacking both, apply bevel first so it shades the source layer's edge.

import {bevelEffect, dropShadowEffect} from '@luma.gl/engine/effects';


const layerEffects = [
{effect: bevelEffect, options: {radius: 4, strength: 0.4, angle: -0.7}},
{effect: dropShadowEffect, options: {radius: 12, offset: [10, 8], opacity: 0.65}}
] as const;
Loading interactive example…
Loading interactive example…

Configure an effect​

Set an effect entry’s options field for settings that affect resources or pass order. The renderer resolves the definition once at construction. Keep animated controls in the render call’s uniforms so they can change without reallocating those resources.

import {EffectRenderer} from '@luma.gl/engine';
import {hdrBloom, ssaoEffect, ssr} from '@luma.gl/engine/effects';

const renderer = new EffectRenderer(device, {
effects: [
{effect: ssaoEffect, options: {normalSource: 'normal-texture', resolutionScale: 0.5}},
{effect: ssr, options: {reprojection: 'camera', quality: 'fast'}},
{effect: hdrBloom, options: {quality: 'ultra', downsample: 'auto'}}
],
colorFormat: 'rgba16float'
});

Supply each effect's scene bindings at render time. SSAO in normal-texture mode needs the normal texture in addition to depth. Camera-reprojected SSR also needs camera uniforms. HDR bloom automatically selects fused compute on eligible WebGPU devices. Its fragment alternative produces the same named pyramid levels for the shared downstream passes.

The configurable catalog also includes outlines, selectionOutlineEffect, gtao, ssgi, hdrAutoExposure, volumetricFog, clusteredVolumetricLighting, and contactShadows. Use the heightFog definition for analytic fog with frame uniforms, or configure volumetricFog with {mode: 'height'}. Selection outlines sample a caller-provided selectionTexture mask.

Run compute pipelines​

A ComputePipelineDefinition is an ordered list of compute passes and reusable GPU operations. Each compute pass lists its kernels, maps shader binding names to named resources, and calculates dispatch dimensions from frame state. encodeComputePipeline resolves those bindings and records the passes into the caller's command encoder. Keep buffer and texture allocation in the renderer that owns them.

GPUConvolutionBloom executes fftBloomPipeline from @luma.gl/graph/gpu-effects. The definition makes highlight extraction, forward FFT, spectral multiplication, inverse FFT, and HDR composition explicit. The optical kernel transform runs only when its cached spectrum needs updating. FFTs reuse their existing compiled command graphs.

ClusteredLightGrid executes clusteredLightGridPipeline from @luma.gl/engine/lighting. Its clear, bin, and compact dispatches share one compute pass. Deferred and volumetric lighting continue to consume the resulting light counts and indices through the grid's bindings.

Capture scene geometry​

A SceneCapturePassDefinition names a framebuffer, declares attachment clear and depth settings, and supplies synchronous preparation and geometry hooks. encodeSceneCapturePass prepares GPU resources, opens the render pass, invokes the draw, and closes the pass. The scene supplies and owns the framebuffers and their texture attachments.

  • shadowMapCapturePass in @luma.gl/engine/lighting runs with the depth attachment view for each directional cascade, spot light, or point cube face.
  • deferredGBufferCapturePass in @luma.gl/anari clears the scene's MRT and depth attachments and returns the recorded draw count.
  • wboitCapturePasses records opaque depth, weighted accumulation, and revealage in that order. Both translucent passes reuse opaque depth.
  • aBufferCapturePass resets the head pointers and scissor before drawing a slice. The renderer resolves that slice before reusing its buffers.

Preparation and draw hooks let the scene supply view-specific models and bindings. The capture outputs remain available to the existing shadow sampling and fullscreen resolve stages.

Produce visibility textures for lighting​

ambientOcclusionVisibilityEffect and contactShadowVisibilityEffect in @luma.gl/engine/lighting generate visibility for a later lighting pass. Each effect traces visibility and filters it in two directions using depth and normals. The final output is a visibility texture that can be sampled from its red channel.

For scene lighting, use AmbientOcclusionPass or ContactShadowPass to size the renderer from the inputs, set the camera uniforms, and get a borrowed RGBA8 texture. Callers own the depth and normal textures. The pass owns its output and may overwrite it on the next render. Ambient occlusion requires WebGPU unless its mode is none, which returns a white texture.

To run either definition directly, configure it in EffectRenderer, set colorFormat: 'rgba8unorm', and call renderToTexture with camera uniforms, the normal texture as the source, and depthTexture and normalTexture bindings. Run visibility generation before the lighting pass that samples it.

Upscale with temporal history​

The experimental WebGPU TemporalUpscaler records two named framebuffer passes. Accumulation writes both HDR color and auxiliary history in one draw. Sharpening reads the new color and writes the caller's output framebuffer. Both use the same pass encoder as scene capture, which supports multiple attachments. The upscaler manages its ping-pong framebuffers and only advances history after both passes have been recorded.

Call resetHistory() after a camera cut. Call setSize() when the input or output dimensions change. Submit pending work before rendering another frame, resizing, or destroying the upscaler.

Add glow, lens artifacts, and light shafts​

Use these effects after scene rendering and before tone mapping. Each adds a light contribution to the color chain and preserves scene alpha. Use a floating-point color format for HDR highlights. The effects use half-resolution intermediates and a full-resolution composite.

  • Selective Glow blurs the RGB field supplied as highlightTexture. Write zero RGB outside selected or emissive regions. The effect uses the Gaussian Blur shader on both axes and ignores the highlight alpha. Set the radius in half-resolution texels and use intensity to scale the additive contribution.
  • Lens Flare reads the same highlight binding and uses the ghost, halo, and diffraction shader from HDR bloom. Set those intensities in the effect options. Supply prefiltered highlights appropriate for the desired flare size. The effect can run independently of bloom.
  • Light Shafts marches 16 samples per half-resolution pixel toward a projected light in top-left UV coordinates. Bind lightShaftsMask with visible light in red and zero behind occluders. Use decay and density to control the contribution and travel distance. The mask supplies the visibility information, so offscreen occluders require a different technique.
import {EffectRenderer} from '@luma.gl/engine';
import {lensFlareEffect, lightShaftsEffect, selectiveGlowEffect} from '@luma.gl/engine/effects';

const renderer = new EffectRenderer(device, {
colorFormat: 'rgba16float',
effects: [
{effect: selectiveGlowEffect, options: {radius: 12, intensity: 0.7}},
{effect: lensFlareEffect, options: {ghostIntensity: 0.4}},
{effect: lightShaftsEffect, options: {lightPosition: [0.65, 0.36]}}
]
});

renderer.resize([width, height]);
const litColor = renderer.renderToTexture({
sourceTexture: sceneColor,
bindings: {highlightTexture, lightShaftsMask}
});
Loading interactive example…

Resolve scene buffers​

ANARI exposes fullscreen definitions for deferred direct lighting, ambient lighting, clustered deferred lighting, weighted blended transparency, and A-buffer transparency. Import them from @luma.gl/anari.

import {EffectRenderer} from '@luma.gl/engine';
import {clusteredDeferredLightingEffect} from '@luma.gl/anari';

const lighting = new EffectRenderer(device, {
effects: [clusteredDeferredLightingEffect],
colorFormat: 'rgba16float'
});

lighting.resize([width, height]);
const litColor = lighting.renderToTexture({
sourceTexture: gBuffer.colorTexture,
bindings: {...gBuffer.getBindings(), ...clusteredLightBindings},
uniforms: lightingUniforms
});

The scene renderer supplies and owns the G-buffer or transparency captures. The resolve samples those resources and writes the color result. For A-buffer resolve, use {effect: aBufferResolveEffect, options: {maxFragmentsPerPixel}} and match the limit used to capture fragments. The higher-level A-buffer, weighted blended transparency, and deferred scene renderers wire their own inputs automatically.

Author an effect​

Start with a fullscreen shader that follows the shader pass convention. Declare a pass for each draw and route each shader's inputs to the textures it samples. Use as const satisfies EffectDefinition<...> to check the definition while preserving its literal names and pass structure. This example adjusts contrast and then applies a vignette, reusing two built-in shaders.

import type {EffectDefinition} from '@luma.gl/engine';
import {brightnessContrast, vignette} from '@luma.gl/engine/effects';

export const softVignette = {
name: 'softVignette',
resources: {
adjusted: {}
},
passes: [
{
kind: 'fullscreen',
shaderPass: brightnessContrast,
inputs: {sourceTexture: 'previous'},
output: 'adjusted',
uniforms: {contrast: 0.15}
},
{
kind: 'fullscreen',
shaderPass: vignette,
inputs: {sourceTexture: 'adjusted'},
output: 'previous'
}
]
} as const satisfies EffectDefinition<'adjusted'>;
  • Resources are private to each occurrence of the effect. Set the texture format and scale when the default format or full resolution is unsuitable. EffectDefinition<...> checks that named targets are declared.
  • Inputs map shader binding names to textures. previous reads the current color chain and original reads the input to the entire stack. Supply scene textures such as depth in the render call's bindings.
  • Outputs select a named target or update the shared color chain with previous. Set per-pass defaults in uniforms and apply per-frame overrides by shader module name in the render call.
  • History uses lifetime: 'history'. Specify how to initialize the texture on the first frame or after a reset. A pass can read the previous frame and write the current frame using the same history target name.

Offer a WebGPU implementation with a fragment fallback​

Put the two implementations in initialPasses, then list their shared downstream draws in passes. Bloom declares half- and quarter-resolution extraction textures. Its compute branch writes both in one dispatch. Its fragment branch extracts highlights at half resolution, then downsamples to quarter resolution. Both feed the same blur and reconstruction passes.

For your own compute variant, map each storage binding to a named output and mark those resources with storage: true. The first output's dimensions determine the dispatch grid. The renderer checks WebGPU, storage-format support, binding limits, and workgroup dimensions. On other devices it runs the fragment sequence. Both paths should populate every resource the shared passes read.

Temporal frame conventions​

Supply projection jitter in top-left UV units. Divide jitter in render pixels by the render width and height to convert it. Motion vectors point from the previous unjittered position to the current unjittered position, in UV units. Subtract the motion vector from the current unjittered UV to find the previous position. Apply previous jitter only when sampling history stored in jittered coordinates.

The velocity-based TAA effect takes motion from the scene. Camera-reprojection TAA derives it from current depth and unjittered camera matrices. Supply hardware depth from the same view used to render the current color. Reset history after a camera cut, scene replacement, or a change in resolution that invalidates history.

Record a frame with EffectRenderer​

Use render({sourceTexture, target: null}) to draw to the canvas. Supply a framebuffer as target to draw into it, or omit target to return the output texture. The returned texture is borrowed. A later draw, resize, or destruction can overwrite or invalidate it. Rendering records commands without submitting. Use commandEncoder to record into a caller-owned encoder on the same device.

Set resetHistory: true on the first frame after a camera cut. Scene depth, normals, prepared light textures and buffers, and uniform values can change on each call.

A filter can reference its shader module directly:

const sepiaEffect = {
name: 'sepia',
passes: [{kind: 'filter', module: sepia}]
} as const satisfies EffectDefinition;

const renderer = new EffectRenderer(device, {
effects: [
{effect: ssaoEffect, options: {normalSource: 'normal-texture', resolutionScale: 0.5}},
{effect: sepiaEffect}
]
});

The sepia amount remains a shader uniform. SSAO resolves its target scales and normal-source pass sequence from its definition when the renderer is created.

Share a resolution option or select a variant​

Use optionDefaults to give construction options default values. Use scaleResources when several targets should follow one resolution option. SSGI and clustered volumetric lighting use this to keep their evaluation, history, and filter textures at the same relative size.

Use variants when an option selects a different set of passes or resources. Each value replaces the listed fields for that instance. A value without an entry uses the base definition. For example, volumetricFog uses screen-space passes and a history texture by default. Set the effect's mode option to 'height' to use the analytic pass without allocating a fog history texture.

Apply presets and initialize history​

An option can supply a scale or a uniform default directly, or select a value from a table. For SSR, an explicit resolutionScale takes precedence over the quality preset. The camera reprojection variant allocates full-resolution normal and depth history while the reflection buffers use the selected scale.

HDR auto exposure uses fixed scale factors for the luminance reduction levels. Its history descriptor seeds the exposure value from initialExposure after creation, resize, or history reset. Per-frame uniforms still control adaptation and override construction-time uniform defaults.

Run effects in a GPU graph​

Use the same effect entries in the WebGPU graph. Declare a graph texture input, give the effect operation named shader bindings and an output, and install the engine lowering in the graph compiler.

import {GPUGraph, gpuGraph} from '@luma.gl/graph';
import {GPUEffectOperation, effectOperationLowering, sepiaEffect} from '@luma.gl/engine/effects';

const graph = new GPUGraph();
graph.addInput('sceneColor', gpuGraph.texture({format: 'rgba8unorm'}));
graph.add(new GPUEffectOperation({
input: 'sceneColor',
output: 'filteredColor',
outputDescriptor: gpuGraph.texture({
format: 'rgba8unorm',
extent: {like: 'sceneColor'}
}),
effects: [sepiaEffect],
uniforms: {sepia: {amount: 0.6}}
}));

const compiled = graph.compile(device, {lowerings: [effectOperationLowering]});

Call run for submission or prepare to bind logical textures for a caller-owned command encoder. Other graph operations can consume the named result. Effect options, pass ordering, and compute fallback selection use the same plan as EffectRenderer. The graph tracks each draw and dispatch with its texture uses, so effect-local scratch textures can be reused across passes when lifetimes allow. Use the command graph integration below for velocity TAA. Use GPUCommandEffectOperation on a command graph to bind retained roles to effect occurrences.

For WebGL, use createEffectRenderOperation from @luma.gl/engine/effects with the device-bound GPUSimpleGraph. Give it caller-owned input and output textures and register it with graph.addRenderOperation. This path uses the same fullscreen plan and fragment fallback as the WebGPU graph. Choose effects with GLSL implementations. The graph owns any transient scratch textures and borrows the input, output, and optional shader bindings.

Use appendEffects(graph, props) to connect a stack and pass its logical color result to the next operation. An entry can attach its own bindings and uniforms, so two occurrences of the same definition can sample different graph textures or use different values. Supply a named depth or normal output from a scene render operation just as you would supply a named imported texture. Select the final color as a graph output and bind a caller-owned destination through prepare({outputTargets}) when recording the frame.

The portable operation also accepts per-occurrence overrides. Its bindings refer to caller-owned textures, while named graph operations refer to graph texture names.

Retain temporal history in a WebGPU command graph​

Use addGraphTAA when the scene already records color, hardware depth, and velocity in a WebGPU GPUCommandGraph. It lowers the same velocity TAA definition used by EffectRenderer. The graph tracks the previous history as a sampled input and the current history as a render attachment. Within the same encoding, later passes see the written current color.

Create two GPUTextureHistory pairs at the render resolution. Use the resolved output format for color and rgba16float for packed hardware depth. Both pairs need Texture.SAMPLE | Texture.RENDER. Import them once and bind their current physical roles for each encoding.

import {
addGraphTAA,
importTemporalGraphHistory,
type TemporalFrame
} from '@luma.gl/engine/effects';
import {GPUCommandGraph, GPUTextureHistory} from '@luma.gl/graph/gpu-core';
import {Texture} from '@luma.gl/core';

const graph = new GPUCommandGraph<TemporalFrame>(device);
const usage = Texture.SAMPLE | Texture.RENDER;
const colorHistory = new GPUTextureHistory(device, {width, height, format: 'rgba16float', usage});
const depthHistory = new GPUTextureHistory(device, {width, height, format: 'rgba16float', usage});
const colorRoles = importTemporalGraphHistory(graph, 'taa-color', colorHistory);
const depthRoles = importTemporalGraphHistory(graph, 'taa-depth', depthHistory);

// These views come from the scene and output operations in the same graph.
addGraphTAA(graph, {
id: 'taa',
input: sceneColor,
depth: sceneDepth,
velocity: sceneVelocity,
output: resolvedColor,
colorHistory: colorRoles,
depthHistory: depthRoles
});
const compiled = graph.compile();

function renderFrame(frame: TemporalFrame) {
const encoder = device.createCommandEncoder();
try {
compiled.encode(encoder, {
parameters: frame,
textures: {...colorRoles.getBindings(), ...depthRoles.getBindings()}
});
device.submit(encoder.finish());
colorHistory.advance();
depthHistory.advance();
} finally {
encoder.destroy();
}
}

Pass jitter in top-left UV units relative to the render resolution. Motion XY is unjittered current UV minus previous UV. Set resetHistory: true on the first frame and after a camera cut. TAA still writes both current histories on a reset frame, so the next frame can reuse them. If an encoding is discarded, leave both roles unchanged. Rebuild the graph and its history pairs on resize, and destroy the compiled graph before releasing the pairs.

How the WebGPU upscaler fits​

Use TemporalUpscaler.addToGraph() to schedule the same accumulation and sharpening kernels in a WebGPU command graph. Create output-sized GPUTextureHistory pairs with sampled and render-attachment usage. Use rgba16float for accumulated color and rg16float for the auxiliary depth and weight. Import both pairs with importTemporalGraphHistory().

upscaler.addToGraph(graph, {
color: sceneColor,
depth: sceneDepth,
velocity: sceneVelocity,
colorHistory: upscaleColor,
auxiliaryHistory: upscaleAuxiliary,
output: presentationColor
});

const compiled = graph.compile();
// During each frame:
compiled.encode(commandEncoder, {
parameters: {currentJitter, resetHistory, sharpness: 0.25},
textures: {...upscaleColor.getBindings(), ...upscaleAuxiliary.getBindings()}
});

Set resetHistory on the first frame and camera cuts. After submitting the frame, advance both physical history pairs together. Accumulation reads both previous views and writes both current views as MRT attachments. Sharpening samples current color and writes the output. The velocity texture uses the shared XY convention and supplies expected previous depth and validity in Z/W. Recreate the compiled graph and history pairs after resizing.

Chain graph GTAO and SSGI​

GPUCommandEffectOperation accepts the same effect definitions and construction options as EffectRenderer. Each occurrence can bind previous/current history roles by resource name, map shader uniforms to named frame fields, and override uniforms on reset. These mappings also work for custom effects.

For GTAO and SSGI, use full-resolution hardware depth, normals, and motion (current minus previous unjittered UV). Use rgba8unorm for AO history and rgba16float for indirect radiance and both packed depth histories. Size each pair from the effect's resolutionScale using rounded dimensions with a minimum of one pixel.

graph.add(new GPUCommandEffectOperation({
id: 'screen-space-lighting',
input: sceneColor,
output: litColor,
bindings: {depthTexture: depth, normalTexture: normals, velocityTexture: velocity},
effects: [
{
effect: gtao,
options: {resolutionScale: 0.5},
history: {gtaoHistory: aoHistory, gtaoHistoryDepth: aoDepthHistory},
frameUniforms: {gtaoEvaluate: traceUniforms, gtaoTemporal: temporalUniforms},
resetUniforms: {gtaoTemporal: {historyWeight: 0}}
},
{
effect: ssgi,
options: {resolutionScale: 0.5},
history: {ssgiHistory: indirectHistory, ssgiHistoryDepth: indirectDepthHistory},
frameUniforms: {ssgiTrace: traceUniforms, ssgiTemporal: temporalUniforms},
resetUniforms: {ssgiTemporal: {historyWeight: 0}}
}
]
}));

Map the trace uniforms to frame fields for projection, inverse projection, and sampling index. Map the temporal uniforms to inverse projection and both jitter values. Supply all four history pairs' bindings to each encoding and advance them together after submission.

Retain screen-space reflections in a graph​

Add ssr to a GPUCommandEffectOperation with the same scene color, hardware depth, and normal/roughness views used for direct rendering. Use the quality preset or resolutionScale to choose the tracing resolution.

  • For reprojection: 'velocity', bind motion in unjittered top-left UV units, current minus previous. Map currentJitter and previousJitter to ssrTemporal. Use two trace-sized rgba16float pairs named ssrHistory and ssrHistoryDepth.
  • For reprojection: 'camera', map the current-to-previous clip and view transforms and previous inverse projection to ssrCameraTemporal. The clip transform must match the jittered depth projections when jitter is enabled. Use trace-sized rgba16float reflection history plus full-resolution rgba8unorm pairs for packed depth and ssrHistoryNormal.
  • Map projection and inverse projection to ssrTrace, and map inverse projection to ssrSpatial and ssrComposite. Set the active temporal module's historyWeight to zero in resetUniforms. Bind and advance all retained pairs together after submission.