General

.
Lighting Theory for CG


Note: This tutorial was written for Lightwave 5.5, but can be applied to any 3D software.
Preface

Lighting in Lightwave is a tutorial designed for application of lighting theory to computer graphics and requires a basic understanding of 3D principles. I will predominantly concentrate on natural lighting, but will mention a few things about artificial lighting as well. The overall thrust of my article will be to produce photo-realistic images by applying good lighting techniques and post-processing. In the first part of this article will explore the theory, and in the second part, I will take you through a step-by-step tutorial to produce a simple 3D scene lit by simulated sunlight. I will try to make the application part of this article as much software independent as possible so that you can try out the techniques mentioned in your choice of software.

Introduction


Design, modeling, surfacing, lighting, animation, rendering and post-processing—these are some of the aspects that we generally look at during the span of each project. For most of the people that I have come across, the greatest stress has been on modeling and it declines as we move on to other aspects. The most neglected aspect is that of proper lighting. Place a few lights here and there and then relying on the software’s rendering engine will only get you so far as to come up with a synthetic (in other words, pathetic) looking image. The goal for some of us is photo-realism, and that requires not good modeling, but good surfacing and good lighting. It is easy to get away with images that require artificial lighting because we are not that familiar with it when compared with natural lighting. Replicating sunlight inside your 3D software is hard. The audience, being familiar with sunlight, is very quick to point out any irregularities. Certainly, those who are in the business of replicating sunlight need to be extremely observant of how natural light reflects, refracts, changes color, and changes intensities in nature. Simulating natural light requires a lot of consideration regarding the position, intensity, and color of the light sources used.

Some Characteristics of Light

Color

The color of light depends upon its source. White light is composed of all the possible colors that exist. A ray of white light changes color if it encounters an obstacle, which is not white and is not black. If it hits a white object, the same ray is reflected. If the object is black in color, all the light, no matter what color it was originally, is absorbed by the object and nothing is reflected. So basically when you look at a totally black object, you see the color black because no light enters your eye from that direction. To prove this thing, I ask you to close your eyes for one second. Which color did you see?

In Fig. 1 below you can see a white incident ray of light, which is reflected off a blue floor. The floor absorbs all the colors in the incident ray except blue, and reflects it. Note that the light is reflected at the same angle at which it was incident relative to the floor.

Fig.1

Any object that is in the path of the reflected blue ray will be lit by blue light only, provided that the white light is not incident on the same object. If it is, the object will have a blue tinge. This blue tinge is caused by radiosity, a phenomenon that is not implemented in most 3D software because of the tremendous mathematical complexity of radiosity algorithms.
Reflection & Refraction

Figure 1 shows perfect reflection which is impossible in the real world. Perfect reflection is possible only if the reflecting object is absolutely smooth. In reality, what happens is that not all of the original incident ray is reflected in the same direction. Some of it is reflected off at odd angles to the floor [Fig. 2]. This in turn reduces the intensity of the reflected ray even more.

Fig.2

The same thing happens when light is refracted. Light is not just bent I one direction, but the incident light is divided into several components and refracted at different angles owing to the imperfection in the refracting surface.

Both these irregular reflections and refractions lead to blurred reflections and refractions. This also leads to the fact that the reflected light serves as a point light source (as in the case of Fig. 2), rather than a single direction light source (as in the case of Fig. 1). In Fig. 2, the reflected light ends up lighting up much more of its surroundings than in the case of Fig. 1.

One more point to note that the intensity of the reflected light declines in an exponential manner. You will read more about intensity fall-offs in the next section.

Basic reflection is supported by current-day 3D software. Any object having reflection properties defined will bounce an incident ray. The number of times the ray bounces is controlled by the Ray Recursion Limit which you can set in most 3D software.

Intensity Falloff

A Light ray’s intensity falls off with the square of the distance from the source of the ray. In many of today’s 3D software, falloff calculations for lights are done on a linear scale. There are some that directly support exponential, or inverse-square falloff. In the case of exponential falloff [Fig.4], the light intensity decreases a lot more as you move away from the light source than in the case of linear falloff [Fig. 4].

Fig.3

Fig.4

3D Studio Max directly supports exponential falloff, whereas in Lightwave 3D 5.6 you can use Gaffer, a plugin from Worley Laboratories, or Realitools Volume 2 from Dynamic Realities to get exponential falloff. Later on in the article, I will show you a post-processing technique that can get you almost the same results as those you get with exponential falloff. (If you have Lightwave [6], it already has support for exponential fall-off lights)

That was a very brief look at some of the characteristics of light that one should know before getting involved in lighting. Now we shall see how these characteristics affect natural light.

Observing Light

I will begin this section with a look on Natural Light, and will then briefly mention a few points on artificial lighting.

Natural Light

Natural Lighting, or real world lighting, comes in a myriad of forms. It would perhaps take you an incredibly long amount of time to study each and every aspect of natural light, but for this article, I will limit myself to the basics.

Outdoors, the sun during the day is the primary source of light. The light is slightly yellow in color, but a closer look at your surroundings will point out that yellow colored light is not the only color that is affecting your surroundings. While the sun’s light is the primary light, one could say that there are at most an infinite number of secondary light sources emitting light in all sorts of colors that are found outdoors. In describing the characteristics of light above, I mentioned how light of one color changes to another color when it encounters an obstacle that is different from the color of incident ray of light. I also mentioned that some light is scattered when it is reflected or refracted. Now consider the world outside of your room. There are trees that are brown and green, grass that is totally green, pavement is gray [though not always] and so on. So an actual sample of outdoor light would be composed of many colors, but the most active color would be that of sunlight. Even when there is not much in the surroundings, there will still be some ambient light. Even in the Sahara, shadows are not completely black. The dust particles in the atmosphere (even the atmosphere itself) reflect light.

Every leaf, every brick, even every human is in essence acting like a secondary light source! However, these secondary light sources are extremely dependent upon their color and the intensity of the light that they are reflecting. If the color of the reflecting object is dark, then it will not reflect a lot of light. Most will be absorbed. And coupled with exponential falloff, the range of the reflected light is reduced even further. But if the color of the reflecting object is bright, say a white wall, then it will have considerable effect on the light distribution in its surroundings. In Fig. 5 below, the light from the yellow wall spreads a lot more on the floor than the light from the blue wall.

Fig.5

It is also worth noting that the color of light changes during different times of the day. At dawn, sunlight has a red tinge. At sunset, the red tinge is more apparent. In between these two, the light’s yellow tinge is more apparent.

Shadows change position as well as their shape during the course of a typical day. At dawn, there is no primary light source. All the light that we see at dawn comes to us after being reflected off the atmosphere. I am assuming here a place where there are objects between you and the sun, so that at dawn the horizon is not visible. In such a situation, it will be hard to find a well-defined shadow. The whole sky acts as a kind of a primary light source. Other objects do reflect light, there is not enough of it to have a significant effect. Shadows are incredibly soft-edged.

Around mid-day, the shadows are much sharper. The distance between the shadow-casting object and the shadow-receiving object defines the sharpness. The variation in shadow sharpness is shown below in Fig. 6. I have exaggerated the softness of the shadow along the distance of the plane to illustrate my point. In reality, direct sunlight makes the shadows grow softer at a much slower rate as the distance between the shadow casting object and the shadow receiving object increases. The rate at which the shadow changes its sharpness is dictated by the size of the light source. The bigger the light source relative to the obstructing object, the greater will be the rate of increase of the shadow’s softness.

Fig.6

At sunset, if an object is not directly being lit by sunlight, then its shadow will be extremely soft and will only be make a noticeable presence at the base of the object [Fig. 7]. The same can be said about shadows at dawn. The whole sky acts as one big light source and the light that comes from it hides most of the shadows. It is also worth noting that objects that are placed within shadows cast the same soft-edged shadow, but only when they are very close to some surface [Fig. 7].

Fig.7

The Lightwave Lighting Engine

Lightwave’s lighting engine is one of the finest that you can find on the market. All of the power of Lightwave’s lighting is hidden behind an easy to use interface. Lightwave gives you five kinds of light types

Distant Light
Point Light
Spot Light
Linear Light
Area Light

The one difference that separates a distant light from all the other light types is that it casts parallel rays of light on to the objects. For all the other light types, light emanates from a point and goes out in a radial fashion. (In the case of Area and Linear lights, there are several of such light-emanating points arranged close together)

The one other light type defined in Lightwave is Ambient Light. While I would not advise using ambient light in every scene that requires certain areas to be lit, it does come in handy when you have to light up a certain area that is not that obvious to the viewer’s eye. You must be careful in setting up ambient lights if you already have lights placed in the scene. The reason for this is that ambient light will affect each and every light that exists in your scene. If you must use ambient light, then set its value at the start of the scene when all objects have been layed out and there’s only one light in your scene.

While Lightwave’s lighting engine will not allow you do specify surfaces that will be affected by certain lights (does not apply to Lightwave 6+) and not by others (selective lighting), you can mimic this effect to a certain extent by playing around with light settings.

Consider the Lightwave scene shown below. You will notice a floor plane and a wall plane. There is one light, the Main Light that lies above the two planes. Main light affects both the planes in the scene. The Simulated Floor Light has been placed under the floor plane and its shadows have been turned off. This way the light will affect only the wall plane, and not the floor plane. It will affect the floor plane from below, but we will place the camera above the floor plane, and therefore, will not see the effect of the Floor light on the floor.

Fig.7.1

Fig.7.2


3D Total Homepage