<p>The OpenGL Programming Guide states the formula for diffuse hemisphere lighting on a surface with normal vector $\vec{n}$ as</p>

<p>$L_o(\vec{n}) = L_i(\uparrow) (1-\frac{1}{2}\sin(\theta)) + L_i(\downarrow) \frac{1}{2}\sin(\theta)$ if $0 &lt;= \theta &lt; \frac{1}{2}\pi$</p>

<p>and</p>

<p>$L_o(\vec{n}) = L_i(\uparrow) \frac{1}{2}\sin(\theta) + L_i(\downarrow) (1 - \frac{1}{2}\sin(\theta))$ if $\frac{1}{2}\pi &lt;= \theta &lt;= \pi$</p>

<p>with $\theta$ as the polar angle of $\vec{n}$:</p>

<p>$\theta = \cos^{-1}(n_z)$</p>

<p>I found various other sources (e.g. <a href="http://www2.lawrence.edu/fast/GREGGJ/CMSC420/chapter21/Irradiance.html" rel="nofollow noreferrer">this text</a>) for this formula, however I was unable to find the derivation of this formula.</p>

<hr>

<p>On the other hand, I found this <a href="https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Diffuse_Reflection_of_Skylight#Hemisphere_Lighting" rel="nofollow noreferrer">wikibook article</a>, suggesting:
$L_o(\vec{n}) = L_{i}(\uparrow) (\frac{1}{2} + \frac{1}{2} \cos(\theta)) + L_{i}(\downarrow) (\frac{1}{2} - \frac{1}{2} \cos(\theta))$</p>

<p>which is explicitly described as an approximation/cheating in the OpenGL Programming Guide. The derivation of this formula is done without a clear source of error.</p>

<hr>

<p>Trying to reproduce either formula, I solved</p>

<p>$L_o(\vec{n}) = \frac{1}{\pi}\int_{H} L_i(\vec{w}) \langle{}\vec{w}, \vec{n}\rangle{} \mathrm{d}\vec{w}$</p>

<p>both analytically and numerically, and both times I ended up with the latter formula.</p>

<p>While it may not matter much in practice, I am apparently making some mistake here. So my question is: <strong>How can I derive the former formula from this integral and why is the latter formula only an approximation?</strong></p>

CC BY-SA 3.0
2017-06-23T17:38:31.773Z
Are you talking about diffuse hemisphere lighting from a point light?
Alan Wolfe
CC BY-SA 3.0
2017-06-23T17:42:48.957Z
By hemisphere lighting I mean that the top and bottom (hemispheres) of the "world" both emit light of a differing color, e.g. the top may emit blue light (sky) while the bottom may emit a dim brown (earth). You can think of it as a simplified environment map.
Florian R.
<lighting><diffuse><hemisphere>
Exact Formula for Diffuse Hemisphere Lighting
Florian R.
# Exact Formula for Diffuse Hemisphere Lighting

(Asked by: username_0 on 2017-06-23)

The OpenGL Programming Guide states the formula for diffuse hemisphere lighting on a surface with normal vector $\vec{n}$ as

$L\_o(\vec{n}) = L\_i(\uparrow) (1-\frac{1}{2}\sin(\theta)) + L\_i(\downarrow) \frac{1}{2}\sin(\theta)$ if $0 <= \theta < \frac{1}{2}\pi$

and

$L\_o(\vec{n}) = L\_i(\uparrow) \frac{1}{2}\sin(\theta) + L\_i(\downarrow) (1 - \frac{1}{2}\sin(\theta))$ if $\frac{1}{2}\pi <= \theta <= \pi$

with $\theta$ as the polar angle of $\vec{n}$:

$\theta = \cos^{-1}(n\_z)$

I found various other sources (e.g. [this text](http://www2.lawrence.edu/fast/GREGGJ/CMSC420/chapter21/Irradiance.html)) for this formula, however I was unable to find the derivation of this formula.

---

On the other hand, I found this [wikibook article](https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Diffuse_Reflection_of_Skylight#Hemisphere_Lighting), suggesting:
$L\_o(\vec{n}) = L\_{i}(\uparrow) (\frac{1}{2} + \frac{1}{2} \cos(\theta)) + L\_{i}(\downarrow) (\frac{1}{2} - \frac{1}{2} \cos(\theta))$

which is explicitly described as an approximation/cheating in the OpenGL Programming Guide. The derivation of this formula is done without a clear source of error.

---

Trying to reproduce either formula, I solved

$L\_o(\vec{n}) = \frac{1}{\pi}\int\_{H} L\_i(\vec{w}) \langle{}\vec{w}, \vec{n}\rangle{} \mathrm{d}\vec{w}$

both analytically and numerically, and both times I ended up with the latter formula.

While it may not matter much in practice, I am apparently making some mistake here. So my question is: **How can I derive the former formula from this integral and why is the latter formula only an approximation?**

**Tags:** lighting, diffuse, hemisphere

> **Comments:**
> **username_1**: Are you talking about diffuse hemisphere lighting from a point light?  
> **username_0**: By hemisphere lighting I mean that the top and bottom (hemispheres) of the "world" both emit light of a differing color, e.g. the top may emit blue light (sky) while the bottom may emit a dim brown (earth). You can think of it as a simplified environment map.  

---

## 0 answers

