Documentation
    Preparing search index...

    Class ShaderGraphBuilder

    Builds a ShaderGraph node by node — the domain-agnostic base. "surface" authors normally use NodeMaterialBuilder, which adds texture-value collection and NodeMaterialBuilder.build; "screen" authors build a §70 GraphEffect's graph here:

    const screen = new ShaderGraphBuilder("screen");
    const texel = screen.sampler("source");
    screen.output.color = texel.multiply([0.5, 0.5, 0.5, 1]);
    const effect = { kind: "graph", graph: screen.graph() } as const;

    Hierarchy (View Summary)

    Index
    collectedTextures: Record<string, MaterialTexture>

    Texture values collected by ShaderGraphBuilder.texture.

    domain: ShaderDomain

    Which stage inputs this graph may name — fixed at construction.

    The output slots — builder.output.color = … (RFC 0001's spelling).

    • get nodeCount(): number

      How many nodes the graph holds so far.

      Returns number

    • A vertex attribute (§60 "vertex attributes") — R-19's four fixed streams in a "surface" graph; in a "screen" graph only "uv", the pass's own normalized coordinate (see ShaderAttributeName).

      Parameters

      Returns ShaderExpression

    • A constant. A number is a float; an array of 2–4 numbers is the matching vector; 9 or 16 numbers are mat3/mat4 (column-major, as Matrix4.elements is laid out).

      Parameters

      • value: number | readonly number[]

      Returns ShaderExpression

    • Snapshots the built graph — nodes in creation order, outputs resolved — and validates it (analyzeShaderGraph, §85: a broken graph is refused here, where the code that built it is on the stack).

      Returns ShaderGraph

      RangeError when no colour output was assigned, or when the graph breaks any §60 IR rule.

    • Samples the named sampler at uv (the default uv stream when omitted) without binding a value: a surface material binds one later with setTexture(name, …); a "screen" graph's names resolve against the §70 pass's declared inputs ("source" plus GraphEffect.textures).

      Parameters

      Returns ShaderExpression

    • §9 render time, in seconds — never simulation time (§42/§43: nothing downstream of a shader may become simulation input). The application feeds it to the backend (WebglRenderer.renderTime).

      Returns ShaderExpression

    • A named uniform of type (§60 "uniforms"). One name has one type; the value lives on each NodeMaterial (setUniform) or, for a screen graph, on the §70 pass (GraphEffect.uniforms).

      Parameters

      Returns ShaderExpression

    • Opt into one padded std140 uniform upload per material draw on WebGL 2.

      Returns this

    • Shorthand for attribute("uv"), cached — the texture default.

      Returns ShaderExpression