This article explains the role of reflection in computer graphics, focusing on how light interacts with different surface types, such as specular, diffuse, and translucent surfaces. It introduces the Blinn-Phong lighting model, which breaks down light reflection into ambient, diffuse, and specular components to simulate realistic lighting in digital scenes.
In computer graphics, reproducing how light interacts with object surfaces is essential for creating an accurate representation of the real world. This process is called reflection. It is where light bounces off objects’ surfaces determining how objects are perceived.
In the real world, reflection is the process of light bouncing off a surface. The angle at which light reflects off the surface of an object determines how the object’s surface appears once it reaches the eye or a camera sensor. The surfaces can be grouped into three main types, which are specular surface, diffuse surface, and translucent surface, see Figure 1.
Figure 1
Light–Material Interactions
Note: The arrow represents the direction of the light rays. From “Chapter 6: Lighting and Shading. Interactive Computer Graphics. 8th edition” by Angel and Shreiner (2020). Modify.
- Specular surfaces appear shiny due to the light being reflected in a specific direction making the surface appear shiny.
- Diffuse surfaces reflect light by scattering in all directions. This makes the surface appear matte and uniform.
- Translucent surfaces allow some light to pass through it. This makes the surface appear partially transparent, lightly distorting the light and giving the surface a soft glow or blurred effect.
In computer graphics, reflection is computed using lighting models that simulate how light interacts with surfaces. The most common model is the Blinn-Phong Model, which breaks down reflection into three components based on the real-world diffuse and surface types. The three components are specular reflection, reflection, and diffuse reflection. In computer graphics, this component can be integrated into a 3x3 illumination matrix:
- The first row of the matrix contains the ambient intensities for the red, green, and blue terms from source i.
- The second row contains the diffuse terms.
- The third contains the specular terms. (Angel & Shreiner, 2020, p163)
Figure 2
Phong Reflection
Note: From “OpenGL — lighting with the Phong reflection model (part 1 of 2)” by Will (2019).
Note that:
- Ambient reflection represents indirect lighting, bouncing light, or general brightness.
- Specular reflection is related to the specular surfaces where the light is reflected in a specific direction, resulting in the surface looking shiny.
- Diffuse reflection is related to the diffuse surfaces where the light is scattering in all directions.
A homogenous vector derived from the matrix illumination matrix can be used to compute the lighting in a scene. For example, when using WebGL the code could look as follows:
Vertex Shader GLSL
uniform vec4 uAmbientProduct, uDiffuseProduct, uSpecularProduct;
varying vec4 vColor;
// Compute ambient component
vec4 ambient = uAmbientProduct;
// Compute diffuse component using Lambert's cosine law
float diffuseFactor = max(dot(normal, lightDirection), 0.0);
vec4 diffuse = diffuseFactor * uDiffuseProduct;
// Compute specular component using the Blinn-Phong model
vec3 halfwayDir = normalize(lightDirection + viewDirection);
float specularFactor = pow(max(dot(normal, halfwayDir), 0.0), uShininess);
To summarize, reflection is the process where light bounces off objects’ surfaces determining how objects are perceived. In computer graphics, reflection is computed using lighting models like the Blinn-Phong model, which breaks down light interactions into ambient, diffuse, and specular components. This process is essential for reproducing an accurate representation of the real world.
References:
Angel, E., & Shreiner, D. (2020). Chapter 6: Light and Shading. Interactive computer graphics. 8th edition. Pearson Education, Inc. ISBN: 9780135258262
Will, B. (2019, September 9). OpenGL — lighting with the Phong reflection model (part 1 of 2) [Video]. YouTube. https://www.youtube.com/watch?v=lH61rdpJ5v8
Originally published at Alex.omegapy - Medium on September 23, 2024.
Top comments (0)