applyCommonMaps function

void applyCommonMaps(
  1. Surface s,
  2. Float32List v,
  3. ShaderBindings b,
  4. FragmentContext c, {
  5. bool transformed = false,
})

The three every lit model uses. Metal-rough is separate because only the models that respond to metallic or roughness may sample it.

Implementation

void applyCommonMaps(
  Surface s,
  Float32List v,
  ShaderBindings b,
  FragmentContext c, {
  bool transformed = false,
}) {
  // `L3`: the field in place of the hemisphere, before the normal map, as
  // `ApplyCommonMaps` does it.
  if (irradianceEnabled(b)) {
    final strength = b.vec4('FragInfo', 'material', Vector4.zero()).z;
    s.ambient.setFrom(
      sampleIrradiance(b, s.world, s.normal, s.view)..scale(strength),
    );
  }
  applyNormalMap(s, v, b, c, transformed: transformed);
  applyOcclusionMap(s, v, b, c, transformed: transformed);
  applyEmissiveMap(s, v, b, c, transformed: transformed);
}