Computer GraphicsUnit 109 min read

Illumination, Shading & Colour Models in 3D Graphics

Unit 10 of Computer Graphics covers how light interacts with surfaces (illumination models), techniques to render realistic shading (Gouraud, Phong, etc.), and colour representation systems (RGB, CMYK, HSL) used in games, movies, and real-time rendering pipelines.

TAKEAWAYS:

  • Illumination models (Phong, Gouraud) simulate light reflection using ambient, diffuse, and specular components.
  • Shading techniques (flat, Gouraud, Phong) determine how surfaces appear under light, with Phong interpolation being the most realistic.
  • Colour models (RGB, CMYK, HSL) define how colours are represented, stored, and manipulated in digital systems.
  • Real-world applications include game engines (Unity/Unreal), movie rendering (Blender), and AR/VR experiences.
  • Exam focus: Compare models, derive shading equations, and explain colour space conversions.

1. Illumination Models: How Light Interacts with Surfaces

Light interaction with surfaces is modeled mathematically to create realistic 3D scenes. The Phong Reflection Model is the most widely used, combining three components:

1.1 Components of Illumination

graph TD
    A["Light Source"] --> B["Ambient Light"]
    A --> C["Diffuse Reflection"]
    A --> D["Specular Reflection"]
    B --> E["Uniform Base Illumination"]
    C --> F["Surface Colour × Light Intensity"]
    D --> G["Highlight Spot"]
  • Ambient Light: Simulates indirect light (e.g., light bouncing off walls). Formula: where = ambient reflection coefficient, = ambient light intensity.

  • Diffuse Reflection: Light scattered equally in all directions (Lambertian reflection). Formula: where = light direction vector, = surface normal, = diffuse coefficient.

  • Specular Reflection: Highlights (e.g., shiny surfaces). Formula: where = reflection vector, = viewer direction, = shininess exponent.

Total Illumination:

1.2 Worked Example: Calculating Illumination for a Red Sphere

Assume:

  • Light source at
  • Viewer at
  • Surface normal
  • Reflection vector (mirror-like)
  • Coefficients: , , ,
  • Light intensities: , ,

Step-by-Step Calculation:

  1. Ambient:
  2. Diffuse ():
  3. Specular ():
  4. Total Illumination: (Clamped to for RGB: )

Real-World Tie-In: In Unity3D, the Standard Shader uses a modified Phong model. For a golden statue in a museum, the specular component () creates the shiny highlights, while diffuse () defines the base colour.


2. Shading Techniques: Rendering Surfaces Realistically

Shading determines how colours and intensities vary across a surface. Three key methods:

Shading Method Description Pros Cons
Flat Shading Single colour per polygon. Fastest. Unrealistic (blocky appearance).
Gouraud Shading Interpolates vertex colours across faces. Smoother than flat. Poor specular highlights.
Phong Shading Interpolates normals, then computes light. Most realistic. Computationally expensive.

2.1 Gouraud vs. Phong Shading

Gouraud: Interpolate RGBPhong: Interpolate NormalsPhong: Per-Pixel LightingVertex AVertex BVertex CVertex D
Gouraud shading interpolates vertex colours across faces, while Phong shading interpolates normals and computes lighting per pixel.

Worked Example: Gouraud Shading for a Triangle Vertices:

  • , colour (red)
  • , colour (green)
  • , colour (blue)

Step 1: Interpolate colours at pixel using barycentric coordinates: Result: Pixel at is purple ().

Real-World Tie-In: Pathao’s AR navigation uses Gouraud shading for real-time rendering of 3D maps. The interpolated colours help distinguish roads, buildings, and traffic in low-end devices.


3. Colour Models: Representing and Manipulating Colour

Colour models define how colours are stored and processed. Three key models:

3.1 RGB (Additive Colour Model)

  • Used in monitors, projectors, and digital cameras.
  • Combines Red, Green, Blue light to create all colours.
  • Gamut: All colours visible to the human eye (but limited by device).
Red (30%)Green (60%)Blue (10%)Black (0%)
RGB colour mixing: Combining red, green, and blue channels creates white light.

Worked Example: RGB to Grayscale Conversion Convert to grayscale using luminance weights: Result: Grayscale value = (dark gray).

3.2 CMYK (Subtractive Colour Model)

  • Used in printing (Cyan, Magenta, Yellow, Key/Black).
  • Conversion from RGB:

Worked Example: Print a red logo (): Result: (magenta + yellow = red).

3.3 HSL/HSV (Perceptual Colour Model)

  • Hue: to (colour wheel).
  • Saturation: to (intensity).
  • Lightness/Value: (black) to (white).

Worked Example: Convert (orange) to HSL:

  1. Hue:
  2. Saturation:
  3. Lightness: Result: .

Real-World Tie-In: Khalti’s app icons use HSL for consistent branding. Adjusting saturation makes the "Pay" button stand out while keeping harmony with the theme.


4. Colour Space Conversions

Critical for compatibility between devices (e.g., screen to print). Common conversions:

From To Formula
RGB CMYK , , ,
RGB Grayscale
HSL RGB Complex trigonometric functions (see Wikipedia).

Worked Example: Convert (blue) to CMYK: Result: .


5. Real-World Applications

5.1 Games and AR/VR

  • Unity/Unreal Engine: Use Phong shading for realistic materials (e.g., metal, glass).
  • Pokémon GO: Combines Gouraud shading for performance with Phong highlights for critical UI elements.

5.2 Movie Rendering (Blender, Maya)

  • Disney’s "Frozen": Uses advanced illumination models (e.g., subsurface scattering) for ice and skin.
  • Nepali Films: Low-budget films use simplified Phong models for character shading.

5.3 E-Commerce (Daraz, Amazon)

  • Product Rendering: CMYK is used for printed catalogues, while RGB dominates online displays.
  • Colour Accuracy: Daraz ensures product images match real colours by calibrating RGB profiles.

5.4 Medical Imaging

  • MRI Scans: Use HSL to distinguish tissues (e.g., high saturation for blood vessels).
  • Nepal’s Health Sector: Ultrasound images often convert RGB to grayscale for clarity.

6. Exam Tip

What Examiners Look For:

  1. Illumination Models:

    • Derive the Phong equation step-by-step.
    • Explain the difference between diffuse and specular reflection.
    • Common Pitfall: Forgetting to normalize vectors () or clamp final intensity.
  2. Shading Techniques:

    • Compare Gouraud vs. Phong in terms of realism and cost.
    • Worked Example: Given vertex colours/normals, compute interpolated values.
  3. Colour Models:

    • Conversion Questions: RGB ↔ CMYK, RGB ↔ Grayscale.
    • Applications: When to use HSL (design), CMYK (print), RGB (screens).
  4. Real-World Scenarios:

    • Ncell’s 3D Ads: How would you implement shading for a floating phone in an ad?
    • NEPSE Stock Charts: How would you represent red/green bars (RGB vs. HSL)?

Sample Exam Question: "A triangle has vertices A(red), B(green), C(blue). Using Gouraud shading, what colour appears at the centroid? Derive the CMYK equivalent of the centroid’s colour."


Based on the PU BE Computer (PU) syllabus for Computer Graphics, unit 10.

Discussion

Loading…