Documents
User Generated
Resources
Learning Center
Your Federal Quarterly Tax Payments are due April 15th

VIEWS: 9 PAGES: 38

• pg 1
```									Computer Animation, Modelling
and Visualisation

Lecture 10-

Prof. Abdennour El Rhalibi
a.elrhalibi@ljmu.ac.uk
Contents
•Today we will look at rendering methods
used in computer graphics
– Flat surface rendering - Lambert
– Gouraud surface rendering
– Phong surface rendering

2
• Calculating how a 3D object should look,
taking lighting into account
• Depends on:
– mesh data
• vertices, colors, textures, etc.
– lighting properties
• type of light, position of light, etc.

3
• A definition :
– a program used to determine the final surface
properties of an object or image
– this can include arbitrarily complex
descriptions of:
•   light absorption
•   light diffusion
•   texture mapping
•   reflection
•   refraction
•   surface displacement                       4
•   post-processing effects

– bump mapping (Blinn)
– and many more…            5
• A shading models where the light intensity is
calculated at one point along the polygon and is
used to shade the entire face. Also commonly
• Assigns a single color to a polygon
• Simple & fast
• Color based on:
– Material color
– the polygon's normal
– the position and intensity of a light source.

6
Flat Surface Rendering
•The simplest method for rendering a
polygon surface
•The same colour is assigned to all surface
positions
•The illumination at a single point on the
surface is calculated and used for the entire
surface
•Flat surface rendering is extremely
fast, but can be unrealistic
7
Limitations

•Just add lots and lots of polygons – however,
this is SLOW!                              8
No Surface Rendering Vs Flat
Surface Rendering

No Surface Rendering       Flat Surface Rendering
Color assigned to object   Color assigned to polygons
Like 2D

9
Gouraud Surface Rendering
Flat
was
developed in the 1970s by
Henri Gouraud
•Often also called intensity-
interpolation surface              Gouraud

rendering
•Intensity levels are calculated
at each vertex and
interpolated across the
surface                                      10
• How?
– computes vertex colors using normals & lighting
– interpolates vertex colors across a polygon's
surface
• done linearly:
• fast and resource-conscious
• used by default for e.g. in Direct3D
• Available as option in modeling tools (3DS
Max)

11
Gouraud Surface Rendering
(cont…)
•To render a polygon, Gouraud surface
rendering proceeds as follows:
1. Determine the average unit normal vector at
each vertex of the polygon
2. Apply an illumination model at each polygon
vertex to obtain the light intensity at that
position
3. Linearly interpolate the vertex intensities over
the projected area of the polygon
12
Gouraud Surface Rendering
(cont…)
•The average unit
N1        normal vector at v is
given as:
Nv                    N1  N 2  N 3  N 4
Nv 
v               N1  N 2  N 3  N 4
N4               N2
•or more generally:
n

N3                       N     i
Nv    i 1
n

N
i 1
i        13
Gouraud Surface Rendering
(cont…)
•Illumination values are linearly interpolated
across each scan-line
y
3         y4  y2      y1  y4
I4          I1          I2
y1  y2      y1  y2
1
Scan-line        y5  y 2      y3  y5
I5           I3          I2
4     p       5                    y3  y 2      y3  y2

x5  x p          x p  x4
Ip               I4               I5
2                          x5  x4           x5  x4
x                                  14
Rendering

15
Gouraud Surface Rendering
Example

16
Lambert          Gouraud
Gouraud Surface Rendering
Implementation
•Gouraud surfacing rendering can be
implemented relatively efficiently using an
iterative approach
as part of a visible surface detection
technique

17
Problems With Gouraud
tends to miss
certain highlighting
In particular Gouraud
problem with specular
reflections
can introduce anomalies known as Mach
bands                                   18
Mach Bands
A psychological phenomenon
whereby we see bright bands
where two blocks of solid
colour meet.

Mach bands are an optical
illusion consisting of an image of
two wide bands, one light and
one dark, separated by a narrow
The human eye perceives two
narrow bands of different
brightnesses either side of the
gradient that are not present in
the original image.

19
(cont…)

•The major problem with Gouraud shading is in
handling specular reflections

20
(cont…)

•Gouraud-shaded sphere - note the poor
behaviour of the specular highlight.
21
Flat Surface Rendering Vs
Gouraud Surface Rendering

Flat Surface Rendering   Gouraud Surface Rendering

22
• A more accurate interpolation based approach
for rendering a polygon was developed by
Phong Bui Tuong in 1973
• Basically the Phong surface rendering model (or
normal-vector interpolation rendering)
interpolates normal vectors instead of intensity
values
• It is a smooth shading technique
• approximates curved-surface lighting
• How?
– interpolates the vertex normals of a polygon across
the surface
• the lighting model includes glossy reflection with
a controllable level of gloss                     23
Phong Surface Rendering
(cont…)
•To render a polygon, Phong surface
rendering proceeds as follows:
1. Determine the average unit normal vector at
each vertex of the polygon
2. Linearly interpolate the vertex normals over
the projected area of the polygon
3. Apply an illumination model at positions along
scan lines to calculate pixel intensities using
the interpolated normal vectors
24
Phong Surface Rendering
(cont…)
N3
y4  y2      y1  y4
N1                                   N4          N1          N2
y1  y2      y1  y2
y5  y 2      y3  y 5
N5           N3           N2
N4
Np
y3  y 2      y3  y 2
Scan line
p                                    y p  y5          y4  y p
N5          Np                  N4                N5
y4  y5           y4  y5
N2
25
Phong Surface Rendering
Implementation
•Phong shading is much slower than
Gouraud shading as the lighting model is
revaluated so many times
•However, there are fast Phong surface
rendering approaches that can be
implemented iteratively
•Typically Phong shading is implemented as
part of a visible surface detection technique
26
Gouraud Surface Rendering Vs
Phong Surface Rendering

Gouraud Surface Rendering   Phong Surface Rendering

27

28

29
Bump Mapping
•   invented by Jim Blinn
•   an extension of Phong shading
•   simulates bumpy or wrinkled surfaces
•   How?
– at each pixel along a surface, slight changes are
– these changes are usually stored in a texture map

30
• technique of making computer generated
graphics appear to look hand drawn
• How?
– objects have black outlines (as though done
with pencil)
• done via inversing back-face culling with black
vertices & slight translation
– only a few shades of each color used for
objects
31

– From The Legend of Zelda: The Wind Talker 32
Different Effects using Different

Phong       Gouraud and Cell
33
• textures can be lit as well
• How?
– make polygon white & light normally
– when laying texture, calculate texel brightness
using polygon colors before texture
• We can exert further control over how
textures appear
– ex: texture blending

34
Rendering Pipeline
• Ordered operations involved in
transforming a scene to a screen
projection
• Rendering Options:
– Fixed-function pipeline
– Programmable pipeline

35
What’s wrong with fixed-function?
• Certain graphics algorithms are pre-
programmed into graphics cards (ex:
• So what?
– What if we want to use different algorithms?

• Why is the programmable pipeline
necessary?
– can achieve higher quality lighting/shading
36
– do these things on the hardware level
Summary
•For realistic rendering of polygons we need
interpolation methods to determine lighting
positions
•Flat shading is fast, but unrealistic
•Gouraud shading is better, but does not
handle specular reflections very well
•Phong shading is better still, but can be
slow
37
Tutorial