Saturday, May 5, 2012

Diffuse and Specular Reflection

A deeper understanding of the physics of light can help us write better renderers, and beyond rendering, can give us a deeper understanding and appreciation of the real world. In this post, I'll talk about the nature of diffuse and specular reflection, and address some potential misconceptions.

An illustration of diffuse and specular reflection.
(The diffuse part appears round instead of semicircular,
because the image shows radiant intensity, not radiance.)
Image by GianniG46, found on Wikimedia Commons.

Diffuse reflection (at least the type we talk about in computer graphics), is not, as some sources would lead you to believe, reflection from a rough surface. It's not a special case of specular reflection, but rather a separate phenomenon that can coexist with specular reflection. It's not the case that there's a continuum between diffuse and specular reflection; as an example, no matter how smooth you make a block of marble (or granite, plastic, ceramic, paint, etc.), it will never turn into a perfect mirror [1]. Specular reflection is surface reflection, and diffuse reflection can be thought of as body reflection [2]. The primary means of diffuse reflection is actually subsurface scattering and absorption [1]. Rough surfaces can cause a sort of diffuse reflection, but we usually classify that and any other surface reflection as specular reflection [3][4].

A close-up illustration of diffuse reflection.
Image by GianniG46, found on Wikimedia Commons.

All dielectric materials (insulators / non-metals) are translucent and exhibit subsurface scattering and absorption to some extent [5]. Light enters a material, is scattered around and partially absorbed below the surface, and comes back out somewhere else at a different angle [6]. As the light propagates and scatters through the medium, certain wavelengths are absorbed more strongly than others, giving the object its color (e.g., the yellow of a banana or the green of grass). Absorption is a subtractive process, just like the way ink makes paper appear a certain color by absorbing and subtracting certain wavelengths of light. Different wavelengths are scattered differently as well, which also contributes to the appearance of the material. We can approximate the result of this subsurface scattering with a BRDF like the Lambertian reflection model, if we assume that light enters and exits the material at the same point, and exits in a random direction. However, when this is not the case, we need to use a BSSRDF or otherwise simulate subsurface scattering to make the object look realistic. Either way, this diffuse reflection / subsurface scattering and absorption is the primary means by which we see objects in the world [1].

Dielectrics also exhibit specular reflection from their surfaces based on their refractive indexes. When light strikes an interface between dielectrics with different indexes of refraction, some of the light is reflected and some of the light is transmitted. The proportion of light reflected or transmitted is based on the incident angle and the relative index of refraction, and can be predicted by the Fresnel equations. (The Fresnel equations also predict phase shift and polarization, but these things are almost always ignored in computer graphics, because in common cases they don't have much effect on the appearance of the render.) The amount of diffuse reflection is actually dependent on the amount of specular reflection; i.e., only the light that is not reflected from the surface of the object is transmitted and is available for subsurface scattering (and thus diffuse reflection). Renderers that simply add diffuse and specular contributions will not conserve energy, especially at grazing angles where surface reflectivity approaches 100% (try viewing a flat object from a grazing angle and you'll notice that it practically turns into a mirror.). And renderers that try to overcome the problem using global diffuse and specular multipliers will never be able to achieve diffuse or specular of full brightness and saturation.

Metals (conductors) behave differently than dielectrics in a number of ways. They do not transmit light, and do not exhibit subsurface scattering [7]. The characteristic color of copper or gold is not due to diffuse reflection, but rather certain wavelengths being reflected more strongly from the surface than others. For non-metals, the color of specular reflection is generally the same as the color of the illumination (at least within the visible spectrum), but for metals this is not necessarily true.

Spectral reflectance curves of three different metals.
Image from Wikimedia Commons.

Some sources will use the term specular reflection to refer specifically to ideal (perfectly flat mirror) specular reflection from a smooth surface. In computer graphics however, specular reflection generally can be from a smooth or rough surface. Sometimes we also use the term glossy reflection to refer to specular reflection from a rough surface. We simulate ideal specular reflection using the basic angle of incidence equals angle of reflection law, and we simulate specular reflection from rough surfaces using a microfacet model, where the surface is composed of infinitesimally small ideally specular facets.

Not only is diffuse reflection not caused by surface roughness (although surface roughness certainly results in more diffuse specular reflection in the general sense of the word), the Lambertian reflection model that is prevalent in computer graphics specifically assumes a perfectly smooth surface. Many real-life things—such as the moon, concrete, or plaster—don't actually exhibit Lambertian reflectance at all. This is because these things have rough surfaces. Unlike Lambertian (smooth diffuse) surfaces which appear the same from any viewing angle, the appearance of rough diffuse surfaces varies based on viewing angle (it's directional). We can model this appearance analogously to how we model rough specular reflection, in this case using a microfacet model where each microfacet is a Lambertian reflector. The Oren-Nayar BRDF model does exactly this [2][8].

Things aren't quite as simple in the real world as I've descibed here (or maybe they're simpler depending how you look at it), but the things above should nonetheless be useful for creating more realistic renders [9]. Most of ray tracing deals with geometric optics, but in reality light is electromagnetic radiation with many strange and mysterious properties, such as its dual wave–particle nature, and the fact that it's composed of photons which behave probabilistically [10]. A more complete understanding of how it works requires an understanding of quantum mechanics, relativity, etc., which are very low-level, fundamental things that are very unintuitive for humans because they can't necessarily be explained in terms of things we're familiar with first-hand, things from our everyday lives. And nobody understands fully why these things work the way they do. Luckily, approximations are good enough for computer graphics and many other applications. To truly simulate all effects of light accurately, you would basically have to program the universe.

Things are not always as they seem.
(Shown here, a Feynman diagram, used in quantum mechanics.)
Image from Wikimedia Commons.



References and Further Reading:
[1] Wikipedia: Diffuse reflection
[2] Generalization of Lambert's Reflectance Model (the Oren-Nayar paper)
[3] Wikipedia: Scattering 
[4] A Comprehensive Physical Model for Light Reflection
[5] A Quantized-Diffusion Model for Rendering Translucent Materials
[6] Photon Path Distribution in Inhomogeneous Scattering Media (starting at page 30)
[7] A Microfacet-based BRDF Generator (metals; end of section 5.1 mainly)
[8] Oren-Nayar reflectance model
[9] An Inexpensive BRDF Model for Physically-based Rendering (Schlick's 1994 paper)
[10] Richard Feynman lectures on quantum electrodynamics (QED) (excellent videos; there are also lots of great Richard Feynman videos on Youtube)

1 comment:

  1. Great post, very informative with an interesting conclusion. Thanks

    ReplyDelete