The reason why I do this is not for the sake of mathematical purity but for purely practical reasons. I was reading implementation of a ray-tracer and the code was littered by special cases for specular surfaces. In the case of spacular surfaces the notion of a BSDF as a function breaks down, because it is dirac delta function. The theory of ray-tracing do not fully emphasizes that a BSDF can be Dirac delta function. I believe that emphasizing that a BSDF is a measure in theory can lead to better code design. The same goes for radiance. For example in the case of directional light source the radiance has to be again Dirac delta function. Thus we will consider radiance as measure too.

So please do not expect something radically new or important. It is just small refinement of ray-tracing theory which I will use as guiding principle for better code design.

#### Review of standard theory.

We adopt most notation and terminology from Veach's PhD thesis. Thus \(\mathcal{M}\) is the scene geometry, \(S^2\) is the unit sphere, \(\mathcal{R} = \mathcal{M}\times S^2\) is the ray space. Radiance \(L\) and BSDF \(f\) are following functions\begin{align}

L: \mathcal{R} & \rightarrow [0,\infty], \\

f: \mathcal{M} \times S^2 \times S^2 & \rightarrow [0,\infty].

\end{align}

The backbone of ray-tracing is the scattering equation

\begin{align}

L_o(x,\omega_o) = \int_{S^2} L_i(x,\omega_i) f(x,\omega_i,\omega_o) \, d\sigma^\perp_x(\omega_i)

\end{align}

This equation is the root of all the problems. What if the light is coming in only from one direction \(\omega'_i\), than \(L_i(x,\omega_i)\) is zero for all \(\omega_i \neq \omega'_i\) therefore the whole integral should be zero, because \( \{\omega'_i \} \) is single point which has zero measure. But normally we say, Oh! this is just special case, the value of the integral is \( L_i(x,\omega'_i) f(x,\omega'_i,\omega_o)\). The same goes for specular BSDFs. We fix these problems by defining radiance and BSDF as measure

#### Radiance and BSDF as measure

What is radiance? It is energy flux per unit solid angle per unit area. It is natural measure on ray space which gives you energy flux for given set of points and directions. We denote radiance as measure with letter \(\ell\) to differentiate it from radiance as function. With radiance as measure we have no problem defining radiance of laser at point \(x\) pointing at direction \(\omega\), such radiance is just Dirac measure on ray space \(\ell = I \delta_{(x,\omega)}\), where \(I\) is power of laser.

What is BSDF? BSDF tells you what happens with light when it hits surface i.e. it gives you the amount of light that goes off in given direction. Look at this in perspective of one photon. Photon hits surface at point \(x\) and direction \(\omega_i\), than BSDF gives you probability of that photon continuing in direction \(\omega_o\). Probability is special case of measure, therefore BSDF gives for each ray \((x,\omega_i)\) a probability measure. In following we wil denote BSDF as measure with \(\rho\).

To sum up we think of radiance \(\ell\) and BSDF \(\rho\) as

\begin{align}

\ell: \mathcal{B}(\mathcal{R}) & \rightarrow [0,\infty), \\

\rho: \mathcal{R} \times \mathcal{B}(\mathcal{S^2}) & \rightarrow [0,\infty),

\end{align}

where \( \mathcal{B}(X) \) is set of Borel subsets of \( X\). In words, \(\ell(A)\) is energy flux through set of rays \(A \subset \mathcal{R}\) and \( \rho((x,\omega),B)\) is probability of a photon continuing in some direction in \(B\subset S^2\) which hit surface at a point \(x\) in a direction \(\omega\).

Scattering equation now takes form

\begin{align}

\ell_o(A) = \int_{\mathcal{R}} \rho( (x,\omega_i), A^x) \, d\ell_i(x,\omega_i),

\end{align}

where \(A\subset \mathcal{R}\), \(A^x = \{ \omega \in S^2 : (x,\omega) \in A\} \). This form of scattering equation does not suffer from problems mentioned previously, but it looks a little bit cryptic. To make a little more sense of the equation we will use Lebesgue Decomposition Theorem.

\ell: \mathcal{B}(\mathcal{R}) & \rightarrow [0,\infty), \\

\rho: \mathcal{R} \times \mathcal{B}(\mathcal{S^2}) & \rightarrow [0,\infty),

\end{align}

where \( \mathcal{B}(X) \) is set of Borel subsets of \( X\). In words, \(\ell(A)\) is energy flux through set of rays \(A \subset \mathcal{R}\) and \( \rho((x,\omega),B)\) is probability of a photon continuing in some direction in \(B\subset S^2\) which hit surface at a point \(x\) in a direction \(\omega\).

Scattering equation now takes form

\begin{align}

\ell_o(A) = \int_{\mathcal{R}} \rho( (x,\omega_i), A^x) \, d\ell_i(x,\omega_i),

\end{align}

where \(A\subset \mathcal{R}\), \(A^x = \{ \omega \in S^2 : (x,\omega) \in A\} \). This form of scattering equation does not suffer from problems mentioned previously, but it looks a little bit cryptic. To make a little more sense of the equation we will use Lebesgue Decomposition Theorem.

#### Going back

By Lebesgue Decomposition Theorem we can decompose \(\rho(r, \cdot)\) with the respect to the projected solid angle measure \(\sigma^\perp\).

\begin{align}

\rho(r,\cdot) &= \rho_d(r,\cdot) + \rho_s(r,\cdot) \\

\rho_d(r,\cdot) &\ll \sigma^\perp \\

\rho_s(r,\cdot) &\perp \sigma^\perp

\end{align}

\rho(r,\cdot) &= \rho_d(r,\cdot) + \rho_s(r,\cdot) \\

\rho_d(r,\cdot) &\ll \sigma^\perp \\

\rho_s(r,\cdot) &\perp \sigma^\perp

\end{align}

\(\rho_d\) is the familiar diffuse part of BSDF and \(\rho_s\) is the specular part of BSDF. We can even take Radon-Nikodym derivative of \(\rho_d\) with the respect to the \( \sigma^\perp \) to obtain standard BSDF function,

\begin{align}

\frac{d \rho_d((x,\omega_i),\omega_o)}{d \sigma^\perp(\omega_o)} = f(x,\omega_i,\omega_o).

\end{align}

The specular part \(\rho_s\) is in the most cases just counting measure over one or two directions, these are reflection and refraction directions, occasionally it can be counting measure over more directions. In complete generality it can be quite nasty measure, for example it can be some measure over Cantor set, but who on Earth would have material which reflects in the shape of Cantor set or Sierpinski triangle?

\begin{align}

\frac{d \rho_d((x,\omega_i),\omega_o)}{d \sigma^\perp(\omega_o)} = f(x,\omega_i,\omega_o).

\end{align}

The specular part \(\rho_s\) is in the most cases just counting measure over one or two directions, these are reflection and refraction directions, occasionally it can be counting measure over more directions. In complete generality it can be quite nasty measure, for example it can be some measure over Cantor set, but who on Earth would have material which reflects in the shape of Cantor set or Sierpinski triangle?

## Žádné komentáře:

## Okomentovat