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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.