SphericalHarmonics3

Represents a third-order spherical harmonics (SH). Light probes use this class to encode lighting information.

  • Primary reference: https://graphics.stanford.edu/papers/envmap/envmap.pdf

  • Secondary reference: https://www.ppsloan.org/publications/StupidSH36.pdf

Instances are mutable and not thread-safe. Use each instance from one thread only.

There is no isSphericalHarmonics3 flag. Use is SphericalHarmonics3 instead.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The nine spherical harmonics coefficients, one Vector3 each. Change them in place.

Functions

Link copied to clipboard

Adds the given SH to this instance.

Link copied to clipboard

A convenience method for performing add and scale at once.

Link copied to clipboard

Returns a new spherical harmonics with copied values from this instance.

Link copied to clipboard

Copies the values of the given spherical harmonics to this instance.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Structural equality: true when other is a SphericalHarmonics3 whose nine coefficients are all equal (via Vector3.equals, so NaN != NaN).

Link copied to clipboard
fun fromArray(array: DoubleArray, offset: Int = 0): SphericalHarmonics3

Sets the SH coefficients of this instance from the given array.

Link copied to clipboard
fun getAt(normal: Vector3, target: Vector3): Vector3

Returns the radiance in the direction of the given normal.

Link copied to clipboard
fun getIrradianceAt(normal: Vector3, target: Vector3): Vector3

Returns the irradiance (radiance convolved with cosine lobe) in the direction of the given normal.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Linear interpolates between the given SH and this instance by the given alpha factor.

Link copied to clipboard

Scales this SH by the given scale factor.

Link copied to clipboard
fun set(coefficients: Array<Vector3>): SphericalHarmonics3

Sets the given SH coefficients to this instance by copying the values.

Link copied to clipboard
fun toArray(array: MutableList<Double> = mutableListOf(), offset: Int = 0): MutableList<Double>

Writes the 27 coefficient values into array, starting at offset, and returns it.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Sets all SH coefficients to 0.