bind method
Binds this material's render-pass state, uniforms, and textures.
The base implementation enables back-face culling with clockwise
winding on the Y-down rasterizer (accepting model-space CCW front faces).
Subclasses must call super.bind and then bind any per-material uniforms
and textures expected by their fragment shader. lighting carries the
IBL EnvironmentMap (and its intensity) plus the analytic lights and
shadow resources that materials shade against.
Implementation
@override
void bind(
gpu.RenderPass pass,
TransientWriter transientsBuffer,
Lighting lighting,
) {
super.bind(pass, transientsBuffer, lighting);
_fragInfoScratch
..[0] = baseColorFactor.r
..[1] = baseColorFactor.g
..[2] = baseColorFactor.b
..[3] = baseColorFactor.a
..[4] = vertexColorWeight
..[5] = lodFade
..[6] = displayReferred ? 1.0 : 0.0;
pass.bindUniform(
fragmentShader.cachedUniformSlot("FragInfo"),
transientsBuffer.emplace(_fragInfoBytes),
);
pass.bindUniform(
fragmentShader.cachedUniformSlot('TextureTransform'),
transientsBuffer.emplace(
_textureTransform.packSingle(
baseColorTextureTransform,
baseColorTextureTexCoord,
),
),
);
final resolved = resolveTextureSource(baseColorTexture);
pass.bindTexture(
fragmentShader.cachedUniformSlot('base_color_texture'),
Material.whitePlaceholder(resolved),
sampler: samplerOrPlaceholder(
resolved,
textureSourceSampler(baseColorTexture) ?? _repeatSampler,
),
);
// The unlit shader carries the FogInfo block (fog.glsl) too.
EngineLightingUniforms.bindFog(
pass,
fragmentShader,
transientsBuffer,
lighting,
);
EngineLightingUniforms.bindViewInfo(
pass,
fragmentShader,
transientsBuffer,
lighting,
);
}