How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of...
Transcript of How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of...
1
How do we draw a picture?
• Define geometry.
• Now what?
• We can draw the edges of the faces. Wireframe.
• We can only draw the edges of faces that are visible.
• We can fill in the faces. Giving each object a color(constant shading).
COSC 342
2
Flat Shading
• Assumes the object is faceted, and light and viewerat infinity.
• Illumination model is applied only once per polygon.
2
Flat Shading
• Assumes the object is faceted, and light and viewerat infinity.
• Illumination model is applied only once per polygon.
• What if the object represents a curved surface?
COSC 342
3
Flat Shading
• Works poorly if the model represents a curved sur-face.
• Adding more facets helps but...
? Slows down the rendering.? Effectiveness is tempered by Mach banding.
COSC 342
4
Mach Bands
Perceived intensity change at edges are exageratedby receptors in our eyes, making the dark facet lookdarker and the light facet look lighter.
COSC 342
5
Is A or B darker?
illusion by Ted Adelson COSC 342
6
Are you sure?
illusion by Ted Adelson COSC 342
7
Is A or B darker?
illusion by Ted Adelson COSC 342
8
Are you sure?
illusion by Ted Adelson COSC 342
9
Are the diamonds the same colour?
illusion by Ted Adelson COSC 342
10
Are the diamonds the same colour?
illusion by Ted Adelson COSC 342
11
12
Are the circles the same colour and size?
13
Harmann-grid illusion - See white circles?
14
Flat Shading
15
Gouraud Shading
16
Gouraud Shading
• Also called smooth shading, intensity interpolationshading or color interpolation shading.
• Discontinuities eliminated by interpolating intensity.
• Almost removes Mach bands (high curvature can stillsuffer).
• OpenGL implements Gouraud shading.
• Easily implemented in hardware.
17
Gouraud Shading: How it works
• Illumination is calculated per vertex.
• Average normals of polygons that share vertex.
• Vertex colors linearly interpolated per pixel, firstalong the edges, then between those for the scan-line.
• Slower than flat shading, with much better results forcurved surfaces.
18
Gouraud Shading: How it works
19
Gouraud Shading: Notice any problems?
20
Gouraud Shading: Problems
• Highlights are spread along edges.
• Highlights tend to be larger than they should.
• Highlights tend to be shaped funny (dependent onnumber of polys).
• Misses specular highlights contained within a poly-gon.
21
Gouraud Shading Problems
22
Gouraud Shading Problems
23
Gouraud Shading Problems
24
Gouraud Shading Problems
25
Gouraud Shading Problems
26
Gouraud Shading Problems
27
Gouraud Shading Problems
28
Gouraud Shading Problems
29
Gouraud Shading Problems
30
Gouraud Shading Problems
31
Gouraud Shading Problems
32
Gouraud Shading Problems
33
Gouraud Shading Problems
34
Gouraud Shading Problems
35
Gouraud Shading Problems
36
Phong Shading
• Don’t confuse with Phong illumination(same guy different algorithm).
• Also called normal-vector interpolation shading.
• Interpolates the surface normals instead of the inten-sity values.
• Calculate illumination at every pixel, as well as a vec-tor normalization. Much slower than Gouraud.
• Gives better results, especially for highlights.
• Can handle highlights within a polygon.
37
Phong Shading: How it works
38
Gouraud Shading
Patrick Coleman
39
Phong Shading
Patrick Coleman
40
Shading Comparison
from Watt, 1989
41
Problems with Interpolation Shading
• Must store normals at each vertex.
• Silhouette edges not smoothed.
• Interpolation can mask regular changes.
• Interpolation in image space ignores perspective dis-tortion.
• Crease edges should not have smooth shading.
• Orientation dependence.
from Watt, 1989
42
Interpolation Shading Problems
from Watt, 1989
43
Interpolation Shading Problems
from Watt, 1989
44
Interpolation Shading Problems
from Watt, 1989
45
Interpolation Shading ProblemsA
B
C
Dp
from Watt, 1989
46
Interpolation Shading Problems
A
B
C
D
p
from Watt, 1989
47
Interpolation Shading ProblemsA
B
C
Dp
A
B
C
D
p
from Watt, 1989
48
Fixes for Interpolation Shading
• Use triangles.
• Use more triangles.
• Use multiple normals (to get sharp edges)
from Watt, 1989
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68