# What the f*ck is Polygon Rendering and its methods?

## Polygon rendering is a fundamental technique in computer graphics used to represent three-dimensional objects in a two-dimensional space.

Polygon rendering is a fundamental technique in computer graphics used to represent three-dimensional objects in a two-dimensional space. It involves providing appropriate shading at each point of a polygon to create the illusion of a real object. This technique is essential for creating realistic images and animations in various applications, including video games, movies, and simulations. The goal is to simulate the appearance of real-world objects by accurately representing the way they reflect light and cast shadows.

We will discuss three polygon rendering methods in this blog.

Constant Intensity Shading

Gouraud Shading

Phong Shading

### 1️⃣ Constant Intensity Shading

**Constant intensity** is also known as flat shading. This is the most simple and very fast method to specify a color of an object. Flat shading of a polygon assumes that each polygon is strictly planar and all the points on the polygon have exactly the same blind light treatment. In this method, a single intensity is calculated for each polygon.

This technique thus displays all the points in a polygon with a single color. In this method, the main idea is that we use only one surface normal per polygon.

In general, flat shading of polygon facets provides an accurate rendering for an object if all the following are valid:

The object is a polyhedron and is not an approximation of an object with a curved surface.

Light sources illuminating the objects are sufficiently far from the surface so that the unit is normal to a surface; unit direction vector to the point light source from a position on a surface and attenuation is constant over the surface.

the vector position is sufficiently far from the surface so that the unit vector pointer to the viewer from the surface position, a unit vector in the diversion of ideal specular reflection is constant over a surface.

This kind of polygon rendering method is fast and cheap. One of the disadvantages of constant-intensity shading is a very poor display of polygon-mesh approximations to curved surfaces.

### 2️⃣ Gouraud Shading

This Intensity-Interpolation scheme, developed by Gouraud and usually referred to as Gouraud Shading, renders a polygon surface by linear interpolating intensity value across the surface. Intensity values for each polygon are coordinate with the value of adjacent polygons along the common edges, thus eliminating the intensity discontinuities that can occur in flat shading.

Each polygon surface is rendered with Gouraud Shading by performing the following calculations:

Determining the average unit normal vector at each polygon vertex.

Apply an illumination model to each vertex to determine the vertex intensity.

Linear interpolate the vertex intensities over the surface of the polygon.

Gouraud Shading discards the intensity discontinuities associated with the constant-shading model, but it has some other deficiencies. Highlights on the surface are sometimes displayed with anomalous shapes, and the linear intensity interpolation can cause bright or dark intensity streaks, called Mach bands, to appear on the surface. These effects can be decreased by dividing the surface into a higher number of polygon faces or by using other methods, such as Phong shading, that require more calculations.

### 3️⃣ Phong Shading

Phong shading is a more accurate interpolation-based approach that can be used for rendering a polygon. It was developed by Phong Bui Tuong. It improves upon the Gourand Shading and provides a better approximation of the shading of any smooth surface. It interpolates the normal vector instead of the intensity values.

In Gouraud Shading, some dark and bright intensity streaks known as mach bands appear on the surface due to the linear intensity interpolation, this method reduces the mach band effects and displays more realistic highlights. However, it requires more calculation, hence it increases the cost of shading at each successive step.

### ✨ Conclusion

We can conclude are discussion by comparing the effects of the three polygon rendering methods on this teacup:

Let us tabulate whatever we learnt from this blog.

Method | Description | Advantages | Disadvantages |

Constant Intensity Shading or Flat Shading | Also known as flat shading. Every point on the polygon has the same constant intensity value, resulting in a uniform appearance. | Fast rendering method, useful for displaying simple curved surface appearances. | Unrealistic appearance, no consideration for surface smoothness or reflection. |

Gouraud Shading | Based on the interpolation of intensities between the vertices of a polygon. Calculates the intensity value for each point by linear interpolation across the surface of the polygon. | Eliminates intensity discontinuities, reduces appearance of banding. More realistic appearance than flat shading. | Less accurate than Phong shading. |

Phong Shading | Interpolates the surface’s normal vector at each point and applies the illumination model. Gives more realistic highlights to the surface and reduces appearance of match bands. | Provides the most accurate representation of the object’s reflection and shading. | Computationally expensive, may result in longer rendering times. |

This was it about different types of shading methods used in computer graphics. Thankyou and see ya.