public sealed class SphericalHarmonicsL2An environment's diffuse lighting, in nine numbers per channel.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Diffuse lighting from an environment is a cosine-weighted integral over the whole sphere, and it is very smooth: a Lambertian surface cannot see any detail sharper than the cosine lobe that blurs it. Ramamoorthi and Hanrahan's result is that nine spherical-harmonic coefficients — the first three bands — reproduce that integral to within about one per cent for any environment. Nine RGB numbers, against a prefiltered irradiance cube map's tens of thousands of texels.
That is why the split-sum approximation stores diffuse as SH and only specular as a cube: it makes a light probe small enough to put one in every room, and cheap enough to update one per frame.
Irradiance returns irradiance divided by π, which is the quantity a shader multiplies by albedo. Getting that factor wrong is the classic "everything is π times too bright" bug, so the constant test is exact rather than approximate: a uniform environment of radiance L must come back as exactly L.
Fields and properties (2)
public const int CountHow many coefficients three bands is.
public ReadOnlySpan<Vector3> CoefficientsThe nine coefficients, one RGB triple each.
Methods (5)
public SphericalHarmonicsL2(ReadOnlySpan<Vector3> coefficients)Starts from nine given coefficients.
public SphericalHarmonicsL2()Starts from nothing: a black environment.
public static SphericalHarmonicsL2 Project(TextureData cube, int level = 0)Projects a cube map onto the first three bands.
public static void Evaluate(Vector3 direction, Span<float> basis)The nine basis functions in a direction.
public Vector3 Irradiance(Vector3 normal)The diffuse lighting arriving at a surface facing a direction, divided by π — which is what a shader multiplies by albedo.
Used by (3)
- IblTestsVixen.Core.Imaging.Tests
- SphericalHarmonicsL1Vixen.Core.Imaging
- SphericalHarmonicsL1TestsVixen.Core.Imaging.Tests