When a ray hits one surface, some part of the ray may be transmitted, some part is absorbed, and the rest is reflected (specular or diffuse). By defining the following parameters, the portion of each ray type can be characterized.
From the definition, the following relations will hold.
\begin{equation} \alpha + \rho^d + \rho^s + \tau = 1 \tag{1} \end{equation} \begin{equation} \sigma = \frac{\rho^s}{\rho^d + \rho^s} \tag{2} \end{equation}In the graphical ray tracing implementation, we will not use the absorptance parameter in this form, because RGB color basically represents this feature. For example:
Under the assumption of diffuse reflection (a.k.a Lambertian reflection), the intensity of the reflected light obeys the Lambert's cosine law. The intensity is described by \( I \cos \theta\) for a unit solid angle, where \(\theta\) is an angle with regard to the surface normal. This means that the direction of the reflected flux is independent of the incoming flux direction. The reflected flux direction can be simulated by the following way.
On the differential surface, the local bases \(~(\boldsymbol{R}_\mathrm{X},~\boldsymbol{R}_\mathrm{Y},~\boldsymbol{R}_\mathrm{Z})~\) can be defined as shown below.
\begin{equation} \boldsymbol{R}_\mathrm{X} = \frac{1}{\sqrt{n_x^2+n_z^2}} \left[ \begin{array}{c} n_z \\ 0 \\ -n_x \end{array} \right], ~~ \boldsymbol{R}_\mathrm{Y} = \boldsymbol{R}_\mathrm{Z} \times \boldsymbol{R}_\mathrm{X} = \frac{1}{\sqrt{n_x^2+n_z^2}} \left[ \begin{array}{c} n_y n_x \\ n_z^2 - n_x^2 \\ -n_y n_z \end{array} \right] \tag{3} \end{equation}When \(\boldsymbol{n}=(0, 1, 0)\), the local bases shall be taken by the following way:
\begin{equation} \boldsymbol{R}_\mathrm{Z} = \left[ \begin{array}{c} 0 \\ 1 \\ 0 \end{array} \right], ~~ \boldsymbol{R}_\mathrm{X} = \left[ \begin{array}{c} 0 \\ 0 \\ 1 \end{array} \right], ~~ \boldsymbol{R}_\mathrm{Y} = \left[ \begin{array}{c} 1 \\ 0 \\ 0 \end{array} \right]. \tag{4} \end{equation}On this local coordinate, we present the ray direction by using the polar coordinate paramters \(~(\theta, \varphi)~\). These parameters \(~(\theta, \varphi)~\) have to be generated according to the Lambert's cosine law. We will later discuss about the conversion from the uniform distribution to the distribution based on the Lambert's cosine law. Assuming we got a parameter set \(~(\theta, \varphi)~\), the ray direction \(~(X,~Y,~Z)~\) can be described as shown below.
\begin{equation} \left[ \begin{array}{c} X \\ Y \\ Z \end{array} \right] = \left[ \begin{array}{c} \sin \theta \cos \varphi \\ \sin \theta \sin \varphi \\ \cos \theta \end{array} \right] \tag{5} \end{equation}The conversion from local coordinate \(~(X,~Y,~Z)~\) to the global coordiante \(~(x,~y,~z)~\) is described by:
\begin{equation} \left[ \begin{array}{c} x \\ y \\ z \end{array} \right] = \left[ \begin{array}{ccc} \boldsymbol{R}_\mathrm{X} & \boldsymbol{R}_\mathrm{Y} & \boldsymbol{R}_\mathrm{Z} \end{array} \right] \left[ \begin{array}{c} X \\ Y \\ Z \end{array} \right] \tag{6} \end{equation}In case of the specular reflection, the reflected light direction \(\boldsymbol{r}_\mathrm{out}\) is described by using the incoming light direction \(\boldsymbol{r}_\mathrm{in}\) and the surface normal \(\boldsymbol{n}\) as shown below.
\begin{equation} \boldsymbol{r}_\mathrm{out} = \boldsymbol{r}_\mathrm{in} - 2 \boldsymbol{n} (\boldsymbol{r}_\mathrm{in} \cdot \boldsymbol{n}) \tag{7} \end{equation}Before discussing about the distribution of the Lambert's cosines law, we first think about how to homogeneously distribute points over a unit sphere. When describing a position on a unit surface with \((\theta, \varphi)\), the corresponding surface area for \((\theta, \varphi)\) is described by \(\sin \theta d\varphi d\theta\). Since this differential area is a function of \(\theta\), it is necessary to adjust the density in order to homogeneously distribute points. when you choose one point from homogeneously distributed points, the possibility that the selected point is within the range of \(0\le \theta \le \theta\) is described by:
$$ \begin{equation} p = \frac{\int_0^{\theta} \int_0^{2\pi} \sin \theta d\varphi d\theta}{\int_0^{\pi} \int_0^{2\pi} \sin \theta d\varphi d\theta } = \frac{[-\cos \theta]_{0}^{\theta}}{[-\cos \theta]_{0}^{2\pi}} = \frac{1-\cos \theta}{2} \tag{8} \end{equation} $$By solving this equation for \(\theta\), it is possible to relate a 0–1 value to \(\theta\).
$$ \begin{equation} \theta = \arccos (1-2p) \tag{9} \end{equation} $$In order to generate distribution for Lambert's cosine law, we should apply \(\cos \theta\) on the differential area. Since we are thinking about hemi-spherical surface, the probability distribution is described by
$$ \begin{equation} p = \frac{\int_0^{\theta} \int_0^{2\pi} \sin \theta \cos \theta d\varphi d\theta}{\int_0^{\pi/2} \int_0^{2\pi} \sin \theta \cos \theta d\varphi d\theta } = \frac{[-\cos 2\theta]_{0}^{\theta}}{[-\cos 2\theta]_{0}^{\pi/2}} = \frac{1-\cos 2\theta}{2} \tag{10} \end{equation} $$By solving this equation for \(\theta\), it is possible to relate a 0–1 value to \(\theta\).
\begin{equation} \theta = \frac{\arccos (1-2p)}{2} \tag{11} \end{equation}