From Graphics to Visualization
Introduction Light Sources
Surface Lighting Effects
Basic (Local ) Illumination Models Polygon-Rendering Methods
Texture Mapping
Transparency and Blending Visualization Pipeline
outline
Introduction
• Illumination Model (Lighting/Shading Model)
Calculation of color on an illuminated position on the surface of an object
• Surface Rendering
A procedure for applying a lighting model to
obtain pixels colors for all projected surface
positions
• Point Source
Diverging ray paths from a point light source
Light Sources
Light Sources
• Distributed Light Source
Light rays from an infinitely distant light source illuminate an object along nearly parallel light paths
Surface Lighting Effects
Diffusereflections from
a surface (dull/roughsurface) (shinysurface) Specular reflection superimposed on diffuse reflection vectors
(Global Illumination) Surface lighting effects are produced by a combination of illumination
from light sources and reflection from other surfaces.
Rendering methods differ in approximating lighting effects
• Global illumination: ray tracing, accurate by computationally expensive
• Local illumination: relate the illumination of a given scene point directly to the light set, not to any other scene points If we denote the angle of incidence between the incoming Light direction and the surface
Illumination Models
1) Ambient Light
2) Diffuse Reflection
If we denote the angle of incidence between the incoming Light direction and the surface normal as θ
a a ambdif f k I
I
Angle of incidence θ between the unit light- source direction vector L and the unit normal vector N at a surface position.
Basic (Local )Illumination
Models
Basic (Local )Illumination Models
2) Diffuse Reflection
I
I,diff=K
dI
lcos θ I
I,diff=K
dI
l(N‧L)
kd:
diffuse-reflection coefficient, or diffuse reflectivity.
◆ Lambertian reflectors
◆ Lambert’s cosine law
– Total Diffuse-reflection of a single point-source illumination
0 L
N if
,
0 L
N if ), (
a a
l d a
a
diff
k I
L N I k I
I k
Basic (Local )Illumination Models
3) Specular Reflection and Phong Model
– Phong Specular-Reflection Model (Phong Model)
l nsspec
l
W I
I
,( ) cos
Specular reflection angle equals angle of incidence θ
0 L N or 0 R V if
, 0 . 0
0 L N and 0 R V if , ) (
,
ns
l s spec
l
R V I I k
(2-4) (2-5)
Basic (Local )Illumination Models
3) Specular Reflection and Phong Model
Modeling specular reflections (shaded area) with parameter ns
The projection of either
L or R onto the direction of the normal vector N has a magnitude equal to N˙L.
L N
L N
R ( 2 )
3) Specular Reflection and Phong Model
Specular reflections from a spherical surface for varying specular parameter values and a single light source
Basic (Local )Illumination
Models
3) Specular Reflection and Phong Model
Halfway vector H along the bisector of the angle between L and V.
|
| L V V H L
Basic (Local )Illumination
Models
Color Intensity Calculations
• Phong Algorithm:
I = I
a+ I
d+ I
sI
a:ambient reflection I
d: diffuse reflection I
s: specular reflection I
a=k
aI
eI
d=k
dI
lcosα here cosα =(L‧N) I
s=k
sI
lcos
mβ here cosβ=(R‧V)
• Multiple light sources:
P
L
R N
α α β V
ni i
s d
a
r C
I I I
I
i i1
ri i
Here riis the distance to the light i and C is a constant
Il
L, N, R, V are vectors
Shading
• Technique To Render Solid Surfaces
• Determines How Surfaces Will Be Filled
• Process for Computing the Color Intensity Value for Each Pixel Contained in a Polygon
• The Most Common Shading Techniques Are:
– Flat Shading glShadeModel (GL_FLAT);
– Gouraud Shading glShadeModel (GL_SMOOTH);
– Phong Shading (OpenGL by default doesn't do phong shading )
Shading Techniques
Flat Shading
Gouraud Shading Phong Shading
No Shading
Flat Shading
Flat Shading
• Constant Shading Or Flat Shading
• The Simplest and Cheapest and Therefore Fastest Shading Method
• Filling An Entire Polygon with One Color Intensity
• This Model is Only Valid (Realistic) If:
– The light source is imagined to be at infinity – The viewer is at infinity
– The polygon is not an approximation to a curved surface
Gouraud Shading
Gouraud Shading
• Also called Smooth shading
• Color Interpolation Algorithm
– Interpolation along polygon edges – Interpolation across polygon surfaces
Color Values Given On A Per Vertex Basis
Interpolation Along The Edges
Interpolation Across The Surface
V1 V2
V3
Gouraud Shading Illustration
I
1( x
1, y
1)
I
2( , x y
2 2)
I
3( , x y
3 3)
I
aI
b
I
s
I
a y y I y
sy I y y
s 1
1 2
1
(
2)
2(
1)
I
b y y I y
sy I y y
s 1
1 3
1
(
3)
3(
1)
I
sx x I x x I x x
b a
a b s b s a
1
( ) ( )
y
sI
a j, 1 I
a j, I
aI
b j, 1 I
b j, I
bI
i1,s I
i s, I
sI
a y y I I
1
1 2
1 2
( ) I
y y I I
b
1
1 3
1 3
( ) I
x x I I
s
b a
b a
1
( )
1
j
y
sPhong Shading
Phong Shading
• An Interpolation Process Similar To Gouraud Shading
• Interpolation Over Normal Vector Instead of Vertex Color
– Normal vectors tell about an objects orientation
– Surface orientation is important in respect to the position of
• The observer/viewer of a scene
• The source of lighting
• Creates greater realism than Gouraud shading
– Specially when combined with an illumination model
– Usually implemented through application software
– Very computing intense
Phong Shading Illustration
( , x y
2 2)
( , x y
3 3)
y
sN
1N
3N
2N
aN
sN
b1
1(
2)
2(
1)
2 1
s s
a
N y y N y y
y
N y
( ) ( )
1
1 3 3
1 3 1
s s
b
N y y N y y
y
N y
( ) ( )
1
a s
b s
b a a
b
s
N x x N x x
x
N x
)
,
( x
1y
1Fill-Area Primitives
• Fill (Filled) Area
-- An area filled with some solid color or a pattern
• Surface Tessellation
-- Approximating a curved surface with polygon facets (a
polygon mesh)
Texture Mapping
Texture Mapping
(a) Texture Image; (b) Texture-mapped object
Texture Mapping
Texture Image
Texture Mapping
Texture Mapping: Coordinates Transformations
Texture Mapping
Texture Mapping
Transparency and Blending
(a) as Background + (b) as Foreground
=> blended as (c) The Grid
The Gaussian Surface
Height plot of e
-(x^2+y^2)drawn
on top of the domain grid
Visualization Pipeline
float data[N_x,N_y]
Class Quad
) ( 2 2