Documentation
    Preparing search index...

    Class ShadowUniforms

    One shaded pipeline's shadow uniforms: the six locations, the sampler-unit upload, and the CPU mirror that keeps a frame with no casting light emitting no GL call at all (§69, R-18).

    const shadows = ShadowUniforms.resolve(gl, program, "lit");
    shadows.uploadView(lights); // once per viewport
    shadows.setReceiving(active && item.receiveShadow); // once per draw

    Shared by LitProgram and gl-standard.ts's StandardProgram for PunctualLightUniforms' reason: the two stages consume the identical SceneLights fields through the identical GLSL chunk, and a class each would be two places for the skip rule to drift apart.

    useShadow is a bool uniform whose CPU mirror starts at false, which is what GL initializes a bool uniform to. A frame in which no light casts therefore uploads nothing at all — not the matrix, not the biases, not the sampler, not the switch — so a scene lit the way every scene was lit before §69 shipped issues byte-for-byte the GL sequence it always did. The mirror-at-GL-initial-0 technique on its fourth recorded use (R-15's bool encode switch, R-38's permissive layer mask, R-17's light count).

    The pixel half of that claim lives in the two shaded fragment stages, and is kept the way R-17 kept it: the shadow term multiplies the existing directional expression inside an if (useShadow), so with the switch off the arithmetic is the arithmetic those stages performed before, operation for operation. Nothing is re-associated.

    The split between the two methods is the split between per-view state (the matrix and the biases, which belong to the light) and per-draw state (§49's receiveShadow, which belongs to the node).

    Index
    • Switches the shadow comparison on or off for the draw about to be issued (§49's receiveShadow, §69) — mirrored on the CPU and uploaded only on change, exactly as LitProgram.setFeatures mirrors useMap.

      Pass lights.hasShadow && item.receiveShadow: the two reasons a draw is not shadowed are "nothing casts" and "this node opted out", and folding them into one uniform is what keeps a shadowless frame at zero calls while a non-receiver inside a shadowed frame costs exactly one.

      Parameters

      • receiving: boolean

      Returns void

    • Uploads the frame's shadow matrix, biases and tap size — or nothing at all, when lights.hasShadow is false. Call once per viewport, beside the ambient and directional uploads.

      The sampler unit is uploaded lazily, on the first view that actually has a shadow, exactly as the albedo sampler is: a pipeline that never shades a shadowed frame never mentions the unit.

      Parameters

      Returns void

    • Looks the six locations up on a linked program, throwing the §89 SHADER_COMPILATION_FAILED requireUniform throws if one is missing.

      Parameters

      • gl: WebglContext
      • program: object
      • label: string

        the pipeline name used in the failure message

      Returns ShadowUniforms