Spherical harmonics are an infinite set of orthonormal basis functions

In the above graph, blue portions represent regions where the function is positive, and yellow portions represent regions where it is negative.
Spherical harmonics are of particular interest in computer graphics, as functions taking a unit vector as input can be viewed as a function on the sphere. Those functions, no matter how complicated, can be expressed as an infinite weighted sum of spherical harmonic functions, and can be approximated with finite terms.
Degree and Order
SH functions are split into numbered groups often called “frequency bands” (with degree
A spherical harmonic function with degree
Info
Note that this note uses the physics convention of spherical coordinates
The function has a complicated definition, but each term can be found in various lookup tables online. Note that there are both complex number version
Obtaining the Spherical Harmonic Coefficients
We can represent real-valued function
where
Finding coefficients of spherical harmonic is analogous to finding coefficients of basis vectors to represent a geometric vector. With geometric vectors, we use dot product to find the magnitude of a vector projected to a basis. With spherical harmonic, we find coefficients by computing inner product of functions: 1