taku komuracomputer graphics local illumination and shading computer graphics – lecture 10 taku...
Post on 03-Jan-2016
224 Views
Preview:
TRANSCRIPT
Taku Komura Computer Graphics
Local Illumination and Shading
Computer Graphics – Lecture 10
Taku Komuratkomura@inf.ed.ac.uk
Institute for Perception, Action & Behaviour
Taku Komura Computer Graphics
Last Lecture… Hidden Surface Removal
Back face culling Painter’s algorithm BSP Tree Z-buffer
Taku Komura Computer Graphics
Back Face CullingLight(L), view (V), and normal(N)
Cull faces according to L.N and V.N
Cull if V.N < 0
Cull if L.N > 0
(if only one light,
and no ambient light)
Taku Komura Computer Graphics
Today is about calculating the color of objects
The incident light • Position of light source• Direction • Color
The object • Reflectance
Viewer • Position
Taku Komura Computer Graphics
Overview Illumination (how to calculate the color) Shading (how to color the whole surface)? BRDF (how to simulate the reflection of real objects)
Taku Komura Computer Graphics
Illumination
Simple 3 parameter model The sum of 3 illumination terms:
• Ambient : 'background' illumination
• Specular : bright, shiny reflections
• Diffuse : non-shiny illumination and shadows
Object
Light source
(here point light source)
surface normal (specifies surface orientation)
'Virtual' camera
Taku Komura Computer Graphics
Ambient Lighting Light from the environment
light reflected or scattered from other objects
simple approximation to complex 'real-world' process
Result: globally uniform colour for object
— I = resulting intensity
— Ia = light intensity
— ka = reflectance
Object
Uniform Light source
a
a
k
I
ereflectanc
Intensity Light
I
aaIkI
N
camera
Example: sphere
Taku Komura Computer Graphics
Diffuse Lighting
• Also known as Lambertian reflection– considers the angle of incidence of light on surface
(angle between light and surface normal)
– Result: lighting varies over surface with orientation to light
Object
Infinite point light source
N
Ln
tyreflectivi diffuse:
)(cos
IntensityLight
d
n
p
k
LN
I
I
No dependence on camera angle!
Example: sphere(lit from left)
cosdpkII
Taku Komura Computer Graphics
Specular Lighting
• Direct reflections of light source off shiny object– specular intensity n = shiny
reflectance of object
– Result: specular highlight on object
Object
N
I = output colorR
n = camera position
α : angle between Rn and S
R (Reflection)
Infinite point light source
Ln
No dependence on object colour.
p Intensity Light Iα
nspkII )cos(
Taku Komura Computer Graphics
Combined Lighting Models
• Summing it altogether : Phong Illumination Model
+ + =
Ambient(colour)
Diffuse(directional)
Specular(highlights)
Rc
]coscos[ n
sdpaa kkIkII
Taku Komura Computer Graphics
When you implement it…
Use dot product of the vectors instead of calculating the angles
])()([1
nsd
lights
ppaa RVkLNkIkII
N
L
V
R
,
: Vector from the surface to the viewer
: Normal vector at the colored point
: Reflection vector
: Vector from the light source towards the colored point
Object
N
R
Ln
α
V
Taku Komura Computer Graphics
Color
• You do the above computation for Red, Green and Blue color
• Finally color the pixel by the RGB color
])()([1
nRs
Rd
lights
p
Rp
Ra
Ra
R RVkLNkIkII
])()([1
nGs
Gd
lights
p
Gp
Ga
Ga
G RVkLNkIkII
])()([1
nBs
Bd
lights
p
Bp
Ba
Ba
B RVkLNkIkII
Taku Komura Computer Graphics
Demo applets
http://www.cs.unc.edu/%7Eclark/courses/comp14-spr04/code/SphereLightApplet.html
http://www.cs.auckland.ac.nz/~richard/research-topics/PhongApplet/PhongDemoApplet.html
Taku Komura Computer Graphics
Overview Illumination (how to calculate the color) Shading (how to color the whole surface)?
Taku Komura Computer Graphics
How often do we do the computation of illumination?
At all the points on the surface?
But usually we have normals only at the vertices
Depends on the shading model
– Flat Shading (once per polygon)
(less computation needed)
– Gouraud shading (for all the vertices of the polygon)
– Phong Shading (all the points)
(heavy computation needed)
Taku Komura Computer Graphics
Compute the color at the middle of the polygon All points in the same polygon are colored by the
same color
Flat Shading
Taku Komura Computer Graphics
Compute the color at each vertex first Compute the color inside the polygon by
interpolating the colors of the vertices composing the polygon
Gouraud Shading (Smooth Shading)
Taku Komura Computer Graphics
interpolating the normal vectors at the vertices Do the computation of illumination at each point in
the polygon
Phong Shading
Taku Komura Computer Graphics
Gouraud Shaded Floor Phong Shaded Floor
Gouraud shading is not good when the polygon count is low
Taku Komura Computer Graphics
interpolating the normal vectors at the vertices Do the computation of illumination at each point in
the polygon
Phong Shading
Taku Komura Computer Graphics
Problems with interpolation shading.
Problems with computing vertex normals.
A,B are shared by all polygons, but C is not shared by the polygon on the left.
-Shading information calculated to the right of C will be different from that to the left.
- Shading discontinuity.
Solution : ?
A
B
C
Taku Komura Computer Graphics
Problems with interpolation shading.
Problems with computing vertex normals.
Face surface normals and averaged vertex normals shown.
Solution:?
Taku Komura Computer Graphics
Exercise Draw a picture by Phong Shading by enhancing the
demo program I put up on the web. When doing the rasterization, you do the
computation of the illumination
Taku Komura Computer Graphics
Overview Illumination (how to calculate the color) Shading (how to color the whole surface)? BRDF (how to simulate the reflection of real objects)
Taku Komura Computer Graphics
What about real objects?
Phong Illumination model is popular but actually it is not accurate
True photorealism, requires more sophisticated and elaborate models of surface properties
Taku Komura Computer Graphics
Reflectance of objects
The way the light reflects depends on the physical characteristics of the surface
Its not uniform
Taku Komura Computer Graphics
Bidirectional Reflectance Distribution Function (BRDF)
The reflectance of an object can be represented by a function of the incident and reflected angles
This function is called the Bidirectional Reflectance Distribution Function (BRDF)
where E is the incoming irradiance and L is the reflected radiance
Taku Komura Computer Graphics
What affects the BRDF?
The way light reflecting over the surface The smoothness/roughness of the surface
Single reflection : if smooth, specular Multiple reflections : diffusive
The shadowing effect
Taku Komura Computer Graphics
Isotropic and Anisotropic BRDFs
Isotropic:
Can model by diffuse + specular reflection
Anisotripic
Brushed metal
Cannot model by diffuse + specular reflection
Taku Komura Computer Graphics
How to get the BRDF?
Measure Data
Use Analytical models Empirical models
Microfacet
Taku Komura Computer Graphics
Measuring the BRDF
Measured using a device called gonioreflectometer Casting light from various directions to the object, and
capturing the light reflected back
Taku Komura Computer Graphics
Problems with Measured BRDF
Includes a lot of error
Huge amount of time to capture
The data size is enormous 18 hours acquisition time, 30GB raw data Ngan et al. EGSR ’05
-> Fitting the acquired data into analytical models
Taku Komura Computer Graphics
Analytical models
Empirical models
Gouraud, Phong models or more complex models
Microfacet models
Assuming the surface is composed of a large number of micro mirrors
Each reflect light back to the specular direction
Taku Komura Computer Graphics
Microfacet Theory [Torrance & Sparrow 1967]
Surface modeled by tiny mirrors Value of BRDF at
— # of mirrors oriented halfway between and
where is the incoming direction, is the out going direction
— Modulated by Fresnel, shadowing/masking
[Shirley 97]
top related