EnvironmentMap.fromGpuTextures constructor

EnvironmentMap.fromGpuTextures({
  1. required Texture prefilteredRadiance,
  2. List<Vector3>? diffuseSphericalHarmonics,
  3. Texture? diffuseShTexture,
})

Wraps an already-built prefiltered radiance texture.

prefilteredRadiance is either layout produced by prefilterEquirectRadiance (mip levels or the legacy band atlas, detected from the texture's mip count). The diffuse term comes from diffuseSphericalHarmonics (kDiffuseShCoefficientCount RGB coefficients with the Lambertian convolution and 1/pi already folded in, as computeDiffuseSphericalHarmonics returns), or from diffuseShTexture (a 9x1 coefficient texture already on the GPU, as a sky bake produces); pass at most one. When both are omitted the diffuse term is zero.

Implementation

factory EnvironmentMap.fromGpuTextures({
  required gpu.Texture prefilteredRadiance,
  List<Vector3>? diffuseSphericalHarmonics,
  gpu.Texture? diffuseShTexture,
}) {
  assert(
    diffuseSphericalHarmonics == null || diffuseShTexture == null,
    'Pass diffuseSphericalHarmonics or diffuseShTexture, not both.',
  );
  if (diffuseShTexture != null) {
    return EnvironmentMap._fromGpuSh(prefilteredRadiance, diffuseShTexture);
  }
  return EnvironmentMap._(
    prefilteredRadiance,
    diffuseSphericalHarmonics ?? _zeroSphericalHarmonics(),
  );
}