basic lighting and shading
DESCRIPTION
Basic Lighting and Shading. The Important Properties of Light. It can Reflect, bend, spread and scatter. Most Common Light Sources. Global Illumination Light Located at Infinity (Distant Light) Light Located Locally Uniform Light (Ambient) Point Source - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/1.jpg)
Basic Lighting and Shading
![Page 2: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/2.jpg)
The Important Properties of Light
• It can Reflect, bend, spread and scatter
![Page 3: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/3.jpg)
Most Common Light Sources
• Global Illumination• Light Located at Infinity (Distant Light)• Light Located Locally– Uniform Light (Ambient)– Point Source • Intensity is L(p,P0) = (1 / |p-p0|2 ) L(P0)
– Spotlights (Directional Lights)
![Page 4: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/4.jpg)
OpenGL Light Types
PointSpotlightAmbientDistant
![Page 5: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/5.jpg)
Point
home.elka.pw.edu.pl/.../general/General.html
![Page 6: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/6.jpg)
Spot
home.elka.pw.edu.pl/.../general/General.html
![Page 7: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/7.jpg)
Ambient (Area)
home.elka.pw.edu.pl/.../general/General.html
![Page 8: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/8.jpg)
Distant (Sun / Moon)
home.elka.pw.edu.pl/.../general/General.html
![Page 9: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/9.jpg)
Physical Light
Bidirectional Reflection Distribution Function– (BRDF)
This is based on 5 Variables:– Frequency– Source Vector (x,y)– Output Vector (x,y)
• It also requires a ‘real’ surface
![Page 10: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/10.jpg)
This is a hugely expensive calculation
• Most light consists of a large frequency Range
• In games we have many fast ways of creating the effects of light
![Page 11: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/11.jpg)
Firslty we need to get rid of the ‘spectrum’
• The human Eye recognises colours through 3 types of cones– We can exploit this behaviour by directly
addressing the cones
http://www.unenergy.org/index.php?p=1_180_CPV---Concentrated-PVhttp://www.atmos.ucla.edu/~fovell/AS3/theory_of_color.html
![Page 12: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/12.jpg)
By exploiting this behaviour we can define the colour of light as
• RGB• Varying the levels of Red, Green and Blue can
make the eye ‘see’ every colour of the spectrum.
![Page 13: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/13.jpg)
• The downside to this simplification is that our model of light looses the ability to separate during reflections/refractions.
• As a solution to this we can either use multiple lights, or use explicit functions to ‘create’ light separation
• For offline rendering you may even consider doing a BRDF Rendering using a more complex Lighting method
http://www.tufts.edu/as/tampl/projects/micro_rs/theory.html
![Page 14: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/14.jpg)
Using Basic Lighting in OpenGL
http://www.cs.virginia.edu/~gfx/Courses/2002/RealTime.fall.02/Cg/CG%20Effects%20Explained/Cg%20Effects%20Explained.htm
![Page 15: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/15.jpg)
Enabling Lighting
Enable Lighting in OpenGLglEnable(GL_LIGHTING)
Enable Each Individual LightglEnable(GL_LIGHTi)i <= GL_MAX_LIGHTS
All implementations support at least 8 lights
![Page 16: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/16.jpg)
The 3 Functions to set you lights
• glLightfv(…)• glLightf(…)• glLightModelfv(…)
![Page 17: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/17.jpg)
Specular Reflection
• Specular– The more specular a surface, the move light is
reflected very closely to the angle of reflection– A mirror is a near perfect Specular Surface
http://www.indigorenderer.com/joomla/forum/files/specular_material_test_01_168.jpg
![Page 18: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/18.jpg)
Diffuse Reflection(Lambertian reflection)
http://torcode.com/http://www.glenspectra.co.uk/SiteResources/Data/Templates/1product.asp?DocID=389&v1ID=
![Page 19: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/19.jpg)
Emissive
• It Glows!
http://www.gennetten-concreteartist.com/d-network.html
![Page 20: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/20.jpg)
Translucent Surfaces
http://www.trinity3d.com/product.php?productid=1572&cat=293&page=2http://www.nondot.org/sabre/Projects/Raytracer/
![Page 21: Basic Lighting and Shading](https://reader035.vdocuments.site/reader035/viewer/2022062323/568161c5550346895dd1aba4/html5/thumbnails/21.jpg)
The End (for now)