Trang 4 How lights can be seen?■ The eye works like a camera■ Lots of photo sensors at the back of the eye■ Sensing the amount of light coming from different directions■ Similar to CMOS
Trang 1Lesson 10
Illuminiation and
shading
Trang 21 Overview
2 Illumination
3 Shading
Trang 3Overview
Trang 4How lights can be seen?
■ The eye works like a camera
■ Lots of photo sensors at the back of the eye
■ Sensing the amount of light coming from different directions
■ Similar to CMOS and CCDs
Information will be sent
to brain for processing
Trang 5What colour is this dress?
Trang 6Object’s colour
■ What Affects the Color of a Point on the Object?
□ position of the sample point
□ position of the light
□ color and intensity of the light
□ camera vector
□ normal vector of the surface at the vertex
□ physical characteristics of the object
(reflectance model, color)
Trang 7Colour’s illusion
Trang 8Lighting and shading
■ Lighting
□ How to compute the color of objects according to the position of the light, normal vector and camera position
■ Shading
□ Different methods to compute the color of the
entire surface
Trang 9Lighting
Trang 10Factors affecting lighting
Light source Surface properties
Trang 13in 3D space, we can specify a pixel correspondingly.
■ The task in lighting is that we have to specify the colour of that pixel
■ If we want to make the scene look *right*, we
have to simulate the lighting process on the surfaces
inside the scene
Trang 14Lighting models
■ Two types of lighting models
□ Empirical: Use simple formulas to create similar
observable result
□ Physics simulation: The lighting formulas will be based on physics formulas in lighting
■ In most cases, experimental models will be used
in interactive computer graphics applications
■ In modern computer graphics applications,
some physic simulation models have been more frequently used
Trang 15Phong lighting model
■ By Bui Tuong Phong (Utah University) is a lighting model which is a combination of both experimental and physics simulation
■ Is the sum of 3 illumination terms
□ Ambient : 'background' illumination
□ Diffuse : non-shiny illumination and shadows
□ Specular : bright, shiny reflections
Trang 16Ambient light
Trang 17Ambient light
■ Light from the environment
■ Light reflected or scattered from other objects
■ Coming uniformly from all directions and then reflected equally to all directions
■ A precise simulation of such effects requires a lot of computation
➢Use a simple “trick” called ambient light
Trang 21Example: Ambient light
Trang 22What about this?
Trang 23Diffuse light
Trang 24Diffuse light
■ When light hits an object
□ If the object has a rough surface, it is reflected to
various directions
□ Result: Light reflected to all directions
What are the factors affecting diffuse light intensity?
Trang 25Diffuse light
■ The smaller the angle between the incident
vector and the normal vector, the higher the chance that the light is reflected back
■ When the angle is larger, the reflection light gets weaker because the chance the light is shadowed / masked increases
Trang 26Lambert’s Cosine Law
“The radiant intensity or luminous intensity observed from an ideal diffusely reflecting surface or ideal diffuse radiator
is directly proportional to the cosine of the angle θ between the direction of the incident light and the surface normal”
n l
Trang 27Example: Diffuse Light
■ Not depend on viewing direction
■ Only depend on the angle between light source and surface normal
Trang 28Diffuse light
I = k d I p cos
■ Ip: diffuse reflectivity
■ : the angle between the normal vector
direction towards the light
■ kd: Light Intensity
E.g sphere (light from the left) Does NOT depend on camera’s position
Trang 29Specular light
Trang 30Specular reflection
■ Direct reflections of light source off shiny object
□ The object has a very smooth surface
□ E.g gloss metal, car surface
Specular Highlight
Trang 31Specular reflection
■ Reason: In microscope level, the surface of
specular surface is very smooth, therefore the
specular reflection is similar to reflection on mirror
■ The smoother the surface, the more it looks like
a mirror
■ Following Snell’s law
l = r
Trang 32Specular reflection
■ For *less than ideal* surface
□ Instead of having to model the microscopic level of the surface to handle conventional reflection
□ When the light touches the surface, some of the light will be reflected in a slightly different direction than the ideal ray.
□ Higher the angle of deviation from the ideal
reflector, the less light reflected
Trang 33Specular highlight
■ specular intensity n = shiny reflectance of object
■ Result: specular highlight on object
□ This is an empirical calculation and isn’t based on
any physics formula
( )n shiny
p
sI k
E.g a sphere
Does NOT depend on surface’s colour
Trang 34Changing the n-shiny
■ Reflection with different nshiny value
Trang 35Phong lighting model
Trang 36Phong lighting model
■ By Bui Tuong Phong (Utah University) is a lighting model which is a combination of both experimental and physics simulation
■ Is the sum of 3 illumination terms
□ Ambient : 'background' illumination
□ Diffuse : non-shiny illumination and shadows
□ Specular : bright, shiny reflections
Trang 37Phong lighting model
■ Resulting intensity will be calculated by the sum of all terms
𝐼 = 𝐼𝑎𝑘𝑎 + 𝐼𝑝 𝑘𝑑 cos 𝜃 + 𝑘𝑠 cos𝑛 𝜑
■ If there are many light sources
□ Calculate the sum of all light intensity
𝑝 𝑙𝑖𝑔ℎ𝑡𝑠
𝐼𝑝 𝑘𝑑 cos 𝜃 + 𝑘𝑠 cos𝑛 𝜑
Trang 38Phong lighting model
■ We can also use dot product
□ V: Vector from the surface to the viewer
□ N: Normal vector at the colored point
□ R: Normalized reflection vector
□ L: Normalized vector from the colored
point towards the light source
d p
a a
shinyR
V k L
N k
I I
k
I
1
ˆ ˆ ˆ
ˆ
Trang 39Shading
Trang 40■ The illumination model computes the color of sample points
■ How do we color of the entire object?
➢ This is done at the rasterization level
■ The procedure to color the entire surface is
called shading
Trang 41Flat shading
■ Compute the color at the middle of the polygon
■ All points in the same polygon are colored by the same color
■ Works well for objects really made of flat faces
Trang 42Example scene: Flat shading
Trang 43Flat shading: Problem
■ Suffers from Mach band effect
□ Humans are very sensitive to the sudden change of the brightness
■ The artefact remains although the polygon
number is increased
Trang 45Example scene: Goraud shading
Trang 46Goraud shading: Problem
■ For specular
reflection, highlight falls
off with cosnα
may well miss a
highlight that occurs in
the middle of the face
Trang 47Phong shading
■ by Bui Tuong Phong
■ Doing the lighting computation at every pixel during rasterization
■ Interpolating the normal vectors at the vertices (again using barycentric coordinates)
Trang 48Phong shading process
1 For every vertex of the object, compute its
normal vector
2 Project the vertices onto the screen
3 When rasterizing the pixels, interpolate the
normal vector, position of the point (and the light and camera vector if necessary) using barycentric coordinates, and do the lighting computation
Trang 49Example scene: Goraud shading
Trang 50Comparison between shading techniques
Trang 51Any questions?
Trang 52Lecture notes provided by School of Information and
Communication Technology, Hanoi University of Science and
Technology.
Composed by Huynh Quyet Thang, Le Tan Hung, Trinh Thanh
Trung and others
Edited by Trinh Thanh Trung
Special thanks to all the people who made and released these awesome resources for free:
■ Presentation template by SlidesCarnival
■ Photographs by Death to the Stock Photo ( license )
■ Diverse device hand photos by Facebook Design Resources