1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB...

48
1 Jinxiang Chai CSCE 441 Computer Graphics
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    225
  • download

    1

Transcript of 1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB...

1

Jinxiang Chai

CSCE 441 Computer Graphics

2

Midterm

Time: 10:10pm-11:20pm, 10/20

Location: HRBB 113

3

What you’ve learned in this class?

2D GraphicsDrawing lines, polygonsColor

3D GraphicsTransformations

Hidden surface removals

4

Scan Line Conversion

How to draw a line?

- Digital Differential Analyzer (DDA)

- Midpoint algorithm

- Understand both algorithms

- Strengths and limitations

5

Scan Conversion of Polygons

How to draw a polygons?

- Active edge list

- Boundary fill

- Flood fill

- Understand three algorithms

- Limitations and strengths

6

Clipping Lines

1P

2P

3P4P

5P

6P

7P

8P9P

10P

7

Clipping Lines

5P

6̂P

7P

8P

9̂P

10P̂

8

Clipping Lines

Given a line with end-points (x0, y0), (x1, y1)

and clipping window (xmin, ymin), (xmax, ymax),

determine if line should be drawn and clipped end-points of line to draw.

(x0, y0)

(x1, y1)

(xmin,ymin)

(xmax,ymax)

9

Line Clipping

How to clip a line?

- Simple line clipping algorithm

- Cohen--Sutherland

- Liang-Barsky

10

Clipping Polygons

Clipping polygons is more complex than clipping the individual lines - Input: polygon

11

Clipping Polygons

Clipping polygons is more complex than clipping the individual lines - Input: polygon - Output: original polygon, new polygon,

or nothing

12

Polygon Clipping

How to clip a polygon?

- Sutherland-Hodgman Clipping (convex polygons)

- Weiler-Atherton Algorithm (general polygons)

13

2D/3D Transformation

Various transform matrices

- 2D/3D rotation

- 2D/3D translation

- 2D/3D scaling

- 2D affine transform

14

Arbitrary Rotation Center

To rotate about an arbitrary point P (px,py) by :

(px,py)

15

Arbitrary Rotation Center

To rotate about an arbitrary point P (px,py) by : Translate the object so that P will coincide with

the origin: T(-px, -py)

(px,py)

16

Arbitrary Rotation Center

To rotate about an arbitrary point P (px,py) by : Translate the object so that P will coincide with

the origin: T(-px, -py) Rotate the object: R()

(px,py)

17

Arbitrary Rotation Center

To rotate about an arbitrary point P (px,py) by : Translate the object so that P will coincide with

the origin: T(-px, -py) Rotate the object: R() Translate the object back: T(px,py)

(px,py)

18

Translate the object so that P will coincide with the origin: T(-px, -py)

Rotate the object: R() Translate the object back: T(px,py)

Put in matrix form: T(px,py) R() T(-px, -py) * P

x’ 1 0 px cos() -sin() 0 1 0 -px x y’ = 0 1 py sin() cos() 0 0 1 -py y1 0 0 1 0 0 1 0 0 1 1

Arbitrary Rotation Center

19

The standard scaling matrix will only anchor at (0,0)

Sx 0 0 0 Sy 0 0 0 1

What if I want to scale about an arbitrary pivot point?

Scaling Revisit

20

2D/3D Coordinate Transformation

Various transform matrix - 2D/3D rotation - 2D/3D translation - 2D/3D scaling - 2D affine transform

How to do 2D/3D matrix composition

21

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

21

22

2D Coordinate Transformation

2D translation

pj

i

i

j

o

o

110010

0

y

x

yjjij

xjiii

y

xTT

TT

1

0

0

1

),( 00 yx

22

23

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

cossin

sincos

10

0

y

x

y

x

y

x

),( 00 yx

23

24

2D Coordinate Transformation

2D translation & scaling

pj

i

i

j

o

o

1100

0

0

102

0

y

x

y

x

y

x x

),( 00 yx

24

25

Hierarchical Modeling: Lamp

What’s the current coordinate A ?

1

2

3

3c

2c

1c

A

03221100 )()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp

),,( 0yx0c

25

How to do opengl implementation?

26

A More Complex Example: Human Figure

How to do opengl implementation?

27

Image space

3D->2D Geometry Pipeline

27

Normalized project

space

View spaceWorld spaceObject space

Aspect ratio &

resolution

Focal length

Rotate and translate the

camera

28

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

28

Model space

(Object space)

29

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

29

World space

(Object space)

30

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

30

Eye space

(View space)

31

Camera Coordinate

31

32

3D Coordinate Trans.

Transform object description from camera to world

32

),,( zyx uuu),,( zyx nnn),,( zyx vvv

10000

0

0

,1

, znvu

ynvu

xnvu

TTzzz

yyy

xxx

wccw

33

Viewing Trans: gluLookAt

33

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

34

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

),,( zyx upupupV

How to determine ?

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

nvu

,,

35

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

refppN

0

),,( zyx upupupV

N

Nn

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

36

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

refppN

0

),,( zyx upupupV

N

Nn

V

nVu

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

37

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

refppN

0

),,( zyx upupupV

N

Nn

V

nVu

unv

H&B equation (7-1)

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

38

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

38

Normalized projection

space

39

Consider the projection of a point on the camera plane

3D->2D

39

By similar triangles, we can compute how much the x and y coordinates are scaled

z

dxx

d

x

z

x

'

z

dyy

d

y

z

y

'

'

40

Now we can rewrite the perspective projection equation as matrix-vector multiplications

The Perspective Matrix

40

After the division by w, we have

z

dxx

d

x

z

x

'

z

dyy

d

y

z

y

'

'

10100

0010

0001

'

'

'

z

y

x

dw

y

x

11

'

'

zdyz

dx

y

x

41

Projections

Parallel projection - definition

- properties

Perspective projection

- definition

- homogeneous coordinates

- vanishing point

- properties

42

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

42

Image space, window space, raster

space, screen space, device space

43

Scan conversion

3D Rendering pipelineModeling transformation

lighting

Viewing transformation

Project transformation

Clipping

Image

Transform into 3D world system

Illuminate according to lighting and reflectance

Transform into 3D camera coordinate system

Transform into 2D camera system

Clip primitives outside camera’s view

Draw pixels (includes texturing, hidden surface, etc.)

44

Hidden Surface Removals

Backface Culling Painter’s algorithm BSP Z-buffer Scan line Ray casting

45

5-2

2

7-2

For Example, BSP Tree

1 2

3

4

6

5-1

37-1

4 6

1

7-2

7-1

5-2

5-1

Traversal order?1->6->(5-2)->(7-2)->3->4->(5-1)->(7-1)->2

b

b

b f

f

f

b

b

46

Color

Understanding chromaticity diagram and its concept

Understanding various color models:

- RGB

- CMY/CMYK

- YUV/YIQ

- HSV

- XYZ, etc.

47

Chromaticity Diagram How to obtain chromaticity diagram?

Where are spectral colors and non-spectral colors located?

How to determine purity/saturation and dominant wave length/hues for a given color?

How to identify complementary colors?

How to compare color gamuts for different primaries?

Why three primary colors are not sufficient to represent all colors?

Image taken from http://fourier.eng.hmc.edu/e180/handouts/color1/node27.html

48

What you’ve learned in this class?

2D GraphicsDrawing lines, polygons

Color 3D Graphics

Transformations