1. Definition
Polygon shading is a technique used to determine the color and brightness of a polygon in a 3D scene based on light interaction and surface properties.
- Polygons are the basic building blocks of 3D models.
- Shading improves the visual realism of polygons by simulating light and material effects.
- Depending on how lighting is calculated, polygon shading can be flat, Gouraud, or Phong.
2. Types of Polygon Shading
A. Flat Shading
-
Assigns a single color to the entire polygon based on one normal vector (usually the face normal).
-
Steps:
- Compute the polygon’s normal.
- Apply lighting model (ambient + diffuse + specular) at one point (typically the centroid).
- Fill the polygon with that color.
-
Pros: Simple, fast.
-
Cons: Faceted appearance, edges of polygons are visible.
B. Gouraud Shading
-
Computes lighting at vertices and interpolates colors across the polygon.
-
Steps:
- Compute vertex normals (usually by averaging adjacent face normals).
- Apply lighting model at each vertex.
- Interpolate vertex colors across the polygon during rasterization.
-
Pros: Smooth shading, simple highlights on curved surfaces.
-
Cons: Can miss small specular highlights (e.g., tiny bright spots).
C. Phong Shading
-
Interpolates normals across the polygon and computes lighting per pixel.
-
Steps:
- Compute vertex normals.
- Interpolate normals for each pixel inside the polygon.
- Apply Phong illumination model per pixel.
-
Pros: Realistic highlights, smooth appearance.
-
Cons: More computationally expensive than Gouraud or flat shading.
3. Shading Pipeline for Polygons
- Vertex Processing: Compute vertex positions and normals.
- Lighting Calculation: Apply ambient, diffuse, and specular components.
- Interpolation: Depending on shading method, interpolate color or normals across polygon.
- Rasterization: Fill polygon pixels with computed colors.
4. Summary Table
| Shading Method |
Normal Usage |
Color Computation |
Appearance |
Pros |
Cons |
| Flat |
One normal per face |
One color per polygon |
Faceted |
Fast |
Looks blocky |
| Gouraud |
Vertex normals |
Interpolated vertex colors |
Smooth |
Efficient |
Can miss specular highlights |
| Phong |
Interpolated normals |
Per-pixel |
Very smooth, realistic |
Realistic highlights |
Computationally expensive |
Key Points:
- Polygon shading determines how polygons appear under lighting.
- Choice of shading affects realism, performance, and visual quality.
- Flat → Gouraud → Phong represents increasing realism and computational cost.