Documentation
    Preparing search index...

    Class StandardProgram

    The metallic-roughness pipeline (§57's StandardMaterial, §59, §68).

    const program = StandardProgram.create(gl);
    program.use();
    program.setViewProjection(viewProjection); // once per viewport
    program.setAmbientLight(lights.ambientColor); // once per viewport
    program.setDirectionalLight(lights.direction, lights.directionalColor);
    program.setPunctualLights(lights); // once per viewport
    program.setCameraPosition(x, y, z); // once per viewport
    program.setFeatures(hasMap); // once per draw
    program.setModel(item.worldMatrix);
    program.setBaseColor(material.baseColor, material.opacity);
    program.setSurface(material.metalness, material.roughness, material.emissive);

    Light and camera uniforms are per-frame state uploaded per viewport — they live in the program object, exactly like the view-projection, so one upload holds for every standard draw into that view even when other pipelines run in between.

    Owns its GL objects and nothing else; the renderer re-creates it on context restore exactly as it re-creates the other five (§61).

    Implements

    Index
    • Deletes the GL program (§83). Idempotent.

      Only call this on a live context — see UnlitProgram.dispose.

      Returns void

    • Uploads the scene ambient term (§68), straight RGB. Accepts the SceneLights record's own live array — copied into scratch, as every upload here is.

      Parameters

      • color: readonly [number, number, number]

      Returns void

    • Uploads §59's baseColor as straight-alpha, linear-light RGBA, scaled by the material's opacity exactly as UnlitProgram.setColor does — see it for the multiply and for why the default reproduces an untouched material's upload bit for bit. Accepts the material's own live array; the values are copied into scratch, so the material keeps ownership of its array.

      Parameters

      • color: readonly [number, number, number, number]
      • opacity: number = 1

      Returns void

    • Uploads the world-space eye position the specular lobe is evaluated against — the one per-view input a diffuse-only pipeline never needed.

      Three scalars rather than a matrix or a Vector3, because the renderer reads them straight out of the camera's world matrix translation column and has nothing to allocate on the way.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns void

    • Uploads the directional light (§68): the world-space unit vector the light travels along (SceneLights.direction — the fragment stage negates it) and its colour premultiplied by intensity (SceneLights.directionalColor). A frame with no directional light uploads black, which zeroes the whole direct term — one shader, no variants, exactly as in LitProgram.

      Parameters

      • direction: Vector3
      • color: readonly [number, number, number]

      Returns void

    • Selects whether this draw samples the bound base-colour texture (§59's map), the packed metallic-roughness map, and/or the emissive map. Identical in contract to LitProgram.setFeatures — mirrored on the CPU, uploaded only on change, sampler units uploaded lazily the first time this program draws that texture at all. Extra booleans default false so a one-argument call stays the untextured-MR/emissive draw it was before those maps existed (R-19: a uniform switch, not a shader variant).

      Parameters

      • useMap: boolean
      • useMetalRoughnessMap: boolean = false
      • useEmissiveMap: boolean = false
      • useNormalMap: boolean = false
      • useOcclusionMap: boolean = false

      Returns void

    • Uploads the frame's hemisphere (§68) — or nothing, for a scene that has none. See HemisphereLightUniforms for the contract.

      Parameters

      Returns void

    • Offset encoding makes GL's zero-initialized uniforms the glTF defaults.

      Parameters

      • normalScale: number = 1
      • occlusionStrength: number = 1

      Returns void

    • Uploads one render item's world matrix and its derived normal matrix.

      Parameters

      Returns void

    • Uploads the frame's point and spot lights (§68, R-17) — or nothing, for a scene that has none. See PunctualLightUniforms for the contract and for why "nothing" is load-bearing.

      Parameters

      Returns void

    • Selects whether the draw about to be issued is shadowed (§49's receiveShadow, §69) — see ShadowUniforms.setReceiving, whose contract this is verbatim.

      Parameters

      • receiving: boolean

      Returns void

    • Uploads the frame's shadow matrix, biases and tap size (§69, R-18) — or nothing, for a frame in which no light casts. Call once per viewport; see ShadowUniforms for the contract and for why "nothing" is load-bearing.

      Parameters

      Returns void

    • Uploads the three surface parameters §59 puts beside the base colour: metalness, roughness, and the straight-RGB emissive term.

      One method rather than three, because they are one material's description of one surface and every draw uploads all of them: splitting would triple the call sites for no caller that wants two of the three. Values are uploaded as authored — the material documents 0…1 and does not clamp, and the shader applies the one floor it cannot survive without (see the module header).

      Parameters

      • metalness: number
      • roughness: number
      • emissive: readonly [number, number, number]

      Returns void

    • Uploads projection * view for the viewport being drawn. Column-major, so transpose is false — the engine's Matrix4 layout is already GL's (§7b).

      Parameters

      Returns void

    • Makes this the current program. Call before any upload below.

      Returns void