Basic Lighting and Shading The Important Properties of
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 • Intensity is L(p, P 0) = (1 / |p-p 0|2 ) L(P 0) – Spotlights (Directional Lights)
Open. GL Light Types Point Spotlight Ambient Distant
Point home. elka. pw. edu. pl/. . . /general/General. html
Spot home. elka. pw. edu. pl/. . . /general/General. html
Ambient (Area) home. elka. pw. edu. pl/. . . /general/General. html
Distant (Sun / Moon) home. elka. pw. edu. pl/. . . /general/General. html
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
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
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-PV http: //www. atmos. ucla. edu/~fovell/AS 3/theory_of_color. html
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.
• 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/p rojects/micro_rs/theory. html
Using Basic Lighting in Open. GL http: //www. cs. virginia. edu/~gfx/Courses/2002/Real. Time. fall. 02/Cg/CG%20 Effects%20 Explai ned/Cg%20 Effects%20 Explained. htm
Enabling Lighting Enable Lighting in Open. GL gl. Enable(GL_LIGHTING) Enable Each Individual Light gl. Enable(GL_LIGHTi) i <= GL_MAX_LIGHTS All implementations support at least 8 lights
The 3 Functions to set you lights • gl. Lightfv(…) • gl. Lightf(…) • gl. Light. Modelfv(…)
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/j oomla/forum/files/specular_mat erial_test_01_168. jpg
Diffuse Reflection (Lambertian reflection) http: //torcode. com/ http: //www. glenspectra. co. uk/Site. Resources/Data/Templates/1 product. asp? Doc. ID=389&v 1 ID=
Emissive • It Glows! http: //www. gennetten-concreteartist. com/dnetwork. html
Translucent Surfaces http: //www. trinity 3 d. com/product. p hp? productid=1572&cat=293&page= 2 http: //www. nondot. org/sabre/Proje cts/Raytracer/
The End (for now)
- Slides: 21