PadhaikoAll subjects

Past exam question: 2081 Chaitra (Regular), Q6

Computer Graphics and Visualization · 5 marks

Open in the Padhaiko app

Topic: Ambient, Diffuse & Specular Reflection; Constant, Gouraud & Phong Shading

Question

Explain the Phong shading algorithm. Mention the advantages of fast Phong shading overphong shading method.

Solution

Overview and Mechanism of the Phong Shading Algorithm: Phong shading (also known as normal-vector interpolation shading) is a rendering method developed by Bui Tuong Phong. Unlike Gouraud shading (which interpolates vertex colors linearly and misses specular highlights located in polygon interiors), Phong shading interpolates surface normal vectors across the polygon and evaluates the full illumination equation at every individual pixel.

The algorithm proceeds through the following steps:

  1. Compute Vertex Normals: At each vertex of a polygon mesh, compute the average unit normal vector by summing the normal vectors of all adjacent polygonal faces sharing that vertex:
  1. Interpolate Normals Along Polygon Edges: For each scanline intersecting the polygon's edges between vertices and , compute the interpolated edge normal using linear parameterization:
  1. Interpolate Normals Across the Scanline: For each pixel along a horizontal scanline between the left edge intersection and right edge intersection :
  1. Normalize and Evaluate Illumination Per Pixel: Normalize the interpolated vector to unit length and compute total pixel intensity:

Computational Bottleneck in Standard Phong Shading: While Phong shading produces realistic, smoothly curved appearances with accurate specular highlights and eliminates Mach banding, it is computationally intensive:

Advantages of Fast Phong Shading Over Standard Phong Shading: Fast Phong shading (such as the method of Bishop and Weimer) addresses this computational bottleneck by approximating the normal normalization and intensity computation using a Taylor series expansion or a 2D bivariate polynomial:

The specific advantages include:

  1. Elimination of Per-Pixel Vector Normalization: Completely avoids calculating inverse square roots () at every screen pixel.
  2. Evaluation via Forward Finite Differences: Along each horizontal scanline (), the polynomial becomes a 1D quadratic function . Successive pixel intensities are computed using forward differences requiring only two simple additions per pixel ( and ) without multiplication or division.
  3. Significant Speedup: Reduces arithmetic clock cycles by a factor of to compared to standard software Phong rendering.
  4. Preservation of Visual Quality: Accurately retains specular highlight curvature and shape without re-introducing Mach banding artifacts, delivering visual results virtually indistinguishable from true Phong shading.
Answer:
  1. Phong shading interpolates vertex surface normal vectors bilinearly across edges and scanlines, normalizes the vector at every pixel, and evaluates the complete ambient + diffuse + specular lighting equation per pixel.
  2. Fast Phong shading approximates the per-pixel lighting function using a bivariate polynomial evaluated via incremental forward differences, eliminating per-pixel vector normalizations and square roots while preserving specular highlight fidelity with only two additions per pixel.

All past exam questions for Computer Graphics and Visualization