Udocheals.org → Light source in computer graphics

7.15.2017 | Jennifer Bargeman

Light sources

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

$$$APPLET Applet Flat shading.

$$$APPLET Applet Gouraud shading.

$$$APPLET Applet Reflektor. We can imagine it as a cone where at the top there is a point *light* source. The external one determines the frontier at which the light moves. A more realistic representation is achieved using a couple of parallel-axes cones with a common top. 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. The internal cone represents a beam of clear light. A reflector is direction dependent light source, determined by its surface and orientation. The light intensity of the reflector is maximal in the direction in which it radiates, and it drops exponentially perpendicular to this direction.

Then, we can calculate the color hue for the internal points of the polygon. It is advantageous for shading bodies the surface of which comprises a set of polygons. This method is also known as bilinear interpolation. 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. Gouraud shading is based on the interpolation of light intensity on edges of a surface and its interpolation using scanline. These can be determined on the basis of the normal using a *lighting* model, for example the Phong model (10.2.3).

$$$APPLET Applet Point light source and parallel light source.

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

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. These methods are called shading. 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. By shading is understood the drawing of objects using color shades, naturally established through curved surfaces, giving a better image of them. It is achieved so as a precise calculation is made only at several points, and others are derived using these points.

This was rather difficult in the case of using the previous light *sources*. 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.

Example : Interpolation of intensity for a triangle.

At the corners of this square, we assign the normal vectors: N1, N2, N3, N4. Example: scanning of algorithm y crossing the given square in two limit points of edges a, b. 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:.

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

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

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

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

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.

Finally, we interpolate the intensities for the given polygon. In the following step, we assign an intensity of the corner using a lighting method. 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.

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

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

$$$APPLET Applet Surface light source.

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

$$$APPLET Applet Phong shading.