3D Rendering

Fundamentals of Photo Realistic Rendering

Reflection
Figure 1: A proportion of light is reflected from a surface and reaches the viewer.

Human perceive surfaces as visible when they are illuminated by a light source. This light is reflected at the surface and absorbed in the eye by cones or rods (see Figure 1). Light is a form of electromagnetic radiation that has both wave and particle properties. Physically based rendering aims to simulate the behaviour of light as physically plausible as possible, taking the physical properties of the surfaces into account.

The following article explains some basics of physically based rendering, referring mostly to the work of Pharr et al. [PHJ16] and focusing on topics that are important to understand and implement a path tracing algorithm. For this purpose, first the sources of radiation are explained and then the models used to calculate the reflection properties of surfaces are described.

Radiometric quantities

First, the most important physical quantities and their relation to each other are explained. It should be noted that there are both radiometric and photometric designations for each quantity. In radiometry, electromagnetic radiation is measured, while photometry focuses on the observation of visible light. In the context of this work, the radiometric designations are used.

Steradian
Figure 2: The steradian is a unit of measurement for the solid angle. On a sphere with a radius of r, a steradian encloses an area of 1 r².

Some of the quantities are measured via a solid angle, the 3D equivalent of the arc angle in 2D space. The solid angle describes the area A in relation to the square of the radius of the sphere and is given in steradians $sr$:
Steradians Formula
The full solid angle corresponds to the surface of the entire unit sphere, i.e. 4 $\pi$$sr$. When talking about incoming or outgoing radiation on a surface, the radiation is measured in relation to the surface on the sphere that is pierced by the radiation. Since a single direction penetrates an infinitesimally small area on the sphere one uses the differential solid angle $d\omega$ to describe an infestimal range of directions. As in other works, the symbol $\omega$ is used for the normalised direction and d for the differential solid angle when integrated over a spherical surface [Wyn00]. Finally, it should be noted that all directions $\omega$ can be given in normalised spherical coordinates. Thus a direction $\omega$ can also be described as a combination of polar angle $\phi$ and azimuth angle $\theta$.

The amount of radiant energy Q refers to the total energy loss that the source suffers from the radiation. A radiation source permanently emits photons, each of which has an energy of
Radiant Flux Formula
contained. Accordingly, the amount of radiation is the sum of the energy of all photons that are emitted by the emitter. h is the Planck constant, c the speed of light and $\lambda$ the wavelength of the emitted photon.

Radiation Flux and Radiation Intensity
Figrue 3: Schematic representation of the radiation flux and intensity.

$Radiant flux$ $\Phi$ refers to the amount of radiation emitted per time from a point light source
Energy Emittet Formula
and is expressed in $watts$ (see Figure 3a).

The $radiant$ $intensity$ I indicates how much radiation per solid angle is emitted by the emitter (see Figure 3b)
Radiant Intensity

This is particularly useful to describe in which direction the source emits more or less radiation. This is expressed in watts per sr.

Irradiance and Radiance
Figure 4: Schematic representation of the irradiance E and the radiance L.

The $irradiance$ E indicates how much radiation reaches the receiver per infestation area $\mathrm{d}A$
Irradiance Formula
(see Figure 4a). This is contrasted with the $radiosity$ B, which uses the same formula to say how much radiation leaves an emitter per area $\mathrm{d}A$:
Radiosity Formula
Both quantities are given in watts per m² (see Figure 4b).

The last and most important radiometric quantity is the $radiance$ L. The radiance indicates how much radiation is emitted from a given point of the radiation source in a specific direction. It is defined as the radiant flux $\mathrm{d}\Phi$ transmitted per visible receiver area $\mathrm{d}A \cos\theta$ and solid angle $\mathrm{d}\omega$
Radiance Formula
and is expressed in watts per m²sr.

Definition of the used light sources

A point light is a radiation source without spatial expansion. The source is therefore infinitely small, has no surface area and emits an equal amount of radiation in all directions. The irradiance decreases quadratically with the distance to the radiation source. In addition, the irradiance also depends on the angle $\theta$ between the normal of the irradiated surface and the irradiation direction, since the 'seen' surface decreases in size with a larger angle between the surface normal and the radiation direction. Thus, the irradiance by a point light can be determined according to the photometric distance law as follows:
Point Light Formula

In addition, Lambert emitters are also used as radiation sources. Lambert emitters are a radiation source that appears equally bright from any viewing angle. This results in a cosine-weighted intensity distribution, which is due to the fact that the 'seen' area also decreases with a larger viewing angle $\theta$ and the radiation density therefore remains constant:

Lambert Emitters Formula

Bidirectional Reflectance Distribution Function

A Bidirectional Reflectance function defines the reflectance properties of surfaces of different materials. With the help of the quantities described above, it is possible to say that a bidirectional reflectance distribution function describes a material by defining the ratio of incoming of incoming irradiance $\mathrm{d}E$ from direction $\omega_i$ to outgoing irradiance $\mathrm{d}L$ in a direction $\omega_o$ at the surface

Bidirectional Reflectance Function

Bidirectional reflectance distribution functions, abbreviated BRDF in the following, are wavelength-dependent and describe a different ratio for each wavelength. However, the BRDF is mostly not defined for the entire spectrum, but only RGB values are used and the function is only evaluated for the colours red, green and blue.

Theoretically, any behaviour of a material can be described with a BRDF. Since in physically based rendering emphasis is placed on a physically plausible behaviour of the surfaces, BRDFs are subject to some restrictions. One speaks of a physically plausible BRDF if it fulfils the following properties:

  1. It is not negative:
    Bidirectional Reflectance function Not Negative Formula

  2. It satisfies the law of conservation of energy. This means that the total reflected radiation of the surface must not exceed the irradiance acting on the surface [Wyn00]:
    Bidirectional Reflectance Total Reflected Formula

  3. It satisfies Helmholtz reciprocity, which states that the radiation flux gives identical results both forwards and backwards. This means that the BRDF remains unchanged even if the radiation source and the observer are swapped:
    Helmholtz Reciprocity

BRDF models

There are basically two ways to represent a BRDF. On the one hand, there is the possibility of measuring a sample by means of a gonioreflectometer and storing the measurement results in a matrix depending on the angle of incidence and angle of reflection of the radiation. These measured BRDFs are recorded in databases and can be used to render objects, e.g. [MPBM03]. On the other hand, BRDFs can be approximated using analytical functions. The latter approach is the most common, since the calibration leads to a not inconsiderable volume of data.

The Lambert BRDF is one of the simplest and most basic descriptions of a surface reflection, describing only diffuse reflections. It was developed by Lambert [Lam60] more than 200 years ago and is the most widely used BRDF model in computer graphics. Here, the surface itself becomes a Lambert emitter through irradiation, appears equally bright from all observed directions and is called a Lambertian reflector:
Lambertian Reflector BRDF Formula

$\rho(\lambda)_d$ is the reflectance, which takes a value between 0 and 1 for each wavelength and is defined as a constant ratio between the total incoming and the total outgoing radiant flux for that wavelength
Reflectance Formula

BRDFs can be combined as a weighted sum. Therefore, they can be divided into components with which each aspect can be described separately [TS67]. A Lambert BRDF is therefore often combined with other BRDFs that describe the specular component. Care must be taken to ensure that the combination of BRDFs meets the above criteria for physical plausibility. Thus, the BRDFs used in this work consist of a diffuse $f_d$ and a specular component $f_s$, whose weighted sum gives the resulting BRDF:

BRDF Sum Formula

An example of a definition of a specular component would be the BRDF for a perfectly specular surface, which is described by means of the Dirac delta function and takes the value 0 everywhere except for the reflected beam,

Specular Surface BRDF Formula

and the following conditions are met:

Specular Surface BRDF Condition Formula

The ratio between diffuse and specular reflection can be determined by means of the Fresnel reflectance $F(\theta)$. Fresnel reflectance is often associated with transparent surfaces to determine the ratio between reflection and transmission. This is also applicable to opaque materials because, as in the case of plastic, there are pigments in the material which in turn diffusely reflect the transmittance [CT81]. The ratio of reflection and transmission depends on the refractive index of the respective medium and the angle of incidence of the radiation. In addition, the polarisation of the radiation influences its reflection behaviour, which is why the calculation of the Fresnel reflection is carried out with a parallel and an orthogonal component.

The reflectance consists of the parallel component

Reflectance Parallel Component

and the orthogonal portion,

Reflectance Orthogonal Component

while its sum gives the reflectance for unpolarised radiation

Reflectance Unpolarised Radiation

Here $\eta_1$ is the optical density of the medium in which the radiation is located before transmission, while $\eta_2$ indicates the optical density of the medium into which the radiation penetrates.

While dielectric materials reflect the radiation either diffusely or completely specularly according to the Fresnel reflectance, conductors have a special reflectance behaviour because, on the one hand, they have no diffuse reflectance properties at all and, on the other hand, part of the radiation is absorbed, depending on the wavelength. The reflection coefficient for conductors is calculated from the parallel component

Reflection Coefficient Parallel Component

and an orthogonal portion

Reflection Coefficient Orthogonal Component

is calculated. Here $\eta$ is the refractive index of the material, while k is the absorption coefficient. The reflectance of unpolarised radiation can also be determined using Equation 2.21

The BRDF described above is suitable for approximating smooth surfaces. However, the result deviates strongly from the reflection behaviour of rough surfaces, which is why microfacet models are used to simulate rough surface structures for both the diffuse and the specular components. Microfacet BRDFs are illumination models based on physics-based models. Here, the surface is modelled by many smaller randomly oriented facets, which allows the simulation of roughness and self-shadowing.

Cook-Torrance BRDF/Torrance-Sparrow BRDF

Torrance and Sparrow [TS67] first presented a model for calculating the specular component of rough surfaces in 1967, and Cook and Torrance [CT81] developed a general local illumination model based on this in 1981

General Local Illumination Model Formula

It should be noted that this equation is the variant of Pharr et al [PHJ16] or that of Torrance and Sparrow [TS67], since the original equation of Cook and Torrance's work violates the law of conservation of energy. This equation consists of the Fresnel term $F_r$, a density function D and a geometric attenuation factor G, which are explained in detail below.

Cook and Torrances Figure
Figure 5: The surface of a microfacetted BRDF is represented as a collection of many small facets.

The microfacet model of Torrance and Sparrow assumes that the surface of, for example, rough metals or plastics consists of a number of small specular facets whose reflections can each be calculated using Equation 2.17. Figure 5 schematically represents a specular reflection on a rough surface modelled by microfacets. For the calculation of the direct reflection of the rough surface, only the microfacets are interesting whose normal coincides with the half vector $\omega_h$, i.e. is oriented in such a way that the incoming radiation from direction $\omega_i$ is reflected in direction $\omega_o$

Half Vector Formula

The density function D gives the fraction of microfacets whose normal points in the direction of the half-vector $\omega_h$ and can be freely chosen. Torrance and Sparrow [TS67] propose a Gaussian distribution in their work, while in the work of Cook and Torrance [CT81] a Beckmann distribution is recommended, which is also used in this work.

Cook and Torrance Beckmann Distribution Function Formula

The roughness of the surface is defined by the standard deviation $\sigma$ of the orientation of the microfacets [PHJ16] and is given in radians.

Roughness Self-shadowing and Masking
Figure 6: The self-shadowing and masking of the surface caused by neighbouring facets and approximated with the geometric attenuation factor.

The geometric attenuation factor G takes the masking (see Figure 6a) and shading (see Figure 6b) of a facet by a neighbouring facet into account. For this, it is assumed that each specular facet has a symmetrical counterpart and that these together form V-shaped notches (V-cavities). The attenuation factor is defined by the ratio of the part of the facet $l-m$ involved in the reflection to the total surface l, taking into account only simple specular reflections and assuming inter-reflections to be perfectly diffuse:

Attenuation Factor Forumla

The Cook-Torrance model is suitable for simulating metals and non-metallic surfaces without diffuse content such as black plastic. The results of the simulation show strong agreement with real measurements [TS67].

Oren-Nayar BRDF

In 1994, Oren and Nayar [ON94] presented a local illumination model for simulating rough diffuse surfaces based on the microfacet model of Torrance and Sparrow. Oren and Nayar observed through experiments that the perceived brightness of a rough surface increases depending on the viewing direction $\omega_o$ as it approaches the illumination direction $\omega_i$, thus deviating from the Lambert model which makes surfaces appear equally bright regardless of the viewing angle considered.

Oren-Nayar BRDF Microfacet Model Figure
Figure 7: The microfacet model according to Oren and Nayar [ON94], whose gaze direction dependence is caused by self-shadowing, masking and inter-reflections.

Analogous to the microfacet model of Torrance and Sparrow, the model of Oren and Nayar is based on many small Lambert facets and thus also simulates shadowing and masking by neighbouring facets, but additionally extends the model by inter-reflections between the V-notches (see Figure 7). In contrast to the Cook-Torrance BRDF, the density function is not freely selectable here and a Gaussian distribution of the facet surfaces is assumed. Since the evaluation of the distribution would require integrating over the hemisphere, a functional approximation was aimed at, which fulfils the properties

Self-Shading and Masking Formula

and calculates the shading and masking, while

Inter-Reflections Formula

using the coefficients

Self-Shading and Masking Formula and Inter-Reflection Coefficients

to calculate the inter-reflections. The BRDF is calculated with the sum of both terms:

Oren-Nayar BRDF Sum Formula

Note that for smooth surfaces the coefficients $C_2$, $C_3$ and the interreflection fraction take a value of 0, while $C_1$ takes a value of 1, resulting in the BRDF being reduced to the Lambert model.

The approximation of Oren and Nayar, like the model of Cook and Torrance, shows high agreement with the measured data for rough surfaces such as sandpaper, cloth and plaster. Together with the local illumination model for specular surfaces presented in the previous subchapter, the microfacet models presented each form one of the components for a common BRDF.

Rendering Equation

In 1986, Kajiya presented [Kaj86] the often quoted rendering equation, which describes in a general form the radiation at a point $\mathrm{x}$ in one direction $\omega_o$. This equation forms the basis for Global Illumination and brings everything together. Instead of the original formula, the rendering equation is used here in an equivalent form of representation, as it describes the application case in this work more clearly

Kajiya Rendering Equation

The emission term $L_e$ describes the self-emission of the surface at point $\mathrm{x}$ in direction $\omega_o$, if the surface is a radiation source, while the term $L_i$ describes the incoming radiation at point $\mathrm{x}$ from direction $\omega_i$. The term $f_r$ is the BRDF as described in the previous subsection.

Schematic Representation Of Rendering Equation
Figure 8: Schematic representation of the rendering equation. The outgoing radiation $L_o$ in direction $\omega_o$ is calculated by integrating the incoming radiation $L_i$ from all directions $\omega_i$ over the hemisphere.

As figure 8 schematically shows, in order to calculate the radiation reflected and/or emitted in the direction $\omega_o$, the incoming radiation from all directions $\omega_i$ is integrated over the entire hemisphere. It should be noted that the calculation of the term $L_i$ again requires an integration over the entire hemisphere at the point from which the radiation is emitted/reflected that impinges on point $\mathrm{x}$ from direction $\omega_i$. This is therefore a recursion and the illumination at the point $\mathrm{x}$ depends on the illumination of all other points $\mathrm{x}'$, which is expressed by the original formulation of the rendering equation:

Original Rendering Equation

Here $L_r^o$ indicates how much radiation reaches the point $\mathrm{x}$ from $\mathrm{x}'$, while b is a BRDF that indicates the fraction of radiation that reaches the point $\mathrm{x}'$ from $\mathrm{x}''$ and is reflected in the direction of $\mathrm{x}$. g is the geometric term describing the radiation fall-off due to the mutual position of the points $\mathrm{x}$ and $\mathrm{x}'$ and corresponds to the distance law. $L_e^o$ describes analogously to $L_e$ how much radiation emitted from $\mathrm{x}'$ reaches the point $\mathrm{x}$. S is the union of all surfaces over which the integration takes place.

In contrast to local illumination models, which focus on the direct illumination of the surface by visible radiation sources, methods that attempt to solve or approximate the render equation are called global illumination models.

Path Tracing

In the same paper in which Kajiya presented the render equation, he presented a method to solve it using Monte Carlo Integration. Monte Carlo integration is a method of approximately solving an integral by randomly sampling the function:

Monte Carlo Integration Equation

The estimate of the integral is obtained by evaluating the function with a density of $p({\omega_i})$ and averaging these values. The density $p({\omega_i})$ can be chosen arbitrarily, but in the optimal case it resembles the function to be evaluated, because the closer $p({\omega_i})$ resembles the function to be evaluated, the faster the arithmetic mean converges towards the actual integral of the function, while, even with poorly chosen density functions, the estimate of the integral becomes more accurate with an increasing number of samples. If the course of the function is unknown, a constant density $p({\omega_i}) = 1$ can therefore also be chosen with a simultaneously high number of samples.

The implementation of the Path Tracing algorithm simulates the path of photons from the radiation source to the viewer by tracing the path from the sensor to the source. So instead of calculating rays that originate in the radiation source and hit the sensor either directly or through reflections off surfaces, for each pixel of the image to be calculated several rays are sent into the scene from the viewer and the path is traced back to the radiation source. For this purpose, at each intersection point of a ray, a surface is used to test whether it is irradiated by one or more radiation sources, whereupon their proportional reflection in the direction of the ray origin is calculated. For each intersection of the beam with a surface, a new beam is then generated in a random direction whose new origin is the calculated intersection. This is repeated recursively until a termination condition, e.g. a maximum path length, is met. Depending on the scene, the BRDF and the chosen density $p({\omega_i})$, the computation of the result may require a high number of rays, resulting in a long computation time.

The implementation of a path tracer will be the subject of another article.

Bibliography
[PHJ16] Matt Pharr, Greg Humphreys, and Wenzel Jakob. Physically Based Rendering. Elsevier LTD, Oxford, 2016.
[Wyn00] ChrisWynn. An introduction to brdf-based lighting. Technical report, NVIDIA Corporation, 2000.
[MPBM03] Wojciech Matusik, Hanspeter Pfister, Matt Brand, and Leonard Mc-Millan. A data-driven reflectance model. ACM Transactions on Graphics, 22(3):759–769, July 2003.
[Lam60] J. H. Lambert. Photometria Sive De Mensura Et Gradibus Luminis, Colorum Et Umbrae. Eberhard Klett, 1760.
[TS67] Kenneth E. Torrance and Ephraim M. Sparrow. Theory of off-specular reflection from roughened surfaces. Journal of the Optical Society of America, 1967.
[CT81] Robert L. Cook and Kenneth E. Torrance. A reflectance model for computer graphicsa reflectance model for computer graphics. In ACM SIGGRAPH 1981, 1981.
[ON94] Michael Oren and Shree K. Nayar. Generalization of lamberts reflectance model. SIGGRAPH, 1994.
[Kaj86] James T. Kajiya. The rendering equation. In Proceedings of the 13th annual conference on Computer graphics and interactive techniques (SIGGRAPH) 1986, ACM Press, 1986.
Profile picture

Artur Schütz

Senior Software Developer specializing in C++ graphics and game programming. With a background as a Full Stack Developer, Artur has now shifted his focus entirely to game development. In addition to his primary work, Artur explores the field of Machine Learning, experimenting with ways to enrich gameplay through its integration.