Download presentation
Presentation is loading. Please wait.
Published byMarcus Beverly Quinn Modified over 9 years ago
1
LIGHTING JEFF CHASTINE 1
2
WHAT IS LIGHT? A very complex process Find a dark area – how is it being lit? Light bounces (mirrors, shiny objects) Light refracts through other media (water, heat) Light comes from everywhere (Global Illumination) Light bounces off of lakes in weird ways (Fresnel effect) THUS We’re forced to make approximations Tradeoff between time and realism “If it looks good, it is good” – Michael Abrash http://darrentakenaga.com/3d.html http://en.wikipedia.org/wiki/File:Global_illumination.JPG JEFF CHASTINE
3
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 Directional light - position doesn’t matter - triangle is almost fully lit JEFF CHASTINE 3
4
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 (Triangle less lit) JEFF CHASTINE 4
5
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 (Little to no light hits the surface) JEFF CHASTINE 5
6
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 (Directional light) JEFF CHASTINE 6
7
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 (Directional light) JEFF CHASTINE 7
8
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 (Directional light) Lesson learned: Lighting depends on angles between vectors! JEFF CHASTINE 8
9
A BASIC LIGHTING CONCEPT How can we determine how much light should be cast onto a triangle from a directional light? P2P2 P0P0 P1P1 (Directional light) Assuming N and L are normalized, and N∙L isn’t negative JEFF CHASTINE 9
10
BASIC LIGHTING Four independent components: Diffuse – the way light “falls off” of an object Specular – the “shininess” of the object Ambient – a minimum amount of light used to simulate “global illumination” Emit – a “glowing” effect Only diffuse JEFF CHASTINE 10
11
BASIC LIGHTING Four independent components: Diffuse – the way light “falls off” of an object Specular – the “shininess” of the object Ambient – a minimum amount of light used to simulate “global illumination” Emit – a “glowing” effect Diffuse+Specular JEFF CHASTINE 11
12
BASIC LIGHTING Four independent components: Diffuse – the way light “falls off” of an object Specular – the “shininess” of the object Ambient – a minimum amount of light used to simulate “global illumination” Emit – a “glowing” effect Ambient Diffuse+Specular+Ambient JEFF CHASTINE 12
13
BASIC LIGHTING Four independent components: Diffuse – the way light “falls off” of an object Specular – the “shininess” of the object Ambient – a minimum amount of light used to simulate “global illumination” Emit – a “glowing” effect D+S+A+Emit Note: emit does not produce light! JEFF CHASTINE 13
14
INTERACTION BETWEEN MATERIAL AND LIGHTS Final color of an object is comprised of many things: The base object color (called a “material”) The light color Example: a purple light on a white surface Any textures we apply (later) Materials and lights have four individual components Diffuse color ( c d and l d ) Specular color ( c s and l s ) Ambient color ( c a and l a ) Emit color ( c e and l e ) c d * l d = [c d.r *l d.r, c d.g *l d.g, c d.b *l d.b ] // R, G, B JEFF CHASTINE 14
15
GENERAL LIGHTING Primary vectors l – the incoming light vector n – the normal of the plane/vertex r – the reflection vector v – the viewpoint (camera) l n r θθ v JEFF CHASTINE 15
16
LAMBERTIAN REFLECTANCE (DIFFUSE COMPONENT) l n θ JEFF CHASTINE 16
17
LAMBERTIAN REFLECTANCE (DIFFUSE COMPONENT) l n θ Note: final_color diffuse has R, G, B scalar 3 parts (R, G, B) JEFF CHASTINE 17
18
LAMBERTIAN REFLECTANCE (DIFFUSE COMPONENT) l n θ JEFF CHASTINE 18
19
BLINN-PHONG REFLECTION (SPECULAR COMPONENT) Describes the specular highlight and is dependent on viewpoint v Also describes a “half-vector” h that is halfway between v and l l n r θθ v h JEFF CHASTINE 19
20
BLINN-PHONG REFLECTION (SPECULAR COMPONENT) l n r θθ v h Note: vectors should be normalized JEFF CHASTINE 20
21
BLINN-PHONG REFLECTION (SPECULAR COMPONENT) l n r θθ v h JEFF CHASTINE 21
22
s = ~1 s = ~30 s = ~255 JEFF CHASTINE 22
23
AMBIENT AND EMIT COMPONENTS JEFF CHASTINE 23
24
FINAL COLOR To determine the final color (excluding textures) we sum up all components: http://en.wikipedia.org/wiki/Phong_reflection_model final_color diffuse final_color specular final_color ambient final_color emit final_color + JEFF CHASTINE 24
25
WHAT ABOUT MULTIPLE LIGHTS? JEFF CHASTINE 25
26
COMMON KINDS OF LIGHTS Point light Directional Light Spot Light Area Light Interesting fact: Lights cannot be seen! Only their effects We can light per vertex (fast) or per fragment (slower) JEFF CHASTINE 26
27
POINT LIGHTS Here, per fragment lighting used JEFF CHASTINE 27
28
POINT LIGHTS Here, per vertex lighting used JEFF CHASTINE 28
29
DIRECTIONAL LIGHTS Are infinitely far away position in NO WAY matters Have only direction All objects are lit evenly Sometimes called a “Sun” JEFF CHASTINE 29
30
SPOTLIGHTS Point light source Conical in shape JEFF CHASTINE 30
31
SPOTLIGHTS Point light source Conical in shape Have: An inner and outer cone angle Umbra – areas that are fully in shadow Penumbra – areas that are in partial shadow Note: There’s an ambient light JEFF CHASTINE 31
32
AREA LIGHTS A “surface” lights objects Has a position and direction Provides for a smoother drop off than point Larger surface == smoother shadows Expensive to calculate JEFF CHASTINE 32
33
What you’ll see if you don’t glEnable(GL_LIGHTING) THE END!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.