Computer graphics lighting: Difference between revisions

Content deleted Content added
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 26 templates: del empty params (38×); del |url-status= (8×);
Make a broader link to the whole concept rather than linking individual words. The linked page will link to the individual words if they are relevant
 
(44 intermediate revisions by 25 users not shown)
Line 1:
{{short description|Simulation of light in computer graphics}}
 
'''Computer graphics lighting''' isencompasses the collectionrange of techniques used to simulate light inwithin [[computer graphics]] scenes. WhileThese lightingmethods techniques offer flexibilityvary in the[[computational level of detail and functionality availablecomplexity]], theyoffering alsoartists operateflexibility atin differentboth levelsvisual of computational demanddetail and [[Computational complexity|complexity]]performance. Graphics artistsprofessionals can chooseselect from a varietywide array of [[light sourcessource]]s, models[[lighting model]]s, [[shading]] techniques, and effects to suitmeet the needsspecific requirements of each applicationproject.
 
== Light sources ==
Light sources allow for different ways to introduce light into graphics scenes.<ref>{{Cite news|url=https://garagefarm.net/blog/light-the-art-of-exposure|title=Light: The art of exposure|date=2020-11-11|work=GarageFarm|access-date=2020-11-11|language=en-US}}</ref><ref name=":727">{{Cite web|url=https://www.cs.uic.edu/~jbell/CourseNotes/ComputerGraphics/LightingAndShading.html|title=Intro to Computer Graphics: Lighting and Shading|website=www.cs.uic.edu|access-date=2019-11-05}}</ref>
 
=== Point ===
Point sources emit light from a single point in all directions, with the intensity of the light decreasing with distance.<ref name=":7372">{{Cite web|url=https://www.cs.uic.edu/~jbell/CourseNotes/ComputerGraphics/LightingAndShading.html|title=Intro to Computer Graphics: Lighting and Shading|website=www.cs.uic.edu|access-date=2019-11-05}}</ref> An example of a point source is a standalone light bulb.<ref name=":8">{{Cite web|url=http://www.bcchang.com/immersive/ygbasics/lighting.html|title=Lighting in 3D Graphics|website=www.bcchang.com|access-date=2019-11-05}}</ref>
[[File:Real-time Raymarched Terrain.png|thumb|309x309px|A directional light source illuminating a terrain.]]
 
=== Directional ===
A directional source (or distant source) uniformly lights a scene from one direction.<ref name=":8" /> 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 from the scene.<ref name=":8" /> An example of a directional source is sunlight on Earth.<ref name=":9">{{Cite web|url=https://www.pluralsight.com/blog/film-games/understanding-different-light-types|title=Understanding Different Light Types|website=www.pluralsight.com|language=en|access-date=2019-11-05}}</ref>
 
=== Spotlight ===
A spotlight produces a directed [[cone]] of light.<ref name=":73">{{Cite web|url=https://www.cs.uic.edu/~jbell/CourseNotes/ComputerGraphics/LightingAndShading.html|title=Intro to Computer Graphics: Lighting and Shading|website=www.cs.uic.edu|access-date=2019-11-05}}</ref> The light becomes more intense as the viewer gets closer to the spotlight source and to the center of the light cone.<ref name=":73" /> An example of a spotlight is a flashlight.<ref name=":9" />
 
=== Area ===
Area lights are 3D objects which emit light. Whereas point lights and spot lights sources are considered infinitesimally small points, area lights are treated as physical shapes.<ref>{{cite conference |last1=Lagarde |first1=Sebastien |author-link1= |last2=de Rousiers |first2=Charles |author-link2= |date=Summer 2014 |title=Moving Frostbite to Physically Based Rendering 3.0 |url=https://www.ea.com/frostbite/news/moving-frostbite-to-pb |conference=SIGGRAPH |___location= |publisher= |pages= |id= |book-title=}}</ref> Area light produce softer shadows and more realistic lighting than point lights and spot lights.<ref>{{Cite book |last1=Pharr |first1=Matt |title=Physically Based Rendering: From Theory to Implementation |last2=Humphreys |first2=Greg |last3=Wenzel |first3=Jakob |publisher=Morgan Kaufmann |year=2016 |isbn=978-0128006450 |edition=3rd |language=English}}</ref>
 
=== Ambient ===
Ambient light sources illuminate objects even when no other light source is present.<ref name=":73" /> The intensity of ambient light is independent of direction, distance, and other objects, meaning the effect is completely uniform throughout the scene.<ref name=":73" /> This source ensures that objects are visible even in complete darkness.<ref name=":9" />
 
=== Lightwarp ===
A lightwarp is a technique of which an object in the geometrical world [[refracts]] light based on the [[Unit vector|direction]] and [[Intensity (physics)|intensity]] of the light. The light is then [[Wave function|warped]] using an ambient diffuse term with a range of the [[color spectrum]]. The light then may be [[reflectively]] scattered to produce a higher [[depth of field]], and [[refracted]]. The technique is used to produce a [[Style_(visual_arts)#Stylization|unique rendering style]] and can be used to limit [[overexposure]] of objects. Games such as [[Team Fortress 2]] use the rendering technique to create a [[cartoon]] [[cel shaded]] stylized look.<ref>{{Cite book|chapter-url=https://hal.inria.fr/inria-00449828|chapter=Radiance Scaling for Versatile Surface Enhancement|first1=Romain|last1=Vergne|first2=Romain|last2=Pacanowski|first3=Pascal|last3=Barla|first4=Xavier|last4=Granier|first5=Christophe|last5=Schlick|title=Proceedings of the 2010 ACM SIGGRAPH symposium on Interactive 3D Graphics and Games |date=February 19, 2010|pages=143–150 |publisher=ACM|via=hal.inria.fr|doi=10.1145/1730804.1730827|isbn=9781605589398 |s2cid=18291692 }}</ref>
 
===HDRI===
HDRI stands for High dynamic range image and is a 360° image that is wrapped around a [[3D modeling|3D model]] as an outdoor setting and uses the sun typically as a light source in the sky. The [[Texture mapping|textures]] from the model can reflect the direct and [[Shading#Ambient lighting|ambient light]] and colors from the HDRI.<ref>{{cite web | url=https://visao.ca/what-is-hdri/#:~:text=High%20dynamic%20range%20images%20are,look%20cartoonish%20and%20less%20professional. | title=What are HDRI images? | date=13 January 2021 }}</ref>
 
== Lighting interactions ==
In computer graphics, the overall effect of a light usuallysource consistson an object is determined by the combination of multiplethe object's interactions with it usually described by at least three main components.<ref name=":82">{{Cite web|url=http://www.bcchang.com/immersive/ygbasics/lighting.html|title=Lighting in 3D Graphics|website=www.bcchang.com|access-date=2019-11-05}}</ref> The overall effect of a light source on an object is determined by the combination of the object's interactions with these components.<ref name=":82" /> The three primary lighting components (and subsequent interaction types) are diffuse, ambient, and specular.<ref name=":82" />
[[File:Phong components revised.png|thumb|544x544px|Decomposition of lighting interactions.]]
 
=== Diffuse ===
Diffuse lighting (or [[diffuse reflection]]) is the direct illumination of an object by an even amount of light interacting with a [[Scattering|light-scattering]] surface.<ref name=":838">{{Cite web|url=http://www.bcchang.com/immersive/ygbasics/lighting.html|title=Lighting in 3D Graphics|website=www.bcchang.com|access-date=2019-11-05}}</ref><ref name=":10">{{Cite web|url=http://graphics.cs.cmu.edu/nsp/course/15-462/Spring04/slides/07-lighting.pdf|title=Lighting and Shading|last=Pollard|first=Nancy|author-link=Nancy Pollard|date=Spring 2004}}</ref> After light strikes an object, it is [[Reflection (computer graphics)|reflected]] as a function of the surface properties of the object as well as the angle of incoming light.<ref name=":10" /> This interaction is the primary contributor to the object's brightness and forms the basis for its color.<ref name=":83">{{Cite web|url=http://www.bcchang.com/immersive/ygbasics/lighting.html|title=Lighting in 3D Graphics|website=www.bcchang.com|access-date=2019-11-05}}</ref>
 
=== Ambient ===
Line 40 ⟶ 49:
==== Phong illumination model ====
{{Main|Phong reflection model}}
One of the most common shadingreflection models is the Phong model.<ref name=":1" /> The Phong model assumes that the intensity of each [[pixel]] is the sum of the intensity due to diffuse, specular, and ambient lighting.<ref name=":3" /> This model takes into account the ___location of a viewer to determine specular light using the angle of light reflecting off an object.<ref name=":4" /> The [[Trigonometric functions|cosine]] of the angle is taken and raised to a power decided by the designer.<ref name=":3" /> 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.<ref name=":4" /> 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.<ref name=":3" /> This model creates a more realistic looking white highlight based on the perspective of the viewer.<ref name=":1" />
 
==== Blinn-Phong illumination model ====
Line 53 ⟶ 62:
{{Main articles|Ray tracing (graphics)}}
[[File:Ray-traced steel balls.jpg|thumb|Image rendered using ray tracing]]
Light sources emit rays that interact with various surfaces through absorption, reflection, or refraction.<ref name=":72" /> An observer of the scene would see any light source that reaches their eyes; a ray that does not reach the observer goes unnoticed.<ref>{{Cite web|url=https://developer.nvidia.com/rtx/raytracing|title=Introducing the NVIDIA RTX Ray Tracing Platform|date=2018-03-06|website=NVIDIA Developer|language=en|access-date=2019-11-08}}</ref> It is possible to simulate this by having all of the light sources emit rays and then compute how of each of them interact with all of the objects in the scene.<ref name=":17">Reif, J. H. (1994). "[https://users.cs.duke.edu/~reif/paper/tygar/raytracing.pdf Computability and Complexity of Ray Tracing]"(PDF). ''Discrete and Computational Geometry''.</ref> However, this process is inefficient as most of the light rays would not reach the observer and would waste processing time.<ref name=":21">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. {{doi|10.1145/37401.37438}}. {{ISBN|9780897912273}}.</ref> 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.<ref name=":17" /> 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.<ref name=":0">{{Cite journal|last=Greenberg|first=Donald P.|date=1989-04-14|title=Light Reflection Models for Computer Graphics|journal=Science|language=en|volume=244|issue=4901|pages=166–173|doi=10.1126/science.244.4901.166|issn=0036-8075|pmid=17835348|bibcode=1989Sci...244..166G |s2cid=46575183 }}</ref>
 
==== Radiosity ====
Line 61 ⟶ 70:
==== Photon mapping ====
{{Main|Photon mapping}}
[[Photon]] mapping was created as a two-pass global illumination algorithm that is more efficient than raytracingray tracing.<ref name=":19">Wann Jensen, Henrik (1996). "[http://graphics.ucsd.edu/~henrik/papers/photon_map/global_illumination_using_photon_maps_egwr96.pdf Global Illumination using Photon Maps] {{Webarchive|url=https://web.archive.org/web/20080808140048/http://graphics.ucsd.edu/~henrik/papers/photon_map/global_illumination_using_photon_maps_egwr96.pdf |date=2008-08-08 }}" (PDF). ''Rendering Techniques ’96'': 21–30.</ref> It is the basic principle of tracking photons released from a light source through a series of stages.<ref name=":19" /> The first pass includes the photons being released from a light source and bouncing off their first object; this map of where are the photons are located is then recorded.<ref name=":18" /> The photon map contains both the position and direction of each photon which either bounce or are absorbed.<ref name=":19" /> The second pass happens with [[Rendering (computer graphics)|rendering]] where the reflections are calculated for different surfaces.<ref name=":20">{{Cite web|url=https://web.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/photon_mapping/PhotonMapping.html|title=Photon Mapping - Zack Waters|website=web.cs.wpi.edu|access-date=2019-11-08}}</ref> In this process, the photon map is decoupled from the geometry of the scene, meaning rendering can be calculated separately.<ref name=":18" /> 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.<ref name=":20" />
 
== Polygonal shading ==
{{Main|Shading}}
 
Polygonal [[shading]] is part of the [[Rasterisation|rasterization]] process where [[3D computer graphics|3D]] models are drawn as [[2D computer graphics|2D]] pixel images.<ref name=":4">{{Cite web|url=https://cglearn.codelight.eu/pub/computer-graphics/shading-and-lighting|title=Computer Graphics: Shading and Lighting|website=cglearn.codelight.eu|access-date=2019-10-30}}</ref> 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 (computer graphics)|fragment]] (or pixel) of the resulting image.<ref name=":4" /> The [[Polygon mesh|polygons]] of the 3D model store the geometric values needed for the shading process.<ref name=":11">{{Cite web|url=http://math.hws.edu/graphicsbook/c4/s1.html|title=Introduction to Computer Graphics, Section 4.1 -- Introduction to Lighting|website=math.hws.edu}}</ref> This information includes [[Vertex (geometry)|vertex]] positional values and [[Normal (geometry)|surface normals]], but can contain optional data, such as [[Texture mapping|texture]] and [[Bump mapping|bump]] maps.<ref>{{Cite web|url=https://www.khronos.org/opengl/wiki/Vertex_Specification#Primitives|title=Vertex Specification - OpenGL Wiki|website=www.khronos.org|access-date=2019-11-06}}</ref>
[[File:Flatshading00.png|alt=|thumb|165x165px|An example of flat shading.]]
[[File:Gouraudshading01.png|alt=|thumb|165x165px|An example of Gouraud shading.]]
[[File:Phongshading00.png|alt=|thumb|165x165px|An example of Phong shading.]]
 
=== Flat shading ===
Line 75 ⟶ 84:
 
=== Gouraud shading ===
[[Gouraud shading]] is a type of interpolated shading where the values inside of each polygon are a blend of its vertex values.<ref name=":4" /> Each vertex is given its own normal consisting of the average of the surface normals of the surrounding polygons.<ref name=":12" /> The lighting and shading at that vertex is then calculated using the average normal and the lighting model of choice.<ref name=":12" /> This process is repeated for all the vertices in the 3D model.<ref name=":7">{{Cite web|url=https://www.cs.uic.edu/~jbell/CourseNotes/ComputerGraphics/LightingAndShading.html|title=Intro to Computer Graphics: Lighting and Shading|website=www.cs.uic.edu|access-date=2019-11-05}}</ref> Next, the shading of the edges between the vertices is calculated by [[Interpolation|interpolating]] between the vertex values.<ref name=":7" /> Finally, the shading inside of the polygon is calculated as an interpolation of the surrounding edge values.<ref name=":7" /> Gouraud shading generates a smooth lighting effect across the 3D model's surface.<ref name=":7" />
 
=== Phong shading ===
Line 81 ⟶ 90:
 
== Lighting effects ==
[[File:Miroir-cercle.jpg|thumb|A reflective material demonstrating caustics.]]
 
=== Caustics ===
{{Main articles|Caustic (optics)}}
[[Caustic (optics)|Caustics]] are a lightingan effect of light reflected and refracted lightin movinga medium with curved interfaces or reflected throughoff a mediumcurved surface.<ref name=":14">{{Cite web|url=https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch02.html|title=GPU Gems|website=NVIDIA Developer|language=en|access-date=2019-10-30}}</ref> They appear as ribbons of concentrated light and are often seen when looking at bodies of water or glass.<ref name=":15">{{Cite web|url=https://www.dualheights.se/caustics/caustics-water-texturing-using-unity3d.shtml|title=Caustics water texturing using Unity 3D|website=www.dualheights.se|access-date=2019-11-06}}</ref> Caustics can be implemented in 3D graphics by blending a caustic [[Texture mapping|texture map]] with the texture map of the affected objects.<ref name=":15" /> The caustics texture can either be a static image that is animated to mimic the effects of caustics, or a [[Real-time computing|Real-time]] calculation of caustics onto a blank image.<ref name=":15" /> The latter is more complicated and requires backwards [[Ray tracing (graphics)|ray tracing]] to simulate photons moving through the environment of the 3D render.<ref name=":14" /> In a photon mapping illumination model, [[Monte Carlo sampling|Monte Carlo]] sampling is used in conjunction with the ray tracing to compute the intensity of light caused by the caustics.<ref name=":14" />
 
=== Reflection mapping ===
Line 96 ⟶ 105:
 
== See also ==
*[[Per-pixel lighting]]
*[[Computer graphics]]
 
==References==
{{reflist}}
 
{{Computer graphics}}
{{DEFAULTSORT:Computer Graphics Lighting}}
[[Category:3D rendering]]
[[Category:Lighting| ]]
[[Category:Shading| ]]