Implementing Reflection Models in Computer Graphics



In the last chapter, we presented some real-world examples of reflection models. We saw glossy metals, rough papers, glass materials and so on. In this chapter, we will see how to implement those reflection models in computer graphics, focusing on the basics and providing examples for better understanding.

We will understand the Bidirectional Reflectance Distribution Function (BRDF), energy conservation, reciprocity, and properties needed for successful implementation. We will also look at examples like specular reflections in metals and dielectrics for a better understanding on implementation.

Basics of Reflection Models

Reflection models are used in describing how light behaves when it interacts with a surface. In computer graphics, we often use the BRDF to describe these interactions.

A BRDF tells us how much light is reflected from a surface based on the angle of incoming light and the viewing angle. This function is important for creating realistic reflections and lighting in a scene.

Importance of Reflectance Distribution Function

We have seen already that a BRDF model produces a rendering that is more physically based compared to simple models like point light sources or Phong-like models. The main challenge is that real BRDFs are often too complex for direct implementation. This is where simplified models come into play. These models use basic principles of light reflection and refraction to simulate different materials in a believable manner.

Desirable Properties of Reflection Models

For a reflection model to work correctly in computer graphics, it needs to meet certain properties. These properties ensure that the model behaves realistically and is suitable for rendering purposes.

The most important properties include −

  • Energy Conservation − This means that the total amount of light reflected should never exceed the amount of light that hits the surface. If we send a beam of light at a surface from any direction, the total amount of light reflected in all directions should be at most the amount of incident light. This property ensures that the material does not appear to glow or produce more light than it receives.
  • Reciprocity − This means that the BRDF should behave the same way if the directions of incoming and outgoing light are reversed. This property is used for creating realistic reflections. It tells that the surface appears the same when viewed from different angles.
  • Separation of Diffuse and Specular Components − This helps in handling specular highlights separately from the diffuse reflections. It is used to make the model more flexible and easier to implement, as it separates the light that reflects directly from the surface (specular) from the light that scatters within the surface (diffuse).
  • Intuitive Parameters − The parameters of the BRDF should have clear physical meanings. For example, in the Phong model, the diffuse constant and exponent directly relate to surface properties like color and highlight size. This makes it easier for artists and developers to tweak the parameters and achieve the desired look.
  • Monte Carlo Sampling − The BRDF should be easy to integrate using sampling techniques like Monte Carlo methods. This is important for rendering because it helps to get efficient computation of light interactions with the surface.

Implementing the Reflection Models

So far, we have seen several properties. Let us discuss how to implement them. Implementing a reflection model starts by defining the BRDF for the surface. The BRDF can be derived based on measurements or approximations. In most implementations they uses empirical models that provide a good balance between accuracy and computational efficiency.

For example, the surface radiance in a particular direction can be calculated using the transport equation −

$$\mathrm{L_s(k_o) \:=\: \int_{\forall k_i} \:\rho(k_i,\: k_o)\: L_f(k_i)\: \cos \theta_i \: d\sigma_i}$$

This equation gives the surface radiance in a given direction (ko). It considers all the incoming light directions (ki) and the BRDF (ρ(ki, ko)). The integration over all incoming directions gives the total light reflected from the surface.

If we sample the incoming directions with a probability distribution function (pdf), we can approximate the surface radiance using a finite number of samples −

$$\mathrm{L_s(k_o)\: \approx \frac{1}{N}\: \sum_{j=1}^{N}\: \frac{\rho(k_j,\: k_o)\: L_f(k_j) \cos \theta_j}{p(k_j)}}$$

This approximation converges to the true value as the number of samples (N) increases. The choice of the probability distribution function (p) is important because it affects the convergence of the approximation. Ideally, the pdf should be shaped similarly to the BRDF to minimize the variance.

Specular Reflection Models

Let us see the specular reflections that are sharp reflections models. These occur on smooth surfaces like metals or glass. These reflections are highly directional and depend on the incident angle of light. For metals, the reflectance at normal incidence (R0) is used to determine how much light is reflected. The reflectance should vary according to the Fresnel equations.

A good approximation for reflectance in metals is given by Schlick’s formula −

$$\mathrm{R(\theta,\: \lambda) \:=\: R_0(\lambda) \:+\: (1 \:+\: R_0(\lambda)) (1 \:-\: \cos \theta)^5}$$

This formula shows the set the normal reflectance value (R0) for the metal based on measurements or visual observations. The reflectance increases as the incident angle increases, creating a realistic metallic appearance.

For dielectrics, the same formula can be used, but the reflectance at normal incidence is determined by the refractive index (n) −

$$\mathrm{R_0(\lambda) \:=\: \left( \frac{n(\lambda) \:-\: 1}{n(\lambda) \:+\: 1} \right)^2}$$

Dielectrics, like glass or water, have a lower reflectance compared to metals. The refractive index controls how much light is reflected and how much is transmitted through the material.

Specular Reflection Models

Implementing Monte Carlo Sampling

The Monte Carlo sampling is a technique used to evaluate the BRDF for rendering. It samples random points from a probability distribution and using these points to approximate the integral of the BRDF. The pdf should be chosen to match the shape of the BRDF as closely as possible to achieve good results.

For example, if the BRDF is Lambertian (constant reflectance), then the ideal pdf is proportional to cos θ. This means that we should sample directions with a probability proportional to the cosine of the angle. This choice ensures that the sampled directions cover the important areas of the BRDF, leading to better convergence.

Conclusion

In this chapter, we explained how to implement reflection models in computer graphics. We covered the basics of the BRDF, energy conservation, and reciprocity. We also looked at desirable properties like separation of diffuse and specular components and Monte Carlo sampling.

We also provided examples of specular reflection models for metals and dielectrics. Understanding these concepts is essential for creating realistic renderings and achieving lifelike graphics in computer-generated images.

Advertisements