bind method
Binds this material's render-pass state, uniforms, and textures.
The base implementation enables back-face culling with
counter-clockwise winding (matching the glTF convention). 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,
gpu.HostBuffer transientsBuffer,
Lighting lighting,
) {
super.bind(pass, transientsBuffer, lighting);
var fragInfo = Float32List.fromList([
baseColorFactor.r, baseColorFactor.g,
baseColorFactor.b, baseColorFactor.a, // color
vertexColorWeight, // vertex_color_weight
]);
pass.bindUniform(
fragmentShader.getUniformSlot("FragInfo"),
transientsBuffer.emplace(ByteData.sublistView(fragInfo)),
);
pass.bindTexture(
fragmentShader.getUniformSlot('base_color_texture'),
baseColorTexture,
sampler: gpu.SamplerOptions(
widthAddressMode: gpu.SamplerAddressMode.repeat,
heightAddressMode: gpu.SamplerAddressMode.repeat,
),
);
}