Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

3.7 Gouraud and Phong Shading

Lesson 25 of 32 in the free Computer Graphics notes on Siksha Sarovar, written by Rohit Jangra.

Two Strategies on a Triangle Mesh

Both shading methods use the same illumination equation; they differ in where they evaluate it: at vertices then interpolate the color (Gouraud), or interpolate the normal then evaluate per pixel (Phong shading - distinct from Phong illumination).

Gouraud Shading (1971)

  1. Compute per-vertex normal as the average of adjacent face normals.
  2. Evaluate the illumination equation at each vertex -> vertex colors.
  3. During rasterization, interpolate the color linearly across the triangle (using barycentric coordinates).

Pros

  • Cheap: lighting once per vertex.
  • Smooth color across faces, eliminates flat shading appearance.

Cons

  • Highlights are missed if they fall in the middle of a triangle: the highlight only appears if a vertex happens to be near it.
  • Linear color interpolation produces Mach banding at edges between triangles.
  • Looks plasticky for shiny materials.

Phong Shading (1975)

  1. Per-vertex normals as before.
  2. During rasterization, interpolate normals across the triangle (then renormalize).
  3. Evaluate the full illumination equation at every pixel.

Pros

  • Sharp, correctly placed specular highlights even mid-triangle.
  • Smooth shading on relatively coarse meshes.

Cons

  • Cost: one lighting evaluation per pixel instead of per vertex. On modern GPUs this is the default.
  • Still needs renormalization of interpolated normals (linear interpolation does not preserve unit length).

Comparison Table

FeatureGouraudPhong Shading
Lighting evaluationsper vertexper pixel
Captures specular accuratelyOnly if vertex near highlightYes
CostLowHigh
Mach bandingVisibleSuppressed
Smooth on coarse meshLimitedGood

Other Shading Modes Worth Knowing

  • Flat (Constant) Shading: one normal per triangle, one color per triangle. Faceted look, useful for low-poly aesthetics or technical drawings.
  • Blinn-Phong: replaces R.V with H.N where H = (L+V)/||L+V||, the half-vector. Cheaper and behaves better at glancing angles. Default in OpenGL fixed-function era.
  • Toon / Cel: clamp diffuse and specular to a few discrete bands for a comic-book look.

Numerical Difference Sketch

Imagine a single bright triangle with a highlight near its centroid:

  • Gouraud: corners might be dim because L.N near corners is moderate; centroid color is the average -> highlight invisible.
  • Phong shading: per-pixel L.N at centroid is high -> highlight clearly visible.

When to Choose Which

  • Gouraud: very large meshes where lighting cost dominates and material is matte.
  • Phong shading: anything shiny, modern engines, mobile with deferred shading.
  • Often combined: Gouraud for diffuse term + Phong for specular term to reduce cost while keeping crisp highlights.

Modern Practice

Almost all modern engines do per-pixel shading (Phong shading + PBR), with vertex-stage work limited to transform and attribute interpolation setup.