Skip to content
FoundationSource checked

Phong Shading

Computes local lighting with ambient, diffuse, and specular terms per fragment.

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Beginner
Family
Local Illumination
Tier
Foundation
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
4
Code example
Ready
Visualization
Ready

Overview

Phong shading evaluates a simple reflectance model at shaded points, producing smooth highlights when normals are interpolated across a surface.

Core Concepts

ambient termdiffuse termspecular termnormal interpolation

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(1)

Average

O(pixels * lights)

Worst

O(pixels * lights)

Space

O(1)

When to Use

  • Use it for simple local lighting with smooth specular highlights.
  • Use it in teaching renderers or lightweight real-time shading.
  • Use it when physically based material accuracy is not required.

When Not to Use

  • Avoid it when energy conservation or physically based materials are required.
  • Avoid it when global illumination, shadows, or indirect lighting are the main effect.
  • Avoid mixing coordinate spaces for normals, lights, and view vectors.

What It Does

  • Computes local lighting with ambient, diffuse, and specular terms per fragment
  • Uses local illumination and diffuse term to guide the work.
  • Produces rendered image.

Use Cases

  • Real-time graphics
  • Offline rendering
  • Lighting and visibility effects

Inputs

  • Scene geometry
  • Materials
  • Camera and lighting state

Outputs

  • Rendered image
  • Visibility or shading buffers

Key Formulas (1)

Phong lighting

I = ambient + diffuse + specular
I = ambient + diffuse + specular

Combines the basic lighting terms used by Phong-style shading.

Pseudocode

  1. 1.Normalize the surface normal, light direction, and view direction.
  2. 2.Compute the diffuse term from max(dot(normal, light), 0).
  3. 3.Compute the reflection direction and specular term.
  4. 4.Add ambient, diffuse, and specular contributions.
  5. 5.Return the shaded color.

Canonical Example

Input
normal facing a white light with a viewer near the reflection direction
Output
bright diffuse color with a specular highlight
Explanation
Phong shading adds ambient, diffuse, and specular terms from the local light and view geometry.

Implementation Notes

  • Normalize the normal, light direction, and view direction before evaluating terms.
  • Compute ambient, diffuse, and specular components separately.
  • Clamp or tone-map final colors according to the renderer's color pipeline.

Common Pitfalls

  • Using unnormalized normals or light vectors.
  • Computing lighting vectors in different coordinate spaces.
  • Expecting the model to behave like physically based shading.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show rays, samples, buffers, or shading terms that contribute to the final pixel.

Phong Shading mechanism walkthrough step 1 of 5
Step 1 of 5: Normalize the surface normal, light direction, and view direction.
rendering-mechanism

Notes

Phong shading is a local illumination model; it does not simulate indirect light transport.

Sources (1)

What each reference supports for this entry.

Phong 1975

Paper

Original illumination model paper for diffuse and specular shading.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Blinn-Phong modifies Phong's specular term with a halfway vector.

Conceptual neighborCook-Torrance Shading

Both are local shading models with specular terms.

Tags

GraphicsShadingLightingClassic