In the above example, the default values for ambient and diffuse are used. We render this to see what the effect is and then make the following change to the finish.
The sphere is black because we have specified that none of the light coming from any light source will be reflected by the sphere. Let's change diffuse back to the default of 0.6.
Now we see the gray surface color where the light from the light source falls directly on the sphere but the shaded side is still absolutely black. Now let's change diffuse to 0.3 and ambient to 0.3.
The sphere now looks almost flat. This is because we have specified a fairly high degree of ambient light and only a low amount of the light coming from the light source is diffusely reflected towards the camera. The default values of ambient and diffuse are pretty good averages and a good starting point. In most cases, an ambient value of 0.1 ... 0.2 is sufficient and a diffuse value of 0.5 ... 0.7 will usually do the job. There are a couple of exceptions. If we have a completely transparent surface with high refractive and/or reflective values, low values of both ambient and diffuse may be best. Here is an example.
This is glass, obviously. Glass is a material that takes nearly all of its appearance from its surroundings. Very little of the surface is seen because it transmits or reflects practically all of the light that shines on it. See glass.inc for some other examples.
If we ever need an object to be completely illuminated independently of the lighting situation in a given scene we can do this artificially by specifying an ambient value of 1 and a diffuse value of 0. This will eliminate all shading and simply give the object its fullest and brightest color value at all points. This is good for simulating objects that emit light like lightbulbs and for skies in scenes where the sky may not be adequately lit by any other means.
Let's try this with our sphere now.
Rendering this we get a blinding white sphere with no visible highlights or shaded parts. It would make a pretty good streetlight.
Rendering this we see a fairly broad, soft highlight that gives the sphere a kind of plastic appearance. Now let's change phong_size to 150. This makes a much smaller highlight which gives the sphere the appearance of being much harder and shinier.
There is another kind of highlight that is calculated by a different means called specular highlighting. It is specified using the keyword specular and operates in conjunction with another keyword called roughness. These two keywords work together in much the same way as phong and phong_size to create highlights that alter the apparent shininess of the surface. Let's try using specular in our sphere.
Looking at the result we see a broad, soft highlight similar to what we had when we used phong_size of 25. Change roughness to .001 and render again. Now we see a small, tight highlight similar to what we had when we used phong_size of 150. Generally speaking, specular is slightly more accurate and therefore slightly more realistic than phong but you should try both methods when designing a texture. There are even times when both phong and specular may be used on a finish.
We see that our sphere now reflects the green and white checkered plane and the black background but the gray color of the sphere seems out of place. This is another time when a lower diffuse value is needed. Generally, the higher reflection is the lower diffuse should be. We lower the diffuse value to 0.3 and the ambient value to 0.1 and render again. That is much better. Let's make our sphere as shiny as a polished gold ball bearing.
That is very close but there is something wrong with the highlight. To make the surface appear more like metal the keyword metallic is used. We add it now to see the difference.
We see that the highlight has taken on the color of the surface rather than the light source. This gives the surface a more metallic appearance.
The degree of refraction, i. e. the amount of bending that occurs, is given by the keyword ior, short for index of refraction. If we know the index of refraction of the substance we are trying to create, we may just use that. For instance, water is 1.33, glass is around 1.45 and diamond is 1.75. Let's return to the example of a glass sphere we used earlier.
We render this again and notice how the plane that is visible through the sphere is distorted and turned upside-down. This is because the light passing through the sphere is being bent or refracted to the degree specified. We reduce ior to 1.25 and re-render. We increase it to 1.75 and re-render. We notice how the distortion changes.
Section 4.8.4.2
Using Surface Highlights
Section 4.8.4.3
Using Reflection and Metallic
Section 4.8.4.4
Using Refraction
Table Of Contents