bind method

  1. @override
void bind(
  1. RenderPass pass,
  2. TransientWriter transientsBuffer,
  3. EnvironmentMap environment
)
override

Binds the fragment's uniform blocks, textures, and (when useEnvironment) the environment IBL samplers. Called by the engine during the background draw; not part of the app-facing API.

Implementation

@override
void bind(
  gpu.RenderPass pass,
  TransientWriter transientsBuffer,
  EnvironmentMap environment,
) {
  // Parameters (the MaterialParams block plus any declared samplers) carry
  // the sky's inputs; the raw uniform-block path is unused here.
  parameters.bind(pass, fragmentShader, transientsBuffer);
  // Zero keep-alive, mirroring PreprocessedMaterial; the generated sky
  // references every declared parameter resource through it so none can be
  // optimized out. Environment skies always declare the block (it keeps
  // the radiance samplers live even when the author never samples them).
  if (parameters.hasAnyParameters || useEnvironment) {
    pass.bindUniform(
      fragmentShader.getUniformSlot('FragmentKeepAlive'),
      transientsBuffer.emplace(_zeroKeepAlive),
    );
  }
  // A `requires: [environment]` sky samples the prefiltered radiance
  // through SampleEnvironment, bound the same way the standard material
  // binds it (both layout samplers plus the layout selector block).
  if (useEnvironment) {
    EngineLightingUniforms.bindPrefilteredRadiance(
      pass,
      fragmentShader,
      sampledEnvironment ?? environment,
    );
  }
}