Return to previous page | Return to menu Go to next page


Programmer’s Tutorial

Light source

This chapter explains how to set the light source in SGL. By using a light source, objects displayed in 3D graphics are shaded, enabling more realistic images to be drawn.

3-1. Light source

A light source typically contains the following information:

  1. Light source position
  2. Light intensity
  3. Light color

However, it takes a lot of time to calculate all of these as light source information and draw them accurately. Therefore, SGL selects only the light source direction from these light source information and reflects it in the polygon drawing.
Also, with regard to the direction of light, normal light is defined as radiation from one point, which is too time consuming to calculate. Therefore, assuming that the light source position is at infinity, the light direction is always assumed to be emitted from the same direction regardless of the coordinate position of the object.

Figure 3-1 Light source image model

The change due to the light source on the object surface is determined by the direction of the ray and the orientation of the normal vector of each polygon face. An image of this is shown below.

Figure 3-2 Shadow image model


Return to previous page | Return to menu Go to next page