7Plastic

In the past decade, we have witnessed the development of a number of systems for the rendering of solid objects by computer. The two principal problems encountered in the design of these systems are the elimination of the hidden parts and the shading of the objects. Until now, most effort has been spent in the search for fast hidden surface removal algorithms. With the development of these algorithms, the programs that produce pictures are becoming remarkably fast, and we may now turn to the search for algorithms to enhance the quality of these pictures.
In trying to improve the quality of the synthetic images, we do not expect to be able to display the object exactly as it would appear in reality, with texture, overcast shadows, etc. We hope only to display an image that approximates the real object closely enough to provide a certain degree of realism. This involves some understanding of the fundamental properties of the human visual system. Unlike a photograph of a real world scene, a computer generated shaded picture is made from a numerical model, which is stored in the computer as an objective description. When an image is then generated from this model, the human visual system makes the final subjective analysis. Obtaining a close image correspondence to the eye's subjective interpretation of the real object is then the goal. The computer system can be compared to an artist who paints an object from its description and not from direct observation of the object. But unlike the artist, who can correct the painting if it does not look right to him, the computer that generates the picture does not receive feedback about the quality of the synthetic images, because the human visual system is the final receptor.
Bui Tuong Phong, “Illumination for Computer Generated Pictures,” Communications of the ACM, Volume 18, Number 6, June, 1975.
 

MDL represents a change of paradigm that requires a reevaluation of many traditional computer graphics ideas, and suggests a return to first principles. One of the venerable lighting models that came to define the “plastic” appearance of early computer-generated imagery was published by Bui Tuong Phong in 1975. This chapter considers the assumptions made by Phong in the development of his lighting model and how they correspond to the simulation of plastic in MDL.

In his landmark paper of 1975, Bui Tuong Phong made two fundamental contributions to “the rendering of solid objects by computer.” The first was an improved shading function, defined by Phong in the paper as

a function which yields the intensity value of each point on the body of an object from the characteristics of the light source, the object, and the position of the viewer.(Bui Tuong Phong, ibid.)

At that time, the typical shading function depended upon the weighted average of the color calculated at the vertices of a polygon, a method published by Henri Gouraud in 1971 and called Gouraud shading. Instead of averaging the colors at vertices, Phong's technique averaged the normal vectors at the vertices of the polygon to calculate the average normal vector of the point to be shaded. Phong shading, as this method is now called, produced much better results for “transparency and highlight effects,” as shown in this illustration from Phong's 1975 paper:

Fig. 7.1 – Bui Tuong Phong,“Illumination for Computer Generated Pictures,” 1975

The second contribution of Phong's paper was a method of adding “specular highlights” to the calculation of diffuse reflection. These brighter areas of a rendered object simulate the blurred reflections of light sources modeled as geometric points in space. (Later illumination models, including the model implemented by MDL, reserve the term “specular” for perfect mirror reflections and instead call blurred reflections due to surface roughness “glossy.” See “Specular interaction at a surface” and and “Glossy interaction” for a description of specular and glossy components in MDL.)

Here is Phong's formula from the original paper:

Sp = Cp [cos(i)(1 – d) + d] + W(i)[cos(s)]n

where (quoting from the paper):

Cp is the reflection coefficient of the object at point P for a certain wavelength.
i is the incident angle.
d is the environmental diffuse reflection coefficient.
W(i) is a function which gives the ratio of the specular reflected light and the incident light as a function of the incident angle i.
s is the angle between the direction of the reflected light and the line of sight.
n is a power which models the specular reflected light for each material.

The terms of Phong's equation can be grouped into five categories that define the diffuse and specular components.

Fig. 7.2 – Categorizing the terms of the Phong equation

The term d, the “environmental diffuse reflection coefficient” is a directionally independent scalar value and not a color. Early commercial rendering applications typically called this value the “ambient light”—the light that is present because of environment interreflections—and implemented it as a color value. In Phong's equation, d only increases the intensity of the object's color without regard to the incident angle i, simulating a base level of light striking all surfaces.

A second interesting feature of this equation is that the specular component is a scalar value, and, like the environmental term d, is not a color. Adding this scalar value was typically implemented in early rendering systems as a scaling factor of the incoming light color. Coincidentally, highlights that duplicate the color of the light source on a diffuse reflective surface simulate the visual appearance of plastic. Perhaps the unintended look of plastic due to the scalar specular term of the Phong equation helped contribute to the early criticism of computer-generated imagery as cheap and inauthentic.

The Phong model makes several assumptions about light-surface interaction that provide a strong contrast with the physically based approach of MDL.

Direct illumination only
The diffuse and specular terms of the Phong equation are calculated as the surface interaction of a source of light, typically modeled as a geometric point without area. Only the direct contribution of the light from the light objects is considered in calculating the diffuse and specular terms. To provide for light reflected from other surfaces, the Phong model adds a constant value—the “environmental diffuse reflection” term d in the Phong equation—that represents perfect diffuse reflection. This term d approximates light reflected from other surfaces as an increase that is constant throughout the scene. This constant value is simply added to the calculation based on the light objects. The interreflections between two objects that are spatially close to each other are not represented by the approximation.
Light objects and the light loop
To calculate the effect of all light objects in the scene, the Phong model assumes an iteration through them to accumulate their individual contributions to the shading of the surface point being rendered. This iteration is often called the light loop. MDL does not define a special type of object that emits light nor does it provide a language stucture for iterating through a set of such light objects. Instead, a surface can emit light, defined as a property in the material struct that is similar in its MDL representation to the properties of reflection and transmission. Distribution functions in the material properties provide a single mechanism for all light interaction, eliminating both the explicit accumulation of light object contributions and the need for a compensating approximation of light from other surfaces.
Highlights as the only reflections

The “specular” component in the Phong model is a scalar value that is added to the diffuse color calculation for each light object. As a scalar value, the specular component can only serve to brighten the diffuse color, simulating an additional white light striking that surface point. Though this appears as a reflection of a light source on the surface of the object, no other objects in the scene are reflected.

The final term in the Phong equation, a cosine function raised to a power, controls the spatial area over which the highlight is distributed. The exponential term n, often called the “Phong exponent” in rendering applications, affects the degree to which the light is spread across the surface. Because the blurriness of a reflection can be due to the roughness of the surface, the Phong exponent value is often available in the user interface as a means of artistic control of the surface's apparent roughness.

Empirical derivation of a non-physically based formula

In the paper, Phong describes the calculation of the specular component of the model:

The function W(i) and the power n express the specular reflection characteristics of a material. For a highly reflective material, the values of both W(i) and n are large. The range of W(i) is between 10 and 80 percent, and n varies from 1 to 10. These numbers are empirically adjusted for the picture, and no physical justifications are made.(Bui Tuong Phong, ibid.)

As the parameters of the Phong equation are adjusted, the amount of reflected light at a point can easily be made greater than the total amount of light striking that point. For rendering systems that only calculate direct illumination, arbitrary adjustments made to the reflection parameters of individual objects have no effect on the light received by other objects. (It is in this sense that direct illumination is also called “local illumination.”) However, in rendering systems that are based on the physics of light interaction between objects, an object that reflects more light than it receives is adding light energy to the scene, violating the physical principle of energy conservation.

The following sections of this chapter begin with an imitation of the Phong model in MDL, followed by a set of strategies for better physical simulations of the interaction of light and plastic.

The diffuse and specular components of the Phong model are represented in MDL by the distribution functions df::diffuse_reflection_bsdf and df::simple_glossy_bsdf. To simulate a “Phong BSDF,” these two components need to be combined but in a manner that preserves the principle of energy conservation. The control of the spread of the reflection by the exponent in the Phong equation is represented in the df::simple_glossy_bsdf by the relatively more intuitive parameter of roughness.

In the following material, called phonglike_plastic, intensity parameters provide scaling factors for the diffuse and specular color parameters. The df::normalized_mix BSDF combining function proportionally scales these factors if they exceed 1.0, providing an implementation of the desired limitation of the reflected light.

Listing 7.1
material phonglike_plastic (
   
color diffuse_color = color(0.7),
Diffuse color of plastic body
   
float diffuse_intensity = 0.8,
Intensity of the diffuse color
   
color highlight_color = color(1),
Color of the highlight reflection
   
float highlight_intensity = 0.2,
Intensity of the highlight color
   
float highlight_roughness = 0.2) =
Amount of spread of the highlight
material ( 
   surface: material_surface (
      
scattering: df::normalized_mix (
Mixing function for diffuse color and highlight
         components: df::bsdf_component[] (
            
df::bsdf_component (
   weight: diffuse_intensity,
   component: df::diffuse_reflection_bsdf (
      tint: diffuse_color )),
Diffuse component
            
df::bsdf_component (
   weight: highlight_intensity,
   component: df::simple_glossy_bsdf (
      tint: highlight_color,
      roughness_u: highlight_roughness ))))));
Highlight component

Using the phonglike_plastic material with the highlight intensity set to 0.0 produces an image of the diffuse component alone:

Figure 7.3
phonglike_plastic(
  diffuse_color:
    color(.15, .4, 0),
  diffuse_intensity: 0.8,
  highlight_intensity: 0.0)

Setting the diffuse intensity to 0.0 produces an image that only contains the “highlights” created by the df::simple_glossy_bsdf distribution function:

Figure 7.4
phonglike_plastic(
  diffuse_color:
    color(.15, .4, 0),
  diffuse_intensity: 0.0,
  highlight_intensity: 0.2)

Combining the two components with the df::normalized_mix function produces Figure 7.5:

Figure 7.5
phonglike_plastic(
  diffuse_color:
    color(.15, .4, 0),
  highlight_roughness: 0.2)

The roughness of the surface is controlled by the material's highlight_roughness parameter, passed within the material as an argument to the df::simple_glossy_bsdf distribution function:

Figure 7.6
phonglike_plastic(
  diffuse_color:
    color(.15, .4, 0),
  highlight_roughness: .05)
Figure 7.7
phonglike_plastic(
  diffuse_color:
    color(.15, .4, 0),
  highlight_roughness: .3)

The phonglike_plastic material will behave very much like the Phong illumination model. However, function df::normalized_mix will adjust the intensity parameters so that their sum is never greater than 1.0. If an application user sets one intensity parameter to a value that would create an intensity sum greater than 1.0, the other component will become darker in a potentially unexpected way.

The previous material, phonglike_plastic, implemented the Phong equation's addition of the diffuse and “specular” components by using the df::normalized_mix function. A combination of diffuse and glossy components can also be implemented by defining an order for their evalution using the df::weighted_layer function.

Listing 7.2
material phonglike_plastic_layered (
   color diffuse_color = color(0.7),
   color highlight_color = color(1.0),
   
float highlight_intensity = 0.2,
Fractional contribution of the highlight component
   float highlight_roughness = 0.2 ) = 
material ( 
   surface: material_surface (
      
scattering: df::weighted_layer (
Layering function
         
weight: highlight_intensity,
Highlight contribution fraction
         
base: df::diffuse_reflection_bsdf (
   tint: diffuse_color ),
Diffuse component
         
layer: df::simple_glossy_bsdf (
   tint: highlight_color,
   roughness_u: highlight_roughness ))));
Highlight component

Rendering with the phonglike_plastic_layered material produces Figure 7.8:

Figure 7.8
phonglike_plastic_layered(
  diffuse_color:
    color(.15, .4, 0),
  highlight_roughness: .25)

The appearance of objects in the real world is often due to layers of substances with different reflective properties, for example, a coat of varnish over an oil painting or shellac on wood. The changes to the light as it moves through these layers determines the object's ultimate appearance. The explicit order of the df::weighted_layer function enables this real-world layering to be intuitively expressed directly in MDL. The highlights of plastic are modeled in phonglike_plastic_layered as a glossy layer above the diffuse reflection of a colored base. As the contribution of the highlight layer is increased by increasing the weight parameter of df::weighted_layer, the contribution of the diffuse base component is decreased, thereby maintaining energy conservation by keeping the sum of their weights below or equal to 1.0.

Plastic is an example of a class of physical materials called dielectrics. As a dielectric, the increase in plastic's reflectivity at shallow grazing angles is pronounced. This increased reflectivity of plastic can be modeled with the df::fresnel_layer combining function. Increased reflectivity from the Fresnel effect is proportional to the index of refraction.

Listing 7.3
material dielectric_plastic (
   color diffuse_color = color(0.5, 0.04, 0.04),
   color glossy_color = color(1.0),
   
float glossy_weight = 1.0,
Relative weight of the glossy component
   float glossy_roughness = 0.05, 
   float ior = 1.54 ) = 
material ( 
   surface: material_surface (
      
scattering: df::fresnel_layer (
Fresnel-based layering function
         
ior: color(ior),
Index of refraction
         
weight: glossy_weight,
Weight parameter to control layer proportions
         
layer: df::simple_glossy_bsdf (
   tint: glossy_color,
   roughness_u: glossy_roughness),
Glossy layer
         
base: df::diffuse_reflection_bsdf (
   tint: diffuse_color ))));
Diffuse layer

Rendering with the dielectric_plastic material produces Figure 7.9 and Figure 7.10:

Figure 7.9
dielectric_plastic(
  diffuse_color:
    color(.15, .4, 0),
  ior: 1.35,
  glossy_roughness: 0.1)
Figure 7.10
dielectric_plastic(
  diffuse_color:
    color(.15, .4, 0),
  ior: 1.575,
  glossy_roughness: 0.1)

Real-world measurements for industrial plastics include their index of refraction. An MDL material can accurately simulate the reflective properties of a particular type of plastic by including its measured index of refraction in the material struct.

The “highlights” of the original Phong model simulate the reflections of small light sources, blurred across the surface by a cosine function raised to a power. Increasing the exponential term creates the appearance of increasingly rougher surfaces and the blurrier reflections they produce. The reflection characteristics of actual plastic may not be so simple, however. A sharp highlight could be surrounded by a blurred reflection that could not be simulated by the exponential property of the Phong specular term.

Complex highlights for plastic can be created by combining more than one glossy distribution function to produce multiple “lobes” as described in section 4.4.2. In the following dielectric_plastic_two_lobe material, two df::simple_glossy_bsdf instances are combined using df::normalize_mix. The result is then combined with the diffuse component using df::fresnel_layer to create the increased intensity of reflection at shallow grazing angles.

Listing 7.4
material dielectric_plastic_two_lobe (
   color diffuse_color = color(0.5, 0.04, 0.04),
   color glossy_color = color(1.0),
   
float glossy_roughness_1 = 0.05,
float glossy_weight_1 = 0.5,
Parameters of the first lobe
   
float glossy_roughness_2 = 0.25,
float glossy_weight_2 = 0.5,
Parameters of the second lobe
   float glossy_weight = 1.0,
   float ior = 1.54 ) =
material ( 
   surface: material_surface (
      
scattering: df::fresnel_layer (
Fresnel layering to combine glossy and diffuse components
         ior: color(ior),
         weight: glossy_weight,
         
layer:  df::normalized_mix (
   components: df::bsdf_component[] (
      df::bsdf_component (
         weight: glossy_weight_1,
         component: df::simple_glossy_bsdf (
            tint: glossy_color,
            roughness_u: glossy_roughness_1 )),
      df::bsdf_component (
         weight: glossy_weight_2,
         component: df::simple_glossy_bsdf (
            tint: glossy_color,
            roughness_u: glossy_roughness_2 )))),
Overall glossy component created from two glossy BSDFs combined using df::normalize_mix
         
base: df::diffuse_reflection_bsdf (
   tint: diffuse_color ))));
Diffuse component

Rendering with the dielectric_plastic_two_lobe material produces Figure 7.11 and Figure 7.12.

Figure 7.11
dielectric_plastic_two_lobe(
  diffuse_color:
    color(.15, .4, 0),
  ior: 1.575,
  glossy_roughness_1: 0.05,
  glossy_roughness_2: .2)
Figure 7.12
dielectric_plastic_two_lobe(
  diffuse_color:
    color(.15, .4, 0),
  ior: 1.5894,
  glossy_roughness_1: 0.1,
  glossy_roughness_2: .35)

Extending the dielectric_plastic_two_lobe material to more than two lobes is straightforward: for each additional component in the df::normalized_mix, two additional parameters for roughness and weight are added to the parameters of the material. The parameter adjustments of multiple lobes in order to achieve a particular appearance might require tweaking by eye in an interactive application, in some ways a return to the empirical origins of the Phong model.

All the previous materials of this chapter have simulated the interaction of light with plastic as purely a surface effect. Based on the chemical constitution of the plastic, some amount of light may penetrate the surface, creating an effect of translucency. The appearance of translucency can be added to the dielectric_plastic_two_lobe material of the last section by developing a material that implements diffuse transmission (as in section 3.4) and combining it with the two-lobe material.

The following material uses df::diffuse_transmission_bsdf to simulate translucency:

Listing 7.5
material translucency(
   color transmission_color = color(1)) =
material (
   
thin_walled: true,
Refraction disabled with thin-wall model
   surface: material_surface (
      
scattering: df::diffuse_transmission_bsdf (
   tint: transmission_color)));
Diffuse transmission BSDF

Rendering with this simple material produces Figure 7.13:

Figure 7.13
translucency(
  transmission_color:
    color(0.95, 1.0, 0.9))

To combine the visual properties of dielectric_plastic_two_lobes with translucency, a new material must combine the “scattering” BSDFs of the materials defined by their surface properties. To extract the BSDF of a material instance, the dot operator is used in combination with the field names (as described in “Reusing parts of existing materials”).

For example, the following material, which combines the opaque appearance of dielectric_plastic_two_lobes with the translucent appearance of translucency, uses the dot operator in this way:

bsdf name = material-instance .surface.scattering;

For clarity, the dot operator's extraction of each material's BSDF is placed on a line after the closing parenthesis for clarity; this is possible because whitespace is ignored in MDL.

Listing 7.6
material translucent_plastic (
   color diffuse_color = color(0.5, 0.04, 0.04),
   color glossy_color = color(1.0),
   
float glossy_roughness_1 = 0.05,
float glossy_weight_1 = 0.5,
Parameters of the first lobe
   
float glossy_roughness_2 = 0.25,
float glossy_weight_2 = 0.5,
Parameters of the second lobe
   float glossy_weight = 1.0,
   float ior = 1.54,
   
float transmission_weight = 0.2,
color transmission_color = color(0.9),
float transmission_exponent = 3.0) =
Parameters of the translucency component
let {
   
bsdf opaque = dielectric_plastic_two_lobe(
   diffuse_color: diffuse_color,
   glossy_color: glossy_color,
   glossy_roughness_1: glossy_roughness_1,
   glossy_weight_1: glossy_weight_1,
   glossy_roughness_2: glossy_roughness_2,
   glossy_weight_2: glossy_weight_2,
   glossy_weight: glossy_weight,
   ior: ior)
   .surface.scattering;
BSDF of opaque (non-transmissive) surfaces extracted from material dielectric_plastic_two_lobe
   
bsdf translucent = translucency(
   transmission_color: transmission_color)
   .surface.scattering;
Translucency BSDF extracted from material translucency
} in
material (
   thin_walled: true,
   surface: material_surface (
      
scattering: df::custom_curve_layer (
   weight: 1.0,
   normal_reflectivity: 1.0 - transmission_weight,
   grazing_reflectivity: 1.0,
   exponent: transmission_exponent,
   layer: opaque,
   base: translucent)));
Opaque and translucent components combined with df::custom_curve_layer

Using the translucent_plastic material produces Figure 7.14:

Figure 7.14
translucent_plastic(
  diffuse_color:
    color(.15, .4, 0),
  ior: 1.5894,
  glossy_roughness_1: 0.1,
  glossy_roughness_2: .35,
  transmission_weight: 0.5,
  transmission_color:
    color(0.95, 1.0, 0.9))

Using the dot operator to extract a BSDF from a fully developed and independently useful material demonstrates the value of material libraries and the recombinations they promote.

In the next two chapters, topics introduced in the exploration of the Phong model will be developed further. Glass is another dielectric material with similar surface properties that can be augmented by volume distribution functions. The technique of material combination through the extraction of BSDFs will provide translucency to a model of woven fabric.

Fig. 7.15 – Material translucent plastic