Skip to content

RenderPass<U>

ts
type RenderPass<U> = {
  render: (opts?: { target?: RenderTarget | null; clear?: boolean }) => void;
  target: RenderTarget | null;
  setTarget: (target: RenderTarget | null) => void;
  setSize: ({ width, height }: { width: number; height: number }) => void;
  uniforms: U;
  vertex: string;
  fragment: string;
  onUpdated: (callback: UpdatedCallback<U>) => void;
  onBeforeRender: (callback: RenderCallback<U>) => void;
  onAfterRender: (callback: RenderCallback<U>) => void;
  onInit: (callback: (gl: WebGL2RenderingContext) => void) => void;
  onResize: (callback: (width: number, height: number) => void) => void;
  initialize: (gl: WebGL2RenderingContext) => void;
};

A generic rendering pass that encapsulates shaders, uniforms, and attributes.

Type Parameters

U

U extends Uniforms = Record<string, never>

Properties

PropertyTypeDescription
render(opts?: { target?: | RenderTarget | null; clear?: boolean; }) => voidExecutes the render pass.
target| RenderTarget | nullThe current render target for this pass.
setTarget(target: | RenderTarget | null) => voidUpdates the current render target.
setSize({ width, height }: { width: number; height: number; }) => voidResizes the render target associated with this pass.
uniformsUThe reactive uniforms proxy for this pass.
vertexstringThe vertex shader source.
fragmentstringThe fragment shader source.
onUpdated(callback: UpdatedCallback<U>) => voidRegisters a callback called whenever uniforms are updated.
onBeforeRender(callback: RenderCallback<U>) => voidRegisters a callback called just before rendering.
onAfterRender(callback: RenderCallback<U>) => voidRegisters a callback called just after rendering.
onInit(callback: (gl: WebGL2RenderingContext) => void) => voidRegisters a callback called when the pass is initialized with a GL context.
onResize(callback: (width: number, height: number) => void) => voidRegisters a callback called when the pass is resized.
initialize(gl: WebGL2RenderingContext) => voidInitializes the pass with a WebGL2 context.

Released under the MIT License.