Skip to content

renderPass()

ts
function renderPass<Context, U>(params: {
  gl?: WebGL2RenderingContext;
  target?: RenderTarget | null;
  fragment: string;
  vertex: string;
  attributes?: Record<string, Attribute>;
  blending?: "none" | "normal" | "additive";
  depthTest?: boolean;
  drawMode?:
    | "POINTS"
    | "LINES"
    | "LINE_STRIP"
    | "LINE_LOOP"
    | "TRIANGLES"
    | "TRIANGLE_STRIP"
    | "TRIANGLE_FAN";
  transformFeedbackVaryings?: string[];
  resolutionScale?: number;
  uniforms?: U;
}): RenderPass<U, Context>;

Creates a rendering pass that resolves functions, promises, and media uniforms before delegating the actual draw to rawRenderPass.

Type Parameters

Context

Context extends UniformContext

U

U extends UniformSources<Context>

Parameters

params

gl?

WebGL2RenderingContext

Optional WebGL2 context used to initialize the pass immediately.

Passes without a context are initialized by calling pass.initialize(gl) or using the compositor. Calling initialize() multiple times with the same context is a no-op.

target?

| RenderTarget | null

Optional initial render target for the pass. If not provided, it will render directly to the canvas or can be set later.

fragment

string

Fragment shader source code.

vertex

string

Vertex shader source code.

attributes?

Record<string, Attribute>

Mapping of attribute names to their data and configuration.

blending?

"none" | "normal" | "additive"

Blending mode to use for this pass.

Default

ts
"none";

depthTest?

boolean

Whether to enable depth testing.

Default

ts
false;

drawMode?

| "POINTS" | "LINES" | "LINE_STRIP" | "LINE_LOOP" | "TRIANGLES" | "TRIANGLE_STRIP" | "TRIANGLE_FAN"

WebGL draw mode.

Default

"POINTS" if gl_PointSize is found in the vertex shader, otherwise "TRIANGLES".

transformFeedbackVaryings?

string[]

Array of varying names for Transform Feedback.

resolutionScale?

number

Scaling factor applied to the resolution when the pass is resized.

Default

ts
1;

uniforms?

U

Uniform values, synchronous functions, promises, or media descriptors.

Returns

RenderPass<U, Context>

Released under the MIT License.