What are the fConstX in Spherical Harmonics?

At page (slide in reality) 12/20 of this tutorial it is shown a function used to project lights into SH coefficients, however the value of those coefficients is not given, what are their values and what they are for?

Do I have to clamp colors to max value of 1 (float) / 255(uint) when adding lights to SH coefficients?

I'm not an expert on Spherical Harmonic (SH), but I'll try to answer.

SH functions are basis functions. That means that they encode a function $f$ this way by a given basis function $B_i$:

$$\int_{}^{} f(x) B_i(x) dx=fConst_i$$

So what we can do is to use the $fConst_i$ to reconstruct an approximation of the function $f$ this way:

$$\sum_{n=1}^{i} fConst_iB(i)$$

In your case they could look like this:

$$fConst1 = 0.429043;$$ $$fConst2 = 0.511664;$$ $$fConst3 = 0.743125;$$ $$fConst4 = 0.886227;$$ $$fConst5 = 0.247708;$$

These coefficients approximate diffuse lighting.

• So those values needs to be computed on a case basis? and are not real constants? – CoffeDeveloper Aug 29 '16 at 7:42
• ok, seems Those are the actual constants used in every existing shader. – CoffeDeveloper Aug 29 '16 at 8:20
• Yes, for diffuse lighting. For other forms of lighting you need to compute other constants. – CpCd0y Aug 29 '16 at 11:39