Graphics Lighting Models
This document provides a comprehensive overview of various lighting models used in computer graphics. Understanding these models is crucial for creating realistic and visually appealing 3D scenes.
Fundamentals of Light and Surfaces
Light in a 3D scene is typically simulated as rays originating from light sources and interacting with the surfaces of objects. The appearance of a surface is determined by how it reflects, absorbs, and emits light. Key properties of light and surfaces include:
- Color: The spectral distribution of light.
- Intensity: The brightness of the light.
- Direction: The vector indicating the path of light.
- Surface Properties: Reflectivity, diffuseness, specularity, and emission.
Types of Light Sources
Different light sources simulate real-world phenomena and contribute to scene illumination in distinct ways:
- Ambient Light: Uniform light that illuminates all objects equally, simulating indirect illumination. It provides a base level of brightness and prevents completely dark areas.
- Directional Light: Simulates light from a distant source, like the sun. All rays are parallel, meaning they have the same direction and intensity everywhere.
- Point Light: Emits light uniformly in all directions from a single point. Its intensity decreases with distance from the source (often following the inverse square law).
- Spotlight: A cone of light originating from a point, with a defined direction and angular spread. It can have properties like inner and outer cone falloff.
- Area Light: Simulates light emitted from a surface area (e.g., a fluorescent panel). This can produce softer shadows and more realistic highlights than point lights.
Common Lighting Models
1. Phong Lighting Model
The Phong lighting model is an empirical model that approximates the way light interacts with a surface. It calculates the color of a pixel by summing three components: ambient, diffuse, and specular reflection.
- Ambient: Contribution from ambient light.
Ia = Ka * La - Diffuse: Light scattered equally in all directions from a rough surface. It depends on the angle between the surface normal and the light direction.
Id = Kd * La * max(0, dot(N, L)) - Specular: Highlights on shiny surfaces, dependent on the viewer's position and the light direction.
Is = Ks * Lp * max(0, dot(R, V))^shininess
WhereRis the reflection vector,Vis the view vector,shininesscontrols the size of the highlight.
The final color is Ci = Ia + Id + Is. This model is computationally efficient and widely used.
2. Blinn-Phong Lighting Model
A modification of the Phong model that uses a halfway vector H instead of calculating the reflection vector R, which can be more computationally efficient for some hardware. The specular component is calculated as:
Is = Ks * Lp * max(0, dot(N, H))^shininess
This model offers similar visual results to Phong with potentially better performance.
3. Physically Based Rendering (PBR)
PBR aims to simulate light interaction more accurately based on physical principles. Instead of empirical formulas, PBR uses material properties derived from real-world measurements. Key concepts include:
- Microfacet Theory: Models surfaces as being composed of many tiny, randomly oriented facets.
- Energy Conservation: Ensures that the total amount of light reflected or transmitted by a surface does not exceed the incoming light.
- Material Properties: Albedo (base color), Metallic, Roughness, and Specular.
PBR typically uses the Cook-Torrance BRDF (Bidirectional Reflectance Distribution Function) and produces more consistent and realistic results across different lighting conditions.
Example: Applying Ambient and Diffuse Light
Consider a diffuse surface with a green color (Kd = (0, 1, 0)) and ambient reflectivity Ka = 0.2. The ambient light La = (0.1, 0.1, 0.1) and directional light L = (0.5, 0.5, 0.5). If the surface normal N is (0, 1, 0) and the dot product dot(N, L) = 0.7:
Ambient Contribution: Ia = 0.2 * 0.1 = 0.02 (for each color channel)
Diffuse Contribution: Id = Kd * La * 0.7 = (0, 1, 0) * (0.1, 0.1, 0.1) * 0.7 = (0, 0.07, 0)
The resulting color would be influenced by these calculations, with the dominant diffuse component making the object appear green under the light.
Advanced Lighting Techniques
- Global Illumination: Simulates indirect lighting, such as light bouncing off surfaces (radiosity) or light passing through translucent objects.
- Shadows: Techniques like shadow mapping and shadow volumes are used to render shadows cast by objects.
- Reflections and Refractions: Simulating how light bounces off or bends through surfaces to create realistic mirror or glass effects.
Conclusion
The choice of lighting model significantly impacts the visual fidelity and performance of a graphics application. From the simplicity of Phong to the accuracy of PBR, each model offers trade-offs suitable for different use cases.