1. Introduction to Spherical Harmonics (SH)
Spherical Harmonics (SH) are a mathematical basis used to represent functions defined on the surface of a sphere. They are most commonly used in graphics for representing lighting environments, especially for low-frequency lighting such as diffuse or ambient lighting.
- SH are defined by two indices: degree l l l and order m m m.
- The number of SH terms up to degree l l l is ( l + 1 ) 2 (l + 1)^2 (l+1)2.
- SH are orthonormal, meaning each SH basis function is independent of the others.
Applications of SH in 3D Graphics:
- Ambient Lighting: Precomputed lighting environments stored in SH coefficients are used to approximate how light interacts with objects in a scene.
- Diffuse Lighting: SH functions can represent how light scatters from surfaces in all directions.
- Light Probes: SH coefficients are used to store lighting information at different points in a scene, allowing for real-time lighting evaluation.
Key Properties of SH:
- Low-Frequency Approximation: SH are effective at representing smooth, slowly-varying lighting environments, making them ideal for diffuse lighting.
- Compact Representation: By truncating the SH expansion to a low degree (e.g., degree 3), we reduce the computational complexity and memory footprint while maintaining reasonable accuracy.
2. Mathematical Background of Spherical Harmonics
Spherical harmonics Y l m ( θ , ϕ ) Y_l^m(\theta, \phi) Ylm(θ,ϕ) are defined in terms of two angular coordinates:
- θ \theta θ: The polar angle (angle from the z-axis).
- ϕ \phi ϕ: The azimuthal angle (angle from the x-axis in the x-y plane).
For degree l l l and order m m m, Spherical Harmonics Y l m ( θ , ϕ ) Y_l^m(\theta, \phi) Ylm(θ,ϕ) are given by:
Y l m ( θ , ϕ ) = ( 2 l + 1 ) 4 π ⋅ ( l − m ) ! ( l + m ) ! P l m ( cos θ ) e i m ϕ Y_l^m(\theta, \phi) = \sqrt{\frac{(2l + 1)}{4\pi} \cdot \frac{(l - m)!}{(l + m)!}} P_l^m(\cos \theta) e^{i m \phi} Ylm(θ,ϕ)=4π(2l+1)⋅(l+m)!(l−m)!