applyEmissiveMap function

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

Sets Surface.emissive from the emissive map, decoded from sRGB and scaled by FragInfo.emissive and the strength in material2.w. Leaves the surface as it is when no map is bound. transformed reads the map through the material's UV transform.

Implementation

void applyEmissiveMap(
  Surface s,
  Float32List v,
  ShaderBindings b,
  FragmentContext c, {
  bool transformed = false,
}) {
  final map = b.textures['emissive_texture'];
  if (map == null) return;
  final MappedUv(u: mu, v: mv, footprint: uv) = mapUv(
    kMapEmissive,
    v,
    b,
    c,
    transformed: transformed,
  );
  final texel = map.sample(mu, mv, du: uv.du, dv: uv.dv);
  final factor = b.vec4('FragInfo', 'emissive', Vector4.zero());
  final strength = b.vec4('FragInfo', 'material2', Vector4.zero()).w;
  s.emissive = Vector3(
    toLinear(texel.x) * factor.x * strength,
    toLinear(texel.y) * factor.y * strength,
    toLinear(texel.z) * factor.z * strength,
  );
}