Skip to content

30. Mathematics of Lighting and Shading part 4

Dated: 02-07-2025

Light Attenuation

\[f_{\text{atten}} = \frac 1 {k_c + k_1 d + k_2 d^2}\]

Here \(f_\text{atten}\) is the attenuation factor, which is amount of intensity light loses as the distance \(d\) between the photon and its source increases.
The lighting equation with attenuation looks like

\[i_\text{total} = i_a + \sum f_\text{atten} (i_d + i_s)\]

Schlick's Simplification for the Specular Exponential Term

In this simplification, the \((S)^{m_s}\) factor in Phong or Blinn Phong1 is replaced by

\[\frac S {m_s - m_sS + S}\]

Oren - Nayar Diffuse2 Reflection

cs602_i_30_1.png

Full Moon

The full moon does not show Lambertian diffuse shading. In fact, due to the rough surface, it also backscatter some light.
Oren and Nayar [OREN 1992] came up with a generalized version of a Lambertian diffuse shading model that tries to account for the roughness of the surface.

\[i_d = \frac \rho \pi E_0 \cos (\theta_i)(A + B \max (0, \cos (\phi_r - \phi_i))\sin(\alpha)\tan(\beta))\]
\[\text{where } A = 1 - 0.5 \frac {\sigma^2}{\sigma^2 + 0.33} \text{ and } B = 0.45 \frac {\sigma^2}{\sigma^2 + 0.09}\]
The terms
  • \(\frac \rho \pi\) is a surface reflectivity property, which can be replaced with our surface diffuse color.
  • \(E_0\) is a light input energy term, which can be replaced with our light diffuse color2
\[i_d = (m_d \otimes s_d) (\hat n \cdot \hat l)(A + B \max (0, \cos (\phi_r - \phi_i))\sin(\alpha)\tan(\beta))\]
More terms
  • \(\rho\) is the surface roughness parameter. It's the standard deviation in radians of the angle of distribution of the microfacets in the surface roughness model. The larger the value, the rougher the surface.
  • \(\theta_r\) is the angle between the vertex normal3 and the view direction.
  • \(\phi_r - \phi_i\) is the circular angle (about the vertex normal3) between the light vector4 and the view vector.4
  • \(\alpha\) is \(\max(\theta_i, \theta_r)\)
  • \(\beta\) is \(\min(\theta_i, \theta_r)\)
Additional notes

If the roughness value is \(0\), the model is same as Lambertian diffuse model. Oren and Nayar also note that we can replace the value \(0.33\) in coefficient \(A\) with \(0.57\) to better account for surface inter-reflection.

References


  1. Read more about phong

  2. Read more about light types

  3. Read more about surface normals

  4. Read more about vectors