LIGHTING JEFF CHASTINE 1. WHAT IS LIGHT? A very complex process Find a dark area – how is it being...
-
Upload
marcus-beverly-quinn -
Category
Documents
-
view
216 -
download
1
Transcript of LIGHTING JEFF CHASTINE 1. WHAT IS LIGHT? A very complex process Find a dark area – how is it being...
JEFF CHASTINE
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?
P2
P0
P1
Directional light - position doesn’t matter- triangle is almost fully lit
𝑁
JEFF CHASTINE 4
A BASIC LIGHTING CONCEPT• How can we determine how much light should be cast onto a triangle from a directional
light?
P2
P0
P1
(Triangle less lit)𝑁
JEFF CHASTINE 5
A BASIC LIGHTING CONCEPT• How can we determine how much light should be cast onto a triangle from a directional
light?
P2
P0
P1
(Little to no light hits the surface)
𝑁
JEFF CHASTINE 6
A BASIC LIGHTING CONCEPT• How can we determine how much light should be cast onto a triangle from a directional
light?
P2
P0
P1
(Directional light)𝑁
JEFF CHASTINE 7
A BASIC LIGHTING CONCEPT• How can we determine how much light should be cast onto a triangle from a directional
light?
P2
P0
P1
(Directional light)𝑁
𝐿
JEFF CHASTINE 8
A BASIC LIGHTING CONCEPT• How can we determine how much light should be cast onto a triangle from a directional
light?
P2
P0
P1
(Directional light)𝑁
𝐿
Lesson learned: Lighting depends on angles between vectors!
JEFF CHASTINE 9
A BASIC LIGHTING CONCEPT• How can we determine how much light should be cast onto a triangle from a directional
light?
P2
P0
P1
(Directional light)𝑁
𝐿
intensity=acos (𝑁 ∙𝐿)
Assuming N and L are normalized, and N∙L isn’t negative
JEFF CHASTINE 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 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 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 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 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 (cd and ld)
• Specular color (cs and ls)
• Ambient color (ca and la)
• Emit color (ce and le)
• cd * ld=[cd.r*ld.r,cd.g*ld.g,cd.b*ld.b] // R, G, B
JEFF CHASTINE 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 16
LAMBERTIAN REFLECTANCE(DIFFUSE COMPONENT)
• Light falling on an object is the same regardless of the observer’s viewpoint
• Good for rough surfaces without specular highlights
• where and are normalized
l n
θ
JEFF CHASTINE 17
LAMBERTIAN REFLECTANCE(DIFFUSE COMPONENT)
• Light falling on an object is the same regardless of the observer’s viewpoint
• Good for rough surfaces without specular highlights
• where and are normalized
l n
θ
Note: final_colordiffuse has R, G, B
scalar 3 parts (R, G, B)
JEFF CHASTINE 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 20
BLINN-PHONG REFLECTION(SPECULAR COMPONENT)
• - which is really Blinn’s contribution to the original Phong model
l
n
r
θ θ
v
h
Note: vectors should be normalized
JEFF CHASTINE 21
BLINN-PHONG REFLECTION(SPECULAR COMPONENT)
• Our final specular equation is:
l
n
r
θ θ
v
h
JEFF CHASTINE 22
DETERMINING • Realize that will always be < 1.0, so raising it to a power will make it smaller
• is the “shininess” factor
• It relates to the size of the specular highlight
s= ~1 s= ~30 s= ~255
𝑓𝑖𝑛𝑎𝑙𝑐𝑜𝑙𝑜𝑟 𝑠=(𝑛 ∙ h)𝑠∗𝑐𝑠∗𝑙𝑠
JEFF CHASTINE 23
AMBIENT AND EMIT COMPONENTS• Ambient:
• Used to simulate light bouncing around the environment (global illumination)
• Real world is far too complex for real time, so just add a little light!
• Emit:
• Used to make the object “glow”
• Does not emit light!!!
• Both:
• Independent of viewpoint
• Super easy to calculate
JEFF CHASTINE 24
FINAL COLOR• To determine the final color (excluding textures) we sum up all components:
http://en.wikipedia.org/wiki/Phong_reflection_model
final_colordiffusefinal_colorspecularfinal_colorambientfinal_coloremit
final_color
+
JEFF CHASTINE 25
WHAT ABOUT MULTIPLE LIGHTS?• Calculate final colors and sum them all together
• Assuming results are in f[ ] and there are count number of lights
JEFF CHASTINE 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 27
POINT LIGHTS• These lights have a position in 3D space
• Sometimes called a “Lamp”
• Light emanates from the light in all directions
• Distance d determines brightness (“attenuation”):
Here, per fragment lighting used
JEFF CHASTINE 28
POINT LIGHTS• These lights have a position in 3D space
• Sometimes called a “Lamp”
• Light emanates from the light in all directions
• Distance d determines brightness (“attenuation”):
Here, per vertex lighting used
JEFF CHASTINE 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 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 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