Skip to main content

EffectRenderer

EffectRenderer runs fullscreen effects from @luma.gl/engine. It allocates each effect’s intermediate textures and keeps history across frames. See the declarative effects guide for authoring, resource routing, and reusable configurations.

import {EffectRenderer} from '@luma.gl/engine';
import {bloomEffect, toneMappingEffect} from '@luma.gl/engine/effects';

const renderer = new EffectRenderer(device, {
effects: [bloomEffect, toneMappingEffect]
});

renderer.resize([width, height]);
renderer.render({sourceTexture, target: null});
device.submit();

The constructor takes an ordered list of EffectDefinition values or configured entries of the form {effect, options}. Each effect receives the preceding effect’s color output. Use colorFormat to set the intermediate color format, flipY to control source and presentation orientation, and shaderInputs to provide shared module inputs.

MethodBehavior
render(options)Records a frame. Omit target to get a borrowed texture, use null for the canvas, or supply a framebuffer. Presentation returns a boolean.
renderToTexture(options)Records a frame to a borrowed texture using the device encoder.
renderToScreen(options)Records a frame to the canvas using the device encoder.
encodeToTexture(encoder, options)Records a frame to a borrowed texture using the given encoder.
encodeToScreen(encoder, options)Records a frame to the canvas using the given encoder.
resize(size?)Resizes the intermediate textures. Defaults to the canvas drawing-buffer size.
resetHistory()Invalidates retained effect history after a camera cut or scene change.
destroy()Releases resources owned by the effect chain.

Frame options accept a Texture or DynamicTexture as sourceTexture, plus optional module-scoped uniforms, named bindings, and resetHistory. With render, you can also supply a commandEncoder. The caller submits the commands. A texture result can be reused by the renderer on subsequent frames.