Skip to main content

Tilt Shift

Keep a chosen image-space line sharp while progressively blurring the surrounding scene. tiltShift creates a selective-focus miniature effect without requiring a scene depth texture.

GitHub

At a Glance

PropertyValue
ExporttiltShift
BackendsWebGPU and WebGL2
Render passesTwo directional fullscreen sampling passes
Additional inputsNone; focus is defined entirely in image space

Usage

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

const renderer = new ShaderPassRenderer(device, {shaderPasses: [tiltShift]});

renderer.renderToScreen({
sourceTexture: sceneColorTexture,
uniforms: {
tiltShift: {
start: [0.12, 0.36],
end: [0.88, 0.64],
blurRadius: 18,
gradientRadius: 130
}
}
});

Parameters

ParameterDefaultRangeDescription
start[0, 0]Normalized image coordinatesFirst endpoint of the line that remains in focus.
end[1, 1]Normalized image coordinatesSecond endpoint of the line that remains in focus.
blurRadius150 to 50Maximum blur radius in pixels away from the focal line.
gradientRadius2000 to 400Distance in pixels over which blur grows from zero to its maximum.

The focus model assumes the visible scene can be approximated by a planar image-space band. Objects at different real-world depths are not independently distinguished.

Composition and Cost

Tilt shift uses two directional sampling passes, with cost increasing as the selected blur radius grows. Choose Depth of Field when a real depth attachment is available and foreground/background distance should determine focus instead of a manually positioned line.