Lighting, Lighting Effects, Shadows, and Reflections
LightingLighting in computer graphics determines how light sources affect an object’s appearance, defining its color and brightness on a pixel grid. It uses models like ambient (uniform background light), diffuse (light scattering based on surface angle), and specular (shiny highlights on reflective surfaces).
|
|
Ambient Lighting
Ambient lighting represents uniform, non-directional light that illuminates all objects equally, simulating background light in a scene (e.g. a room’s overall glow). It ensures no part of a scene is completely dark, providing a baseline brightness without complex calculations. In rendering, it’s a simple constant added to pixel colors, used in both rasterization and ray tracing for efficiency. Ambient lighting affects texture appearance minimally but prevents unnatural darkness in bitmap displays, making it essential for balanced visuals. |
|
Diffuse Lighting
Diffuse lighting models light scattering evenly across a surface, like sunlight hitting a matte wall. Its intensity depends on the angle between the light source and the surface’s normal (perpendicular direction), with brighter results when light hits directly. Calculated using Lambert’s cosine law, it adds realism by showing surface orientation. In rasterisation, diffuse lighting is computed per pixel for speed; in ray tracing, it’s more precise tracing rays to account for exact light angles and global illumination. Diffuse lighting enhances texture details (e.g. a textured brick surface) in bitmap rendering. |
|
Specular Lighting
Specular lighting simulates shiny highlights on reflective surfaces, like a polished metal sphere, based on the light source, surface normal, and viewer’s position. It uses models like Phong shading, where intensity peaks when reflected light aligns with the viewer’s perspective. Ray tracing handles specular effects accurately by tracing reflected rays, while rasterisation approximates them for speed. Specular lighting makes textures appear glossy or metallic, adding depth to bitmap and vector-based scenes, especially in realistic rendering. |
Lighting Effects
|
When we use and combine lighting in different ways we can get different effects that enhance our scenes to look more realistic (or just cooler).
Some examples of lighting effects include:
Ray tracing naturally produces these effects by simulating light paths, while rasterisation relies on approximations - using things like shadow maps - due to its focus on speed and performance. Lighting effects make scenes more lifelike, impacting how textures and objects appear, and are key in making our scenes more realistic. Note: when talking about these in exams it is important to not only talk about video games (as many might be tempted to). These effects are used heavily in films, in fact if you look at the credits for a movie that uses a lot of CGI you will see that a fairly large percentage of the people employed on it were working on lighting/lighting effects. |
Shadows
|
Shadows occur when objects block light, creating darker areas in a scene (also real life lol). In graphics, they add depth and realism by showing light-source relationships.
Rasterisation uses techniques like shadow maps, which approximate shadows quickly by rendering depth from the light’s perspective. Shadow maps are less resource intensive but may lack precision and produce jagged edges. Ray tracing calculates accurate shadows by tracing light rays to detect obstructions, producing soft or hard edges based on light type. Shadows interact with textures and lighting, affecting bitmap rendering (e.g. pixel colour adjustments) and requiring careful computation to avoid artifacts in real-time displays. For example, shadow maps may need anti-aliasing techniques to smooth edges, while ray-traced shadows naturally capture subtle variations, enhancing texture appearance in complex scenes. |
Reflections
|
Reflections simulate light bouncing off surfaces, like mirrors or glossy objects, adding realism to scenes. The type of reflection that we get is determined by the type of surface that the light is hitting.
Ray tracing accurately simulates specular and imperfect specular reflections by tracing light rays, capturing details like distorted reflections in glass, while rasterisation uses environment maps—precomputed textures—for faster but less precise reflections in real-time applications like games. This trade-off between realism and performance shapes how reflections enhance visuals in films and interactive media. |