The Pass class serves as a base class for creating custom post-processing effects. To create a functional pass, you must extend this class and implement the render method.
Key properties for controlling pass behavior:
enabled: If true, the pass is processed by the composer.needsSwap: If true, the pass indicates that the read and write buffers should be swapped after rendering.clear: If true, the pass clears its buffer before rendering.renderToScreen: If true, the result is rendered directly to the screen (usually managed automatically by EffectComposer).
When implementing render, you must provide the following signature:
render(renderer: WebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget, deltaTime: number, maskActive?: unknown): void
import { Pass, WebGLRenderer, WebGLRenderTarget } from "@react-three/gpu-pathtracer";
class MyCustomPass extends Pass {
constructor() {
super();
this.clear = true;
}
render(
renderer: WebGLRenderer,
writeBuffer: WebGLRenderTarget,
readBuffer: WebGLRenderTarget,
deltaTime: number
) {
// Implementation of your post-processing effect
}
}