getIrradianceAt method

Vector3 getIrradianceAt(
  1. Vector3 normal,
  2. Vector3 target
)

Implementation

Vector3 getIrradianceAt(Vector3 normal, Vector3 target) {
  // normal is assumed to be unit length

  final x = normal.x, y = normal.y, z = normal.z;

  final coeff = coefficients;

  // band 0
  target..setFrom(coeff[0])..scale(0.886227); // π * 0.282095

  // band 1
  target.addScaled(
      coeff[1], 2.0 * 0.511664 * y); // ( 2 * π / 3 ) * 0.488603
  target.addScaled(coeff[2], 2.0 * 0.511664 * z);
  target.addScaled(coeff[3], 2.0 * 0.511664 * x);

  // band 2
  target.addScaled(
      coeff[4], 2.0 * 0.429043 * x * y); // ( π / 4 ) * 1.092548
  target.addScaled(coeff[5], 2.0 * 0.429043 * y * z);
  target.addScaled(
      coeff[6], 0.743125 * z * z - 0.247708); // ( π / 4 ) * 0.315392 * 3
  target.addScaled(coeff[7], 2.0 * 0.429043 * x * z);
  target.addScaled(
      coeff[8], 0.429043 * (x * x - y * y)); // ( π / 4 ) * 0.546274

  return target;
}