2
$\begingroup$

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) for this formula, however I was unable to find the derivation of this formula.


On the other hand, I found this wikibook article, 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?

$\endgroup$
  • $\begingroup$ Are you talking about diffuse hemisphere lighting from a point light? $\endgroup$ – Alan Wolfe Jun 23 '17 at 17:38
  • 1
    $\begingroup$ 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. $\endgroup$ – Florian R. Jun 23 '17 at 17:42

Your Answer

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

Browse other questions tagged or ask your own question.