Download presentation
Presentation is loading. Please wait.
Published byDavid Flynn Modified over 8 years ago
1
1 Dr. Scott Schaefer Lighting
2
2/49 Lighting/Illumination Color is a function of how light reflects from surfaces to the eye Global illumination accounts for light from all sources as it is transmitted throughout the environment Local illumination only accounts for light that directly hits a surface and is transmitted to the eye
3
3/49 Global Illumination Image taken from http://graphics.ucsd.edu/~henrik/images/cbox.html
4
4/49 Reflection Models Definition: Reflection is the process by which light incident on a surface interacts with the surface such that it leaves on the incident side without change in frequency.
5
5/49 Types of Reflection Functions Ideal Specular Reflection Law Mirror Ideal Diffuse Lambert’s Law Matte Specular Glossy Directional diffuse
6
6/49 Illumination Model Ambient Light Uniform light caused by secondary reflections Diffuse Light Light scattered equally in all directions Specular Light Highlights on shiny surfaces
7
7/49 Ambient Light A =intensity of ambient light k a =ambient reflection coefficient Really 3 equations! (Red, Green, Blue) Accounts for indirect illumination Determines color of shadows
8
8/49 Total Illumination
9
9/49 Diffuse Light Assumes that light is reflected equally in all directions Handles both local and infinite light sources Infinite distance: L doesn’t change Finite distance: must calculate L for each point on surface Surface
10
10/49 Diffuse Light C = intensity of point light source k d = diffuse reflection coefficient = angle between normal and direction to light Surface
11
11/49 Lambert’s Law Surface Beam of Light
12
12/49 Lambert’s Law Surface Beam of Light
13
13/49 Lambert’s Law Surface Beam of Light
14
14/49 Total Illumination
15
15/49 Total Illumination
16
16/49 Specular Light Perfect, mirror-like reflection of light from surface Forms highlights on shiny objects (metal, plastic) Surface
17
17/49 Specular Light C =intensity of point light source k s =specular reflection coefficient =angle between reflected vector (R) and eye (E) n =specular exponent Surface
18
18/49 Finding the Reflected Vector Surface
19
19/49 Finding the Reflected Vector Surface
20
20/49 Finding the Reflected Vector Surface
21
21/49 Finding the Reflected Vector Surface
22
22/49 Finding the Reflected Vector Surface
23
23/49 Total Illumination
24
24/49 Total Illumination
25
25/49 Total Illumination
26
26/49 Total Illumination
27
27/49 Multiple Light Sources Only one ambient term no matter how many lights Light is additive; add contribution of multiple lights (diffuse/specular components)
28
28/49 Total Illumination
29
29/49 Total Illumination
30
30/49 Attenuation Decrease intensity with distance from light d = distance to light r = radius of attenuation for light
31
31/49 Attenuation
32
32/49 Attenuation
33
33/49 Spot Lights Eliminate light contribution outside of a cone Surface
34
34/49 Spot Lights Eliminate light contribution outside of a cone Surface
35
35/49 Spot Lights
36
36/49 Spot Lights
37
37/49 Spot Lights
38
38/49 Implementation Considerations Surface
39
39/49 Implementation Considerations Two options: 2-sided: negate for back-facing polygons 1-sided: if, // light on back of surface else Surface
40
40/49 Implementation Considerations Typically choose Clamp each color component to [0,1]
41
41/49 OpenGL and Lighting Specify normals for geometry Create/position lights Specify material properties Select lighting model
42
42/49 OpenGL and Lighting Specify normals for geometry Create/position lights Specify material properties Select lighting model
43
43/49 OpenGL and Lighting glBegin(GL_TRIANGLES); … glNormal3f(nx,ny,nz); glVertex3f(x,y,z); … glEnd();
44
44/49 OpenGL and Lighting Specify normals for geometry Create/position lights Specify material properties Select lighting model
45
45/49 OpenGL and Lighting float light_position[] = {0, -10, 0, 1}; float light_ambient[] = {.1,.1,.1, 1}; float light_diffuse[] = {.9,.9,.9, 1}; float light_specular[] = {1, 1, 1, 1}; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING);
46
46/49 OpenGL and Lighting Specify normals for geometry Create/position lights Specify material properties Select lighting model
47
47/49 OpenGL and Lighting float mat_ambient[] = {1, 0, 0, 1}; float mat_diffuse[] = {1, 0, 0, 1}; float mat_specular[] = {1, 1, 1, 1}; float mat_shiny[] = {50}; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shiny);
48
48/49 OpenGL and Lighting Specify normals for geometry Create/position lights Specify material properties Select lighting model
49
49/49 OpenGL and Lighting glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.