TextureTransform
TextureTransform is the engine helper for texture-to-texture transform passes.
It builds an internal GPUVectorModel, manages a framebuffer for the target texture, and renders into that texture.
TextureTransform is currently exported but marked deprecated in source.
Usage​
import {TextureTransform} from '@luma.gl/engine';
const transform = new TextureTransform(device, {
vs: VERTEX_SHADER,
targetTexture,
targetTextureChannels: 4,
targetTextureVarying: 'outColor',
sourceTextures: {
sourceTexture
}
});
transform.run();
GPU vector inputs​
Supply inputVectors at construction or in run({inputVectors}) to bind borrowed,
contiguous GPU vectors by buffer-layout name. Input row count sets vertex count and
chunk byte offsets are preserved. Buffer layouts are explicit. Each input vector must have at most one chunk.
For multi-chunk inputs, callers must bind and run each chunk separately. The output is targetTexture.
Types​
TextureTransformProps​
export type TextureTransformProps = Omit<GPUVectorModelProps, 'fs'> & {
fs?: GPUVectorModelProps['fs'];
inputVectors?: GPUVectorModelInputs;
inject?: Record<string, string>;
framebuffer?: Framebuffer;
sourceBuffers?: Record<string, Buffer>;
sourceTextures?: Record<string, Texture>;
targetTexture: Texture;
targetTextureChannels: 1 | 2 | 3 | 4;
targetTextureVarying: string;
};
inject, framebuffer, sourceBuffers, and sourceTextures are retained mainly for backward compatibility and are marked deprecated in source comments.
Properties​
device, model, sampler​
Owning device, internal fullscreen model, and sampler used for source textures.
bindings​
Internal binding state for the active transform setup.
Methods​
constructor(device: Device, props: TextureTransformProps)​
Creates the internal model and framebuffer binding state.
destroy(): void​
Destroys the internal model and any owned framebuffers.
delete(): void​
Deprecated alias for destroy().
run(options?: RenderPassProps): void​
Renders one pass into the current target texture framebuffer.
getTargetTexture(): Texture​
Returns the current output texture.
getFramebuffer(): Framebuffer | undefined​
Returns the framebuffer currently used as the render target.
Remarks​
- The default fragment shader is automatically synthesized from
targetTextureVaryingandtargetTextureChannelswhenfsis omitted. - For new work, prefer more explicit render-pass or compute abstractions when possible.