001 :: Shaders - Its all in the Reflections

One of the questions I get frequently is how I set up textures/mapping and lighting. Instead of writing some longer tutorial for MAX here I thought it would benefit people a bit better if I, fairly shallow, write about the concepts of shading and how the lighting effect the same in the 3d world versus the real world while at the same time being fairly non-specific in software.

In the near future I hope to be able to write together smaller documents about more specifics about such things such as translucency and cloths as well as a few Brazil specific tutorials.

Note that all comments or opinions stated in this text is solely mine and not necessarily the industry's way of seeing nor describing it.

What's a Shader?
For this mental exercise, assume light is white. White is in reality made up of several different prime colors that when added forms he white light. When the light hits a objects certain colors gets reflected back to the eye. For example, a blue sphere is in reality not blue, but blue is the only part of the white light that the object reflects (repels) back into our eyes and therefore giving it the blue appearance. This reflected color is what's commonly referred to as [diffuse] in a shader.

Along with the Diffuse color you usually have a specular color and related values, this specular is a faked light source reflection that in real life exist in almost all man-made or treated materials as well as very few natural ones [such as compressed minerals found in some stones and some fruits]. In the 3d world its assumed [correctly] that all materials have an imperfect surface and therefore has a shading between the diffuse and the actual light source reflection.

Diffuse; Color Reflection
The diffuse color of a material is basically just the color that you see when lit by any light source, the diffuse shading of materials is only light-angle dependent, i.e. they are always on the same spot on the object no matter what view you are viewing it from.

The diffuse shading stops at the terminator, (more than 180deg from light source) which the light cannot bend around in most 3d renderers. Note that dust and similar in real life do bend light around to extend the shading past the light terminator.

Fig. 1.1

In the perfect, 3d world, the amount of lit [color reflected] surface on an object stops when it comes to a 180 degree angle from the lightsource. In real life the light is usually extended past this "terminator", due to the refractive properties that dust and other air particles have on light -- bending it past the terminator as shown in Figure 1.1

Fig. 1   The Diffuse shading of a material is not view-independent. I.e. It is light source dependent and do not change location on the object depending on what angle you view it from.
Specular; Light Source Reflection
The Specular highlight of a material is a simulation of the light source reflection thats very common in most man-made materials. In real life this is ofcourse reflected properly (with what in 3d is similar to raytraced reflection) but for most shaders this approximation of the reflection is enough.

The Specular is generated with an assumption that there is slight imperfections [Fig.02, simulated surface] on the surface of the material and therefore the reflection differs a bit across the reflected area, hence the shading across the specular itself.

Note that to proper simulate highly reflective materials you usually need to find a sweet spot between real raytraced reflections with a slight hint of speculars to show a approriate glow around the raytraced highlight [fig. 0.2.1]. You can usually get this glow by using a slight bump [fig. 0.2.2], which the specular assumes you have, and the raytraced reflection will be slightly imperfect, but this technique can require more tweaking than its worth.

In the real world, light source reflections are visible on almost all man-made materials and some very few natural occurring ones, these natural might be certain stones with compressed minerals, some waxy fruits or waxy leafs and so on, try to observe the object/material you are recreating to see how much light it reflects.

The big "but" when it comes to specular highlight is that in the real world they basically never exist as the phong or blinn shaded 3d counterparts but are basically always anisotropic to some degree.

Fig. 2   Specular reflection is less intensive at the edges of the "reflection" due to the assumption that the surface is not perfectly smooth and therefore the reflection would be slightly uneven. This "imperfection" is usually controllable by a glosiness value, but you can't remove the shading completely.
Anisotrophic Specular
Anisotropic highlights/reflections is an approximation of what originally occur on a surface with grooves of microscopic size. These grooves will reflect the lightsource along its surface and therefore alongate the reflection over its surface. The look of this highlight depends on the setup of these grooves (for example, angle and spacing) as well as the orientation to the viewer.

As seen in [fig. 3.2] by simulating these surface grooves by actually stacking a bunch of torii [toruses] ontop of eachother we get an accurate representation of what a real material would look like. This effect is what you usually see on brushed aluminum, feathers, certain cloths, hair and compact discs for example.

As shown in the [fig 3] illustration, these grooves will reflect the the light source in larger angles [between, light source, object and eye, fig. 3.3 and fig 3.4] than normally, which do show up if you would actually create these grooves in your material or object, but lacks with the anisotropic shader per se.

On isotropic material (disc shaped light source reflection) the light gets reflected evenly in all directions, so if you would spin the object the specular reflection would remain unchanged on the object. On the anisotropic material it will move according to the angle of the microscopic grooves vs the viewers eye.

Fig. 3   Anisotropic shaders simulate objects with microscopic grooves on the surface.
Raytraced Reflections
Raytraced reflections is where each ray of light actually gets calculated from the camera, usually these type of light reflections are used on highly reflected surfaces such as water or glass.

Raytraced reflections on an object is the "pure" way of getting reflections from your light to appear on your object. Raytraced are usually the best way to get light source reflections to appear on "perfect" surfaces such as glass, polished chrome, water and so on. Due to the "scratch free" nature of these objects the shaders specular shading is seldom used. But, depending on your scene or eventual weathering of your material you should probably increase the specular to create a faint glow around the atual reflection as if small imperfections would distort the reflection a bit.

In real life almost all reflective materials get more reflective as the angle of incidence increases, this is mostly visible in water but holds true overall. Water is also one of the few surfaces that would exhibit very low, if even existant, specular shading. If the scale would be big it might be suitable to use it for small changes in the surface or for small scaled ones it might be used to show an slight amount of "dirt" in the water.

Fig. 4   Raytraced reflections are by themselves a perfect reflection of your scene as it has no "assumed" properties of your surface. To get them to appear realistic you will probably need to create the imperfections yourself.

Just for Statistics