10 - Illumination and Shading
10 - Illumination and Shading
Definitions Illumination
Fundamentally: Empirical illumination model
CG is about modelling the interaction of
electromagnetic energy within the objects of a
Tries to formulate approximations of
scene. observed phenomenon
What we see, is the light (electromagnetic energy Phong illumination model (OpenGL),
in the spectrum of visual light) that hits the eyes. Raytracing
Involves a number of things:
- Material properties Physically-based
Object position relative to lightsources and other objects
-
Models based on the actual physics of light
- Feature of light sources
interacting with matter
Radiosity, Photonmapping
5 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
6 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
1
Components Ambient Light Source
Light sources Simplification Due to reflections onto other objects, even object
Emitters of radiant energy Only direct illumination from that are not directly lit by a lightsource are visible
Geometric attributes the emitters to the reflectors
of the scene To model indirect illumination a hack called
- Position
- Direction Ignore Geometry of emitters Ambient light source is used
- Shape - No position nor direction.
Spectrum of emittance , - Constant for all surfaces in the scene
Color
- Can have colour
Directional attenuation
- Independent on objects orientation and position.
Surfaces
- Surface properties are used to determine how much
Reflecting spectrum (Color)
ambient light is reflected
Geometry (position,
orientation and micro
structure)
7 Absorption 8
Anders Backman Anders Backman
Computer Graphics and Visualization Department of Computing Science, Umeå University Computer Graphics and Visualization Department of Computing Science, Umeå University
- 1/d2 does not produce acceptal result The angular distance of the object
from the light can be used:
- The problem: real lightsources are not
infitesimal small! (point sources) Vobj • Vlight = cosα
2
Light sources Light sources
Angular Intensity Attenuation Area Light Sources
Spotlight
Occupies a 2D area
Attenuate the light intensity about
the cone axis vector. Generates soft shadows, WHY?
Highest intensity in center of cone
⎧
⎪ 1.0, If source is not a spotlight
⎪
f l , angatten =⎨ 0.0, If (Vobj • Vlight ) = cos α < cos θ l
⎪
⎪(Vobj • Vlight ) ,
al
⎩ otherwise
3
Diffuse
Computing Diffuse reflection reflection
Ideal diffuse surfaces We can model the amount of incident light on a surface with
a source with intensity Il such as:
Also called Lambertian reflectors
Idiffuse = I cos(θ) Error on
Reflected radiant light energy from any point on the surface
With a surface property to control the amount page 565
is calculated with Lamberts cosine law
of reflected diffuse light kd we have:
radiant energy per unit time ldiffuse = I kd cos(θ) Last
Intensity =
projected area Rember dot product, V1·V2=cos(θ), then we get: paragraph!
N
Idiffuse = I kd N·L,
θN where N and L must be normalized (have length 1)
θN INCOMING
LIGHT
Diffuse +
Diffuse reflection Ambient lighting
An illumination modelleling example only
considering diffuse reflection
As we only consider angles in the range of 0° to 90°.
Greater angles, where N·L is below zero, the light is
blocked by the surface and the reflected energy is 0
So adding the Ambient (background) and the Diffuse
lighting equation together results in:
⎧k I + k I ( N • L ) , if N • L>0
I l , diff + amb = ⎨ a a d l
⎩ ka I a , if N • L ≤ 0
4
Specular reflection Phong Bui Toung!
Snells law applies only to ideal
mirror reflectors. Real materials A model for approximating the non ideal reflection
deviates significantly from ideal is the Phong specular-reflection model where V is
reflectors. the unit vector in the direction of the viewer and R
In general, we expect most of the reflected light to is the mirror reflection direction.
travel in the direction of the ideal reflection
⎪⎧k I (V • R ) s , if V • R > 0 and N • L>0
n
direction. But due to microscopic variations in the Il , spec = ⎨ s l
reflector (surface) the some of the reflected light ⎪⎩ 0.0, if V • R < 0 or N • L ≤ 0
scatters in different directions.
As we as a viewer moves out from the reflection The reflection vector R can be calculated as:
(
R + L = 2( N • L ) N )
vector, we expect to see less light reflected.
ns=5 ns=30
27 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
28 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
∑ I ( k ( N • L ) + k (V • R ) )
Il ,diff + amb+ spec = ka I a +
nlights
ns Calculating the illumination model is costly,
i =1
l d s
including several normalizations of vectors.
5
Flat Shading Flat shading
Applying the illumination Introducing normals on the
calculation once per primitive surface
(quad, triangle, ...)
Used for back face culling etc..
Constant intensity surface
rendering (Hearn Baker) One normal for each primitive
is obviously not enough.
Issues:
Vertex normals can be
For point light sources, the calculated by averaging the
direction light varies over the
primitive. normals sharing that vertex.
For specular reflections the
direction to the eye varies k
ni
1 nv = ∑
numvertices
over the primitive. centroid = ∑ pi
numvertices i =1 ni
Illumination is usually i =1
calculated at the centroid of
the primitive.
6
Other effects Other effects
Transparent surfaces Transparent surfaces
An object with When light enters a transparent
Simple transparency equation: transparency kt surface, the direction of the light beam changes direction
I = (1-kt)Irefl+ktItransparency according to Snell’s law: nlsin(θl) = nrsin(θr)
Refraction index n depends on temperatur, and the wavelength
of the light. Therefore light can scatter into several rays of
different color (prisma!)
A For Air n=1, for water we have n=1.33, using those two refraction
Irefl index we can calculate the refraction direction.
If we follow the refraction ray and get the color information which
it contributes to the image, we could get something like:
The color of the
background behind
Itrans
object A
37 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
38 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
Is this all?
So we can land on the moon, thinking of going to
Mars, and the Phong illumination model is all we
can do?
No there are a lot more
One exampel is Cook-Torrance-Illumination