Light sources emit light radiation. A light source is an object that manifests itself only through light radiation. For instance, a bulb can be light source. Because it is not possible to totally describe all light sources, several standard light sources are introduced in computer graphics.

The most commonly used in computer graphics. Light is spreading steadily and with equal intensity in all directions. A point source is definitely determined by its intensity and position.

This type can be imagined as a point light source lying in infinity. Light rays from such a source are radiated parallelly. Normally, it is set as a surface at a finite distance, and then, its rays are radiated perpendicularly to this surface.

This source is the most realistic. It is defined as an oriented polygon characterized by its own radiance. It requires a lot of time for calculation, but the results are relatively good, shading in particular looks realistic. This was rather difficult in the case of using the previous light sources.

A **reflector** is direction dependent light source, determined by its surface and orientation.
We can imagine it as a cone where at the top there is a point light source.
The light intensity of the reflector is maximal in the direction in which it radiates, and it drops
exponentially perpendicular to this direction. A more realistic representation is achieved using
a couple of parallel-axes cones with a common top. The internal cone represents a beam of clear light.
The external one determines the frontier at which the light moves. The intensity of the light declines with
the distance from the axis where it is maximal, down to the frontiers of the external cone, where it is zero.

By shading is understood the drawing of objects using color shades, naturally established through curved surfaces,
giving a better image of them **[1]**. From the previous text we know how to assess the color of points on the surface
of a lighted area, providing we know the direction of a projecting ray, the normal of the surface at a given point and
other factors affecting the resulting color of the point. Calculation of the color of all points on the screen, however, is
a time-consuming operation, and therefore, methods allowing fast calculation have been designed. It is achieved so as
a precise calculation is made only at several points, and others are derived using these points. These methods are
called shading.

**Flat shading** is the simplest and also the fastest method. It is used in displaying plane surfaces that are
approximated by flat patches. For each surface we usually just have one given normal. Where a normal is not given,
we calculate it from the relevant plane surface. On the basis of this normal, we assign the relevant color hue,
which after rastering of this surface, is assigned to all its points.

This shading is suitable for fast previewing of bodies approximated by patches. It is not appropriate for the quality displaying of general bodies because it emphasizes the fact that a round surface is approximated by patches.

**Gouraud shading** is based on the interpolation of light intensity on edges of a surface and its interpolation
using scanline. It is advantageous for shading bodies the surface of which comprises a set of polygons.
This method is an approximation method, but very fast, and used in applications requiring a real-time response.
__In shading, we need information on the colors of every corner of a given polygon.__
These can be determined on the basis of the normal using a lighting model, for example the Phong model (10.2.3).
Then, we can calculate the color hue for the internal points of the polygon. This method is also known as
bilinear interpolation.

In the case that we do not have normal vectors at the corners, we must determine them the sum (or average) of the normal of the incident surfaces of this corner. In the following step, we assign an intensity of the corner using a lighting method. Finally, we interpolate the intensities for the given polygon.

**Example :**

Interpolation of intensity for a triangle

Let's have a polygon (in our case a triangle) which has given intensities at its corners.

Similarly as in the case of Gouraud shading, Phong shading is also based on interpolation. However, here we interpolate normal vectors. Therefore, we assess normal vectors at the corners of polygons. We can use an algorithm of line scanning of normal vectors for this.

**Example:** scanning of algorithm y crossing the given square in two limit points of edges a, b.
At the corners of this square, we assign the normal vectors:
*N1*, *N2*, *N3*,*N4*.
On the basis of the number of lines between two corners of the edge we can determine the vector
differential *dNa*, *dNb* on the edges a, b. Then, calculation of normal vectors in the switch from one
line to another is simplified into adding the differentials:

*Na* = *Na* + *dNa*,br \>
*Nb* = *Nb* + *dNb*,br \>,

The resulting normal vector *N* is calculated through the interpolation of the x coordinate:

*N* = *Na*.(x*b*-x) / (x*b*-x*a*)
+ *Nb*.(x-x*a*) / (x*b*-x*a*).

Copyright (c) 1999-2019 Juraj Štugel. www.netgraphics.sk