Section 4.8.4
Finishes

The final part of a POV-Ray texture is the finish. It controls the properties of the surface of an object. It can make it shiny and reflective, or dull and flat. It can also specify what happens to light that passes through transparent pigments, what happens to light that is scattered by less-than-perfectly-smooth surfaces and what happens to light that is reflected by surfaces with thin-film interference properties. There are twelve different properties available in POV-Ray to specify the finish of a given object. These are controlled by the following keywords: ambient, diffuse, brilliance, phong, specular, metallic, reflection, refraction, caustics, attenuation, crand and iridescence. Let's design a couple of textures that make use of these parameters.

Section 4.8.4.1
Using Ambient

Since objects in POV-Ray are illuminated by light sources, the portions of those objects that are in shadow would be completely black were it not for the first two finish properties, ambient and diffuse. Ambient is used to simulate the light that is scattered around the scene that does not come directly from a light source. Diffuse determines how much of the light that is seen comes directly from a light source. These two keywords work together to control the simulation of ambient light. Let's use our gray sphere to demonstrate this. Let's also change our plane back to its original green and white checkered pattern.

plane {y,-1.5 pigment {checker Green, White} } sphere { <0,0,0>, 1 pigment {Gray75} finish { ambient .2 diffuse .6 }

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.

ambient 0 diffuse 0

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.

sphere { <0,0,0>, 1 pigment { White filter 1 } finish { ambient 0 diffuse 0 reflection .25 refraction 1 ior 1.33 specular 1 roughness .001 } } }

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.

sphere { <0,0,0>, 1 pigment { White } finish { ambient 1 diffuse 0 } } }

Rendering this we get a blinding white sphere with no visible highlights or shaded parts. It would make a pretty good streetlight.


Section 4.8.4.2
Using Surface Highlights

In the glass example above, we noticed that there were bright little hotspots on the surface. This gave the sphere a hard, shiny appearance. POV-Ray gives us two ways to specify surface specular highlights. The first is called Phong highlighting. Usually, Phong highlights are described using two keywords: phong and phong_size. The float that follows phong determines the brightness of the highlight while the float following phong_size determines its size. Let's try this.

sphere { <0,0,0>, 1 pigment { Gray50 } finish { ambient .2 diffuse .6 phong .75 phong_size 25 } }

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.

sphere { <0,0,0>, 1 pigment { Gray50 } finish { ambient .2 diffuse .6 specular .75 roughness .1 } } }

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.


Section 4.8.4.3
Using Reflection and Metallic

There is another surface parameter that goes hand in hand with highlights, reflection. Surfaces that are very shiny usually have a degree of reflection to them. Let's take a look at an example.

sphere { <0,0,0>, 1 pigment { Gray50 } finish { ambient .2 diffuse .6 specular .75 roughness .001 reflection .5 } } }

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.

sphere { <0,0,0>, 1 pigment { BrightGold } finish { ambient .1 diffuse .1 specular 1 roughness .001 reflection .75 } } }

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.

sphere { <0,0,0>, 1 pigment { BrightGold } finish { ambient .1 diffuse .1 specular 1 roughness .001 reflection .75 metallic } } }

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.


Section 4.8.4.4
Using Refraction

Objects that are transparent allow light to pass through them. With some substances, the light is bent as it travels from one substance into the other because of the differing optical densities of the objects. This is called refraction. Water and glass both bend light in this manner. To create water or glass, POV-Ray gives us a way to specify refraction. This is done with the keywords refraction and ior. The amount of light that passes through an object is determined by the value of the filtering and/or transmittance channel in the pigment. We should use the refraction value only to switch refraction on or off using values of 1 or 0 respectively (or the boolean values on and off). See section "Refraction" for a detailed explanation of the reasons.

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.

sphere { <0,0,0>, 1 pigment { White filter 1 } finish { ambient 0 diffuse 0 reflection .25 refraction 1 ior 1.45 specular 1 roughness .001 } } }

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.5
Adding Light Attenuation

Transparent objects can be made to cause the intensity of light passing through them to be reduced. In reality, this is due to impurities in scattering the light. Two float values determine the effect: fade_distance is the distance the light has to travel to reach one-half its original intensity and fade_power is the degree of falloff. Let's try an example of this.

sphere { <0,0,0>, 1 pigment { White filter 1 } finish { ambient .1 diffuse .1 reflection .15 refraction 1 ior 1.45 specular 1 roughness .001 fade_distance 5 fade_power 1 } }


The caustics of a translucent sphere.

This gives the sphere a slightly clouded look as if not all of the light was able to pass through it. For interesting variations of this texture, try lowering ior to 1.15 and raising reflection to 0.5.


Section 4.8.4.6
Using Faked Caustics


Section 4.8.4.6.1
What are Caustics?

First, let us raid our kitchen cupboard. We are looking for transparent glass or crystal drinking glasses. If they have a pattern etched in their surface, so much the better. One by one, we place them under a bright lamp and observe the shadow they cast on the desk or table beneath. If we look closely we will make out bright regions within the shadow. These will be places where the refractive properties of the drinking glass are concentrating light sufficiently to make the bright spots. If there is a pattern in the surface of the glass we will see the pattern formed out of the bright areas. Those bright regions are the caustics caused by refraction, the refractice caustics. There will also be bright patterns of light on the table that are caused by light reflected off the glass. These are called reflective caustics.

Once we know what we are looking for we will be able to spot caustics in many everyday situations: the shadow cast by a magnifying glass has one, light streaming through an aquarium might makes them, the light passing through a piece of crumpled cellophane might cast them on the table top, etc. We will even see them in the bottom of a swimming pool on a bright sunny day. Caustics are a subtle lighting effect that can really lend realism to raytraced images of such items.

POV-Ray uses algorithms that fake refractive caustics (reflective caustices are not possible).There are inherant limitations on the process of (standard) ray-tracing in general which make it unsuitable for certain light simulation applications, such as optical testing and a few very particular architectural lighting projects. Methods which do the considerably more extensive calculations needed to do full light simulation including caustics (like path-tracing, photon-tracing or bi-directional ray-tracing) are very slow and impractical on average platforms.

This means that we have to tinker with the caustics to get the best possible look, but with a little experimentation, we will see we can very closely emulate the real thing. The best way to go is, where ever possible, to study an example of the thing we are trying to trace. We need to get to know its pattern of caustics and then adjust our final picture until we are satisfied.


Section 4.8.4.6.2
Applying Caustics to a Scene

Caustics is a new texture property under the area of finishes. We apply it to the shadows of a transparent, refractive object by adding in the caustics keyword to the finish. We try the following simple example for a start (see file caustic1.pov).

#include "colors.inc" #include "textures.inc" camera { location <0, 15, -40> look_at <-2, 0, 1> angle 10 } light_source { <10, 20, 10> color White } // lay down a boring floor to view the shadow against plane { y, 0 pigment { Grey } } // here's something to have caustics property applied sphere { <0, 3, 0>, 2 texture { Glass3 finish { caustics .6 } } }


The caustics in a swimming-pool.

When we render this we will see our sphere in the upper right corner of the image, floating a little over the plane, and the shadow it casts is sprawled across the central part of our view. And there in the center is a basic caustic. That bright area in the center represents the light which normally refractivity would concentrate in the middle of the shadow.

The only question this leaves is: what is with the floating point value which follows the caustics keyword? Well, that's where our discussion above on adjusting the caustic comes in. Remember the drinking glasses? If we had one that had fairly thin walls and then a thick glass base we will see what we mean in the shadows it casts. Above, with the thinner walls (with less refraction) the caustics are less pronounced and more evenly diffused through the shadow, but when we get to the part of the shadow cast by the thicker, more refractive base, suddenly the caustic becomes more pronounced and more tightly focused near the center.

Of course, since this is a simulated caustic, there is no correspondence between the degree to which the caustic is focused or diffused and the shape, size and refractivity of the object. But we can manually control it with the floating point value following the caustic keyword. The closer this value gets to zero, the more diffused and dimmer the caustic gets, while the nearer it becomes to 1, the more tightly focused and pronounced the caustic gets. At 1, we have the caustic of a thick, highly refractive piece of lead crystal, while at 0.1 it is more like a hollow glass sphere. We try this by re-rendering the above scene, with a range of values from 0.1 to 1.0 and watching the different caustics we get.

Out of range values work also. Numbers higher than 1 just lead to more and more tightly focused caustics. Negative numbers are just plain weird, but interesting. Essentially, the object becomes illuminated in all sorts of bizzare ways and the shadow becomes like a photographic negative of itself. Kind of like a 1950's sci-fi raygun effect. It looks strange, and not at all photo-realistic, but if we like the surreal we may want to try it at least once and file away the effect in our mind in case we ever want it.


Next Section
Table Of Contents