How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of...

69
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

Transcript of How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of...

Page 1: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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

Page 2: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

2

Flat Shading

• Assumes the object is faceted, and light and viewerat infinity.

• Illumination model is applied only once per polygon.

Page 3: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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

Page 4: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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

Page 5: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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

Page 6: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

5

Is A or B darker?

illusion by Ted Adelson COSC 342

Page 7: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

6

Are you sure?

illusion by Ted Adelson COSC 342

Page 8: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

7

Is A or B darker?

illusion by Ted Adelson COSC 342

Page 9: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

8

Are you sure?

illusion by Ted Adelson COSC 342

Page 10: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

9

Are the diamonds the same colour?

illusion by Ted Adelson COSC 342

Page 11: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

10

Are the diamonds the same colour?

illusion by Ted Adelson COSC 342

Page 12: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

11

Page 13: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

12

Are the circles the same colour and size?

Page 14: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

13

Harmann-grid illusion - See white circles?

Page 15: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

14

Flat Shading

Page 16: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

15

Gouraud Shading

Page 17: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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.

Page 18: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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.

Page 19: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

18

Gouraud Shading: How it works

Page 20: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

19

Gouraud Shading: Notice any problems?

Page 21: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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.

Page 22: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

21

Gouraud Shading Problems

Page 23: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

22

Gouraud Shading Problems

Page 24: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

23

Gouraud Shading Problems

Page 25: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

24

Gouraud Shading Problems

Page 26: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

25

Gouraud Shading Problems

Page 27: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

26

Gouraud Shading Problems

Page 28: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

27

Gouraud Shading Problems

Page 29: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

28

Gouraud Shading Problems

Page 30: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

29

Gouraud Shading Problems

Page 31: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

30

Gouraud Shading Problems

Page 32: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

31

Gouraud Shading Problems

Page 33: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

32

Gouraud Shading Problems

Page 34: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

33

Gouraud Shading Problems

Page 35: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

34

Gouraud Shading Problems

Page 36: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

35

Gouraud Shading Problems

Page 37: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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.

Page 38: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

37

Phong Shading: How it works

Page 39: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

38

Gouraud Shading

Patrick Coleman

Page 40: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

39

Phong Shading

Patrick Coleman

Page 41: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

40

Shading Comparison

from Watt, 1989

Page 42: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

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

Page 43: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

42

Interpolation Shading Problems

from Watt, 1989

Page 44: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

43

Interpolation Shading Problems

from Watt, 1989

Page 45: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

44

Interpolation Shading Problems

from Watt, 1989

Page 46: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

45

Interpolation Shading ProblemsA

B

C

Dp

from Watt, 1989

Page 47: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

46

Interpolation Shading Problems

A

B

C

D

p

from Watt, 1989

Page 48: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

47

Interpolation Shading ProblemsA

B

C

Dp

A

B

C

D

p

from Watt, 1989

Page 49: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

48

Fixes for Interpolation Shading

• Use triangles.

• Use more triangles.

• Use multiple normals (to get sharp edges)

from Watt, 1989

Page 50: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

49

Page 51: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

50

Page 52: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

51

Page 53: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

52

Page 54: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

53

Page 55: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

54

Page 56: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

55

Page 57: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

56

Page 58: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

57

Page 59: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

58

Page 60: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

59

Page 61: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

60

Page 62: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

61

Page 63: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

62

Page 64: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

63

Page 65: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

64

Page 66: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

65

Page 67: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

66

Page 68: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

67

Page 69: How do we draw a picture?sking/Courses/COSC5327/Notes/Shading2.pdf · • We can draw the edges of the faces. Wireframe. • We can only draw the edges of faces that are visible.

68