Gouraud Shadings Phong shadings

There are several approaches to rendering the interaction of light with surfaces. The simplest shading techniques are flat, Gouraud, and Phong.

In flat shading, no textures are used and only one colour tone is used for the entire object, with different amounts of white or black added to each face of the object to simulate shading. The resulting model appears flat and unrealistic.

In Gouraud shading, textures may be used (such as wood, stone, stucco, and so forth); each edge of the object is given a colour that factors in lighting, and the computer interpolates (calculates intermediate values) to create a smooth gradient over each face. This results in a much more realistic image. Modern computer graphics systems can render Gouraud images in real time.

In Phong shading each pixel takes into account any texture and all light sources. It generally gives more realistic results but is somewhat slower

The shading techniques described thus far do not model specular reflection from glossy surfaces or model transparent and translucent objects. This can be done by ray tracing, a rendering technique that uses basic optical laws of reflection and refraction. Ray tracing follows an imaginary light ray from the viewpoint through each point in a scene. When the ray encounters an object, it is traced as it is reflected or refracted. Ray tracing is a recursive procedure; each reflected or refracted ray is again traced in the same fashion until it vanishes into the background or makes an insignificant contribution. Ray tracing may take a long time—minutes or even hours can be consumed in creating a complex scene.

Gouraud shading, also called intensity interpolation, provides a way to display smooth-shaded polygons by defining the RGB color components of each polygon vertex.
It operates by first interpolating the RGB values between the vertical vertices along each edge.
This gives us the RGB components for the left and right edges of each scan line (pixel row).
We then display each row of pixels by horizontally interpolating the RGB values between that
row's left and right edges. This produces a remarkably smooth-shaded polygon. Fastgraph supports
Gouraud shading for direct color virtual buffers, but not for 256-color virtual buffers.
• Gouraud shading is an intensity-interpolation method

• The intensity is calculated at each vertex of a polygon and linearly interpolated across the polygon's edges and face

• This allows the use of polygonal models to represent smooth surfaces such as cylinders and spheres

• We approximate the normals at the polygon vertices by adding all normals for each surface that meets at the vertex. To illustrate Gouraud shading, consider a polygon with four vertices. Assume its upper left vertex is pure white (RGB = 255,255,255), the upper right vertex is pure green (0,255,0), the lower right vertex is pure red (255,0,0), and the lower left vertex is pure blue (0,0,255). The resulting Gouraud-shaded polygon would look like this:

Top
## Phong Shadings

• The intensity is calculated at each vertex of a polygon and linearly interpolated across the polygon's edges and face

• This allows the use of polygonal models to represent smooth surfaces such as cylinders and spheres

• We approximate the normals at the polygon vertices by adding all normals for each surface that meets at the vertex. To illustrate Gouraud shading, consider a polygon with four vertices. Assume its upper left vertex is pure white (RGB = 255,255,255), the upper right vertex is pure green (0,255,0), the lower right vertex is pure red (255,0,0), and the lower left vertex is pure blue (0,0,255). The resulting Gouraud-shaded polygon would look like this:

Phong shading, is similar to Gouraud shading except that the Normals are interpolated. Thus, the specular highlights are computed much more precisely than in the Gouraud shading model.
The algorithm is as follows:

1.Compute a normal N for each vertex of the polygon.

2.From bi-linear interpolation compute a normal, Ni for each pixel. (This must be renormalized each time)

3.From Ni compute an intensity Ii for each pixel of the polygon.

4.Paint pixel to shade corresponding to Ii.

Note that this method is much more computationally intensive than Gouraud shading.

Gouraud: 3 floating point adds per pixel (3 intensities).

Phong: 3 fp adds (normal) + (3 squares + sqrt for normal) + (recompute intensity - 3 * (about 10-20 fp multiplies depending on degree of approximation).

So, for each vertex of the polygon to be rendered, you will need to calculate the coordinates to the Phong Map.

You have a polygon. For this polygon, define two vectors which are at right angles to each other and to the surface normal. Call them V and H. These two vectors represent the (u,v) coordinates of the phong map.

Now we'll look at this polygon at an angle so the vector from the light source to the vertex can be seen. This is vector L.

The aim is to calculate the coordinates (u,v) in terms of V, H and L The algorithm is a very simple one. If the phong map is 256x256 and centered then: u = ( V . L ) * 128 + 127 v = ( H . L ) * 128 + 127 do this for each vertex, and then map the Phong map onto it, and there you have one nicely phong shaded polygon.

Top

1.Compute a normal N for each vertex of the polygon.

2.From bi-linear interpolation compute a normal, Ni for each pixel. (This must be renormalized each time)

3.From Ni compute an intensity Ii for each pixel of the polygon.

4.Paint pixel to shade corresponding to Ii.

Note that this method is much more computationally intensive than Gouraud shading.

Gouraud: 3 floating point adds per pixel (3 intensities).

Phong: 3 fp adds (normal) + (3 squares + sqrt for normal) + (recompute intensity - 3 * (about 10-20 fp multiplies depending on degree of approximation).

So, for each vertex of the polygon to be rendered, you will need to calculate the coordinates to the Phong Map.

You have a polygon. For this polygon, define two vectors which are at right angles to each other and to the surface normal. Call them V and H. These two vectors represent the (u,v) coordinates of the phong map.

Now we'll look at this polygon at an angle so the vector from the light source to the vertex can be seen. This is vector L.

The aim is to calculate the coordinates (u,v) in terms of V, H and L The algorithm is a very simple one. If the phong map is 256x256 and centered then: u = ( V . L ) * 128 + 127 v = ( H . L ) * 128 + 127 do this for each vertex, and then map the Phong map onto it, and there you have one nicely phong shaded polygon.