bind method
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
void bind(
gpu.RenderPass pass,
TransientWriter transientsBuffer,
EnvironmentMap environment,
) {
// The variant the sky is drawn with, matching the pipeline the encoder
// built for this environment's radiance layout.
final shader = shaderForEnvironment(environment);
// Keys and a lookup, since iterating `entries` allocates a MapEntry each.
for (final name in _uniformBlocks.keys) {
pass.bindUniform(
shader.cachedUniformSlot(name),
transientsBuffer.emplace(_uniformBlocks[name]!),
);
}
for (final name in _textures.keys) {
final bound = _textures[name]!;
pass.bindTexture(
shader.cachedUniformSlot(name),
bound.texture,
sampler: bound.sampler ?? defaultSamplerOptions,
);
}
if (useEnvironment) {
EngineLightingUniforms.bindPrefilteredRadiance(
pass,
shader,
sampledEnvironment ?? environment,
cubeShader: usesRadianceCubeVariant(environment),
);
pass.bindTexture(
shader.cachedUniformSlot('brdf_lut'),
Material.getBrdfLutTexture(),
sampler: linearClampSamplerOptions,
);
}
}