Key Concepts in Shading Models and Techniques

  1. Ambient, Diffuse, Specular, and Emission Model:

    • Ambient: Represents background light that illuminates objects uniformly from all directions. Formula: .
    • Diffuse: Light that reflects equally in all directions, often caused by rough surfaces. Formula: .
    • Specular: Light reflected in a specific direction, creating highlights. Two common models are:
      • Phong Model: Scales with , where controls shininess.
      • Blinn Model: Uses a halfway vector , scaling with .
    • Emission: Simulates surfaces that emit light themselves, giving the appearance of self-illumination.
  2. Highlight Models:

    • Phong Model: Calculates specular highlights based on the angle between the reflection direction and the view direction .
    • Blinn Model: Uses the halfway vector , which is more efficient for real-time calculations.
  3. Types of Shading:

    • Flat Shading: Lighting is computed once per triangle, giving a faceted look.
    • Gouraud Shading: Lighting is computed per vertex and interpolated across the triangle, resulting in smoother shading but can miss finer specular details.
    • Phong Shading: Lighting is calculated per pixel using interpolated normals, providing more detailed and realistic shading at a higher computational cost.
  4. Transparency and Blending:

    • For rendering transparent objects, draw triangles from back-to-front to ensure correct blending. The blending formula is , where is the transparency level.
    • Use the OpenGL function glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) to enable this blending effect.
  5. Gamma Correction:

    • Purpose: Corrects for the non-linear response of screens, ensuring colors display accurately across devices and optimizing precision in low-intensity regions.
    • Formula: Adjusts colors by raising them to the power of , where is typically 2.2. This process helps achieve consistent brightness and color representation across displays.
    • Reasons:
      • Screen has non-linear color intensity, and we often really want linear output (e.g. for correct antialiasing)
      • By applying gamma correction, we compress the dynamic range of the brighter tones and expand the lower range of intensities. This compression redistributes the precision so that more bits are allocated to darker values where our eyes are more perceptive.