Computer graphics lighting is the collection of techniques used to simulate light in
computer graphics
Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great de ...
scenes. While lighting techniques offer flexibility in the level of detail and functionality available, they also operate at different levels of computational demand and
complexity
Complexity characterises the behaviour of a system or model whose components interaction, interact in multiple ways and follow local rules, leading to nonlinearity, randomness, collective dynamics, hierarchy, and emergence.
The term is generall ...
. Graphics artists can choose from a variety of light sources, models, shading techniques, and effects to suit the needs of each application.
Light sources
Light sources allow for different ways to introduce light into graphics scenes.
Point
Point sources emit light from a single point in all directions, with the intensity of the light decreasing with distance.
An example of a point source is a standalone light bulb.
Directional
A directional source (or distant source) uniformly lights a scene from one direction.
Unlike a point source, the intensity of light produced by a directional source does not change with distance over the scale of the scene, as the directional source is treated as though it is extremely far away.
An example of a directional source is sunlight on Earth.
Spotlight
A spotlight produces a directed
cone
A cone is a three-dimensional geometric shape that tapers smoothly from a flat base (frequently, though not necessarily, circular) to a point called the apex or vertex.
A cone is formed by a set of line segments, half-lines, or lines con ...
of light.
The light becomes more intense as you get closer to the spotlight source and to the center of the light cone.
An example of a spotlight is a flashlight.
Ambient
Ambient light sources illuminate objects even when no other light source is present.
The intensity of ambient light is independent of direction, distance, and other objects, meaning the effect is completely uniform throughout the scene.
This source ensures that objects are visible even in complete darkness.
Lightwarp
A lightwarp is a technique of which an object in the geometrical world
refracts
In physics, refraction is the redirection of a wave as it passes from one transmission medium, medium to another. The redirection can be caused by the wave's change in speed or by a change in the medium. Refraction of light is the most common ...
light based on the
direction and
intensity
Intensity may refer to:
In colloquial use
*Strength (disambiguation)
*Amplitude
* Level (disambiguation)
* Magnitude (disambiguation)
In physical sciences
Physics
*Intensity (physics), power per unit area (W/m2)
*Field strength of electric, ma ...
of the light. The light is then
warped using an ambient diffuse term with a range of the
color spectrum
The visible spectrum is the portion of the electromagnetic spectrum that is visual perception, visible to the human eye. Electromagnetic radiation in this range of wavelengths is called ''visible light'' or simply light. A typical human eye wil ...
. The light then may be
reflectively scattered to produce a higher
depth of field
The depth of field (DOF) is the distance between the nearest and the furthest objects that are in acceptably sharp focus in an image captured with a camera.
Factors affecting depth of field
For cameras that can only focus on one object dist ...
, and
refracted
In physics, refraction is the redirection of a wave as it passes from one medium to another. The redirection can be caused by the wave's change in speed or by a change in the medium. Refraction of light is the most commonly observed phenomeno ...
. The technique is used to produce a
unique rendering style and can be used to limit
overexposure
In photography, exposure is the amount of light per unit area (the image plane's illuminance times the exposure time) reaching a frame of photographic film or the surface of an electronic image sensor, as determined by shutter speed, lens F- ...
of objects. Games such as
Team Fortress 2
''Team Fortress 2'' is a 2007 multiplayer first-person shooter, first-person shooter game developed and published by Valve Corporation. It is the sequel to the 1996 ''Team Fortress'' Mod (video gaming), mod for ''Quake (video game), Quake'' and ...
use the rendering technique to create a
cartoon
A cartoon is a type of visual art that is typically drawn, frequently animated, in an unrealistic or semi-realistic style. The specific meaning has evolved over time, but the modern usage usually refers to either: an image or series of images ...
cel shaded
Cel shading or toon shading is a type of non-photorealistic rendering designed to make 3-D computer graphics appear to be flat by using less shading color instead of a shade gradient or tints and shades. A cel shader is often used to mimic th ...
stylized look.
Lighting interactions
In computer graphics, the overall effect of a light source on an object is determined by the combination of the object's interactions with it usually described by at least three main components.
The three primary lighting components (and subsequent interaction types) are diffuse, ambient, and specular.
Diffuse
Diffuse lighting (or
diffuse reflection
Diffuse reflection is the reflection (physics), reflection of light or other radiation, waves or particles from a surface such that a ray (optics), ray incident on the surface is scattering, scattered at many angles rather than at just one angle ...
) is the direct illumination of an object by an even amount of light interacting with a
light-scattering surface.
After light strikes an object, it is reflected as a function of the surface properties of the object as well as the angle of incoming light.
This interaction is the primary contributor to the object's brightness and forms the basis for its color.
Ambient
As ambient light is directionless, it interacts uniformly across all surfaces, with its intensity determined by the strength of the ambient light sources and the properties of objects' surface materials, namely their ambient
reflection coefficients.
Specular
The
specular lighting
A specular highlight is the bright spot of light that appears on shiny objects when illuminated (for example, see image on right). Specular highlights are important in 3D computer graphics, as they provide a strong visual cue for the shape of a ...
component gives objects shine and highlights.
This is distinct from mirror effects because other objects in the environment are not visible in these reflections.
Instead, specular lighting creates bright spots on objects based on the intensity of the specular lighting component and the specular reflection coefficient of the surface.
Illumination models
Lighting models are used to replicate lighting effects in
rendered environments where light is approximated based on the physics of light.
Without lighting models, replicating lighting effects as they occur in the natural world would require more processing power than is practical for computer graphics.
This lighting, or illumination model's purpose is to compute the color of every pixel or the amount of light reflected for different surfaces in the scene. There are two main illumination models, object oriented lighting and global illumination.
They differ in that object oriented lighting considers each object individually, whereas global illumination maps how light interacts between objects.
Currently, researchers are developing global illumination techniques to more accurately replicate how light interacts with its environment.
Object oriented lighting
Object oriented lighting, also known as local illumination, is defined by mapping a single light source to a single object.
This technique is fast to compute, but often is an incomplete approximation of how light would behave in the scene in reality.
It is often approximated by summing a combination of specular, diffuse, and ambient light of a specific object.
The two predominant local illumination models are the Phong and the Blinn-Phong illumination models.
Phong illumination model
One of the most common reflection models is the Phong model.
The Phong model assumes that the intensity of each
pixel
In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a raster image, or the smallest point in an all points addressable display device.
In most digital display devices, pixels are the smal ...
is the sum of the intensity due to diffuse, specular, and ambient lighting.
This model takes into account the location of a viewer to determine specular light using the angle of light reflecting off an object.
The
cosine of the angle is taken and raised to a power decided by the designer.
With this, the designer can decide how wide a highlight they want on an object; because of this, the power is called the shininess value.
The shininess value is determined by the roughness of the surface where a mirror would have a value of infinity and the roughest surface might have a value of one.
This model creates a more realistic looking white highlight based on the perspective of the viewer.
Blinn-Phong illumination model
The Blinn-Phong illumination model is similar to the Phong model as it uses specular light to create a highlight on an object based on its shininess.
[James F. Blinn (1977). "Models of light reflection for computer synthesized pictures". ''Proc. 4th annual conference on computer graphics and interactive techniques'': 192–198. ]CiteSeerX
CiteSeerX (formerly called CiteSeer) is a public search engine and digital library for scientific and academic papers, primarily in the fields of computer and information science.
CiteSeer's goal is to improve the dissemination and access of ac ...
10.1.1.131.7741. The Blinn-Phong differs from the Phong illumination model, as the Blinn-Phong model uses the vector normal to the surface of the object and halfway between the light source and the viewer.
This model is used in order to have accurate specular lighting and reduced computation time.
The process takes less time because finding the reflected light vector's direction is a more involved computation than calculating the halfway
normal vector
In geometry, a normal is an object such as a line, ray, or vector that is perpendicular to a given object. For example, the normal line to a plane curve at a given point is the (infinite) line perpendicular to the tangent line to the curve at ...
.
While this is similar to the Phong model, it produces different visual results, and the specular reflection exponent or shininess might need modification in order to produce a similar specular reflection.
Global illumination
Global illumination differs from local illumination because it calculates light as it would travel throughout the entire scene.
This lighting is based more heavily in physics and optics, with light rays scattering, reflecting, and indefinitely bouncing throughout the scene.
There is still active research being done on global illumination as it requires more computational power than local illumination.
[Li, Hao (Fall 2018). "Global Illumination" (PDF).]
Ray tracing
Light sources emit rays that interact with various surfaces through absorption, reflection, or refraction.
An observer of the scene would see any light source that reaches their eyes; a ray that does not reach the observer goes unnoticed. It is possible to simulate this by having all of the light sources emit rays and then compute how each of them interact with all of the objects in the scene.
[Reif, J. H. (1994).]
Computability and Complexity of Ray Tracing
(PDF). ''Discrete and Computational Geometry''. However, this process is inefficient as most of the light rays would not reach the observer and would waste processing time.
[Wallace, John R.; Cohen, Michael F.; Greenberg, Donald P. (1987). "A Two-pass Solution to the Rendering Equation: A Synthesis of Ray Tracing and Radiosity Methods". ''Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques''. SIGGRAPH '87. New York, NY, USA: ACM: 311–320. . .] Ray tracing solves this problem by reversing the process, instead sending view rays from the observer and calculating how they interact until they reach a light source.
Although this way more effectively uses processing time and produces a light simulation closely imitating natural lighting, ray tracing still has high computation costs due to the high amounts of light that reach viewer's eyes.
Radiosity
Radiosity takes into account the energy given off by surrounding objects and the light source.
Unlike ray tracing, which is dependent on the position and orientation of the observer, radiosity lighting is independent of view position.
Radiosity requires more computational power than ray tracing, but can be more useful for scenes with static lighting because it would only have to be computed once. The surfaces of a scene can be divided into a large amount of patches; each patch radiates some light and affects the other patches, then a large set of equations needs to be solved simultaneously in order to get the final radiosity of each patch.
Photon mapping
Photon
A photon () is an elementary particle that is a quantum of the electromagnetic field, including electromagnetic radiation such as light and radio waves, and the force carrier for the electromagnetic force. Photons are massless, so they always ...
mapping was created as a two-pass global illumination algorithm that is more efficient than ray tracing.
[Wann Jensen, Henrik (1996).]
Global Illumination using Photon Maps
" (PDF). ''Rendering Techniques ’96'': 21–30. It is the basic principle of tracking photons released from a light source through a series of stages.
The first pass includes the photons being released from a light source and bouncing off their first object; this map of where the photons are located is then recorded.
The photon map contains both the position and direction of each photon which either bounce or are absorbed.
The second pass happens with
rendering where the reflections are calculated for different surfaces.
In this process, the photon map is decoupled from the geometry of the scene, meaning rendering can be calculated separately.
It is a useful technique because it can simulate caustics, and pre-processing steps do not need to be repeated if the view or objects change.
Polygonal shading
Polygonal
shading
Shading refers to the depiction of depth perception in 3D models (within the field of 3D computer graphics) or illustrations (in visual art) by varying the level of darkness. Shading tries to approximate local behavior of light on the object's ...
is part of the
rasterization
In computer graphics, rasterisation (British English) or rasterization (American English) is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (a series of pixels, dots or lines, whic ...
process where
3D models are drawn as
2D pixel images.
Shading applies a lighting model, in conjunction with the geometric attributes of the 3D model, to determine how lighting should be represented at each
fragment (or pixel) of the resulting image.
The
polygons
In geometry, a polygon () is a plane figure that is described by a finite number of straight line segments connected to form a closed ''polygonal chain'' (or ''polygonal circuit''). The bounded plane region, the bounding circuit, or the two toge ...
of the 3D model store the geometric values needed for the shading process.
This information includes
vertex
Vertex, vertices or vertexes may refer to:
Science and technology Mathematics and computer science
*Vertex (geometry), a point where two or more curves, lines, or edges meet
*Vertex (computer graphics), a data structure that describes the position ...
positional values and
surface normals
In geometry, a normal is an object such as a line, ray, or vector that is perpendicular to a given object. For example, the normal line to a plane curve at a given point is the (infinite) line perpendicular to the tangent line to the curve at ...
, but can contain optional data, such as
texture
Texture may refer to:
Science and technology
* Surface texture, the texture means smoothness, roughness, or bumpiness of the surface of an object
* Texture (roads), road surface characteristics with waves shorter than road roughness
* Texture (c ...
and
bump
Bump or Bumps may refer to:
* A collision or impact
* A raised protrusion on the skin such as a pimple, goose bump, prayer bump, lie bumps, etc.
Infrastructure and industry
* Coal mine bump, a seismic jolt occurring within a mine
* Bump (uni ...
maps.
Flat shading
Flat shading is a simple shading model with a uniform application of lighting and color per polygon.
The color and normal of one vertex is used to calculate the shading of the entire polygon.
Flat shading is inexpensive, as lighting for each polygon only needs to be calculated once per render.
Gouraud shading
Gouraud shading
Gouraud shading, named after Henri Gouraud, is an interpolation method used in computer graphics to produce continuous shading of surfaces represented by polygon meshes. In practice, Gouraud shading is most often used to achieve continuous l ...
is a type of interpolated shading where the values inside of each polygon are a blend of its vertex values.
Each vertex is given its own normal consisting of the average of the surface normals of the surrounding polygons.
The lighting and shading at that vertex is then calculated using the average normal and the lighting model of choice.
This process is repeated for all the vertices in the 3D model.
Next, the shading of the edges between the vertices is calculated by
interpolating
In the mathematics, mathematical field of numerical analysis, interpolation is a type of estimation, a method of constructing (finding) new data points based on the range of a discrete set of known data points.
In engineering and science, one ...
between the vertex values.
Finally, the shading inside of the polygon is calculated as an interpolation of the surrounding edge values.
Gouraud shading generates a smooth lighting effect across the 3D model's surface.
Phong shading
Phong shading
In 3D computer graphics, Phong shading, Phong interpolation, or normal-vector interpolation shading is an interpolation technique for surface shading invented by computer graphics pioneer Bui Tuong Phong. Phong shading interpolates surface nor ...
, similar to Gouraud shading, is another type of interpolative shading that blends between vertex values to shade polygons.
The key difference between the two is that Phong shading interpolates the
vertex normal
In the geometry of computer graphics, a vertex normal at a vertex of a polyhedron is a directional vector associated with a vertex, intended as a replacement to the true geometric normal of the surface. Commonly, it is computed as the normalized ...
values over the whole polygon before it calculates its shading.
This contrasts with Gouraud shading which interpolates the already shaded vertex values over the whole polygon.
Once Phong shading has calculated the normal of a fragment (pixel) inside the polygon, it can then apply a lighting model, shading that fragment.
This process is repeated until each polygon of the 3D model is shaded.
Lighting effects
Caustics
Caustics are an effect of light reflected and refracted in a medium with curved interfaces or reflected off a curved surface.
They appear as ribbons of concentrated light and are often seen when looking at bodies of water or glass.
Caustics can be implemented in 3D graphics by blending a caustic
texture map
Texture mapping is a method for mapping a texture on a computer-generated graphic. Texture here can be high frequency detail, surface texture, or color.
History
The original technique was pioneered by Edwin Catmull in 1974.
Texture mapping ...
with the texture map of the affected objects.
The caustics texture can either be a static image that is animated to mimic the effects of caustics, or a
Real-time
Real-time or real time describes various operations in computing or other processes that must guarantee response times within a specified time (deadline), usually a relatively short time. A real-time process is generally one that happens in defined ...
calculation of caustics onto a blank image.
The latter is more complicated and requires backwards
ray tracing to simulate photons moving through the environment of the 3D render.
In a photon mapping illumination model,
Monte Carlo
Monte Carlo (; ; french: Monte-Carlo , or colloquially ''Monte-Carl'' ; lij, Munte Carlu ; ) is officially an administrative area of the Principality of Monaco, specifically the ward of Monte Carlo/Spélugues, where the Monte Carlo Casino is ...
sampling is used in conjunction with the ray tracing to compute the intensity of light caused by the caustics.
Reflection mapping
Reflection mapping (also known as environment mapping) is a technique which uses 2D environment maps to create the effect of
reflectivity
The reflectance of the surface of a material is its effectiveness in reflecting radiant energy. It is the fraction of incident electromagnetic power that is reflected at the boundary. Reflectance is a component of the response of the electronic ...
without using ray tracing.
Since the appearances of reflective objects depend on the relative positions of the viewers, the objects, and the surrounding environments, graphics algorithms produce reflection vectors to determine how to color the objects based on these elements. Using 2D environment maps rather than fully rendered, 3D objects to represent surroundings, reflections on objects can be determined using simple, computationally inexpensive algorithms.
Particle systems
Particle systems use collections of small
particles
In the physical sciences, a particle (or corpuscule in older texts) is a small localized object which can be described by several physical or chemical properties, such as volume, density, or mass.
They vary greatly in size or quantity, from su ...
to model chaotic, high-complexity events, such as fire, moving liquids, explosions, and moving hair.
Particles which make up the complex animation are distributed by an emitter, which gives each particle its properties, such as speed, lifespan, and color.
Over time, these particles may move, change color, or vary other properties, depending on the effect.
Typically, particle systems incorporate
randomness
In common usage, randomness is the apparent or actual lack of pattern or predictability in events. A random sequence of events, symbols or steps often has no order and does not follow an intelligible pattern or combination. Individual rand ...
, such as in the initial properties the emitter gives each particle, to make the effect realistic and non-uniform.
See also
*
Per-pixel lighting
In computer graphics, per-pixel lighting refers to any technique for lighting an image or scene that calculates illumination for each pixel on a rendered image. This is in contrast to other popular methods of lighting such as vertex lighting, whi ...
*
Computer graphics
Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great de ...
References
{{DEFAULTSORT:Computer Graphics Lighting
3D rendering
Lighting
Shading