bind method

void bind(
  1. RenderPass pass,
  2. HostBuffer transientsBuffer,
  3. Lighting lighting
)

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

void bind(
  gpu.RenderPass pass,
  gpu.HostBuffer transientsBuffer,
  Lighting lighting,
) {
  // Double-sided is honored only for opaque materials. A translucent
  // material is always back-face culled: drawing both sides would blend the
  // overlapping front and back surfaces in triangle-index order rather than
  // depth order (the translucent pass has no per-fragment sorting), which
  // seams thick double-sided glass. Single-sided draws just the outer
  // surface.
  final cullBackFace = !doubleSided || !isOpaque();
  pass.setCullMode(cullBackFace ? gpu.CullMode.backFace : gpu.CullMode.none);
  pass.setWindingOrder(gpu.WindingOrder.counterClockwise);
}