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

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

<p>$$\int_{}^{} f(x) B_i(x) dx=fConst_i$$</p>

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

<p>$$\sum_{n=1}^{i} fConst_iB(i)$$</p>

<p>In your case they could look like this:</p>

<p>$$
fConst1 = 0.429043;
$$
$$
fConst2 = 0.511664;
$$
$$
fConst3 = 0.743125;
$$
$$
fConst4 = 0.886227;
$$
$$
fConst5 = 0.247708;
$$</p>

<p>These coefficients approximate diffuse lighting.</p>

CC BY-SA 3.0
2016-08-29T07:42:11.683Z
So those values needs to be computed on a case basis? and are not real constants?
CoffeDeveloper
CC BY-SA 3.0
2016-08-29T08:20:58.427Z
ok, seems Those are the actual constants used in every existing shader.
CoffeDeveloper
CC BY-SA 3.0
2016-08-29T11:39:15.993Z
Yes, for diffuse lighting. For other forms of lighting you need to compute other constants.
CpCd0y
CC BY-SA 3.0
2016-08-27T22:56:08.433Z
2016-08-27T22:56:08.433Z
CpCd0y
<p>At page (slide in reality) 12/20 of <a href="http://documents.tips/documents/spherical-harmonics-gdce.html" rel="noreferrer">this tutorial</a> 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?</p>

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

<shader>
What are the fConstX in Spherical Harmonics?
CoffeDeveloper
# What are the fConstX in Spherical Harmonics?

(Asked by: username_0 on 2016-08-24)

At page (slide in reality) 12/20 of [this tutorial](http://documents.tips/documents/spherical-harmonics-gdce.html) 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?

**Tags:** shader


---

## 1 answers

### Answer by username_1 on 2016-08-27. Score: 0 | Accepted answer

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.

> **Comments:**
> **username_0**: So those values needs to be computed on a case basis? and are not real constants?  
> **username_0**: ok, seems Those are the actual constants used in every existing shader.  
> **username_1**: Yes, for diffuse lighting. For other forms of lighting you need to compute other constants.  

---

