• Public
  • Public/Protected
  • All

Class SphericalHarmonics

Class representing spherical harmonics coefficients to the 3rd degree


  • SphericalHarmonics



l00Search playground for l00

l00: Vector3

The l0,0 coefficients of the spherical harmonics

l10Search playground for l10

l10: Vector3

The l1,0 coefficients of the spherical harmonics

l11Search playground for l11

l11: Vector3

The l1,1 coefficients of the spherical harmonics

l1_1Search playground for l1_1

l1_1: Vector3

The l1,-1 coefficients of the spherical harmonics

l20Search playground for l20

l20: Vector3

The l2,0 coefficients of the spherical harmonics

l21Search playground for l21

l21: Vector3

The l2,1 coefficients of the spherical harmonics

l22Search playground for l22

l22: Vector3

The l2,2 coefficients of the spherical harmonics

l2_1Search playground for l2_1

l2_1: Vector3

The l2,-1 coefficients of the spherical harmonics

l2_2Search playground for l2_2

l2_2: Vector3

The l2,-2 coefficients of the spherical harmonics

preScaledSearch playground for preScaled

preScaled: boolean

Defines whether or not the harmonics have been prescaled for rendering.


addLightSearch playground for addLight

  • addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void
  • Adds a light to the spherical harmonics


    • direction: Vector3

      the direction of the light

    • color: Color3

      the color of the light

    • deltaSolidAngle: number

      the delta solid angle of the light

    Returns void

convertIncidentRadianceToIrradianceSearch playground for convertIncidentRadianceToIrradiance

  • convertIncidentRadianceToIrradiance(): void
  • Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.

    E_lm = A_l * L_lm

    In spherical harmonics this convolution amounts to scaling factors for each frequency band. This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where the scaling factors are given in equation 9.

    Returns void

convertIrradianceToLambertianRadianceSearch playground for convertIrradianceToLambertianRadiance

  • convertIrradianceToLambertianRadiance(): void
  • Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.

    L = (1/pi) * E * rho

    This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.

    Returns void

preScaleForRenderingSearch playground for preScaleForRendering

  • preScaleForRendering(): void
  • Integrates the reconstruction coefficients directly in to the SH preventing further required operations at run time.

    This is simply done by scaling back the SH with Ylm constants parameter. The trigonometric part being applied by the shader at run time.

    Returns void

scaleInPlaceSearch playground for scaleInPlace

  • scaleInPlace(scale: number): void
  • Scales the spherical harmonics by the given amount


    • scale: number

      the amount to scale

    Returns void

Static FromArraySearch playground for FromArray

  • Constructs a spherical harmonics from an array.


    • data: ArrayLike<ArrayLike<number>>

      defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)

    Returns SphericalHarmonics

    the spherical harmonics

Static FromPolynomialSearch playground for FromPolynomial

  • Gets the spherical harmonics from polynomial


    Returns SphericalHarmonics

    the spherical harmonics


  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method