41
L:CC, MI:ERSI CG T7 - Projection Miguel Tavares Coimbra (course and slides designed by Verónica Costa Orvalho)

CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

L:CC, MI:ERSI

CG – T7 - Projection

Miguel Tavares Coimbra

(course and slides designed by

Verónica Costa Orvalho)

Page 2: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Basic steps for creating a 2D image

out of a 3D world

CG 12/13 - T7

• Create the 3D world

– Vertexes and triangles in a 3D space

• Project it to a 2D ‘camera’

– Use perspective to transform coordinates into a

2D space

• Paint each pixel of the 2D image

– Rasterization, shading, texturing

– Will break this into smaller things later on

• Enjoy the super cool image you have created

Today

Page 3: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

How do we get 2D images out

of a 3D world?

Page 4: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

pipeline

. collision detection

. animation global acceleration . physics simulation process on CPU or GPU

. transformation

. projection Computes: . what is to be drawn . how should be drawn . where should be drawn process on GPU

. draws images generated by geometry stage process on GPU CG 12/13 - T7

Page 5: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

Page 6: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

One possibility: Ray tracing

for each pixel {

compute viewing ray

intersect ray with scene

compute illumination at visible point

put result into image

}

Adapted from Steve Marschner, Cornell University

Page 7: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Another one: Projection

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 8: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

Projection in photography

1544

Camera Obscura, Gemma Frisius, 1544

Page 9: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

Lens based projection

1544 1568

Lens Based Camera Obscura, 1568

Page 10: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Ray tracing vs. Projection

• Viewing in ray tracing – start with image point

– compute ray that projects to that point

– do this using geometry

• Viewing by projection – start with 3D point

– compute image point that it projects to

– do this using transforms

• Inverse processes – ray gen. computes the preimage of projection

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 11: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Are there different types of

projections?

Page 12: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Classical projections

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 13: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Parallel Projection

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 14: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Multiview orthographic

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 15: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Off-axis parallel

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 16: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

View volume: Orthographic

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 17: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 18: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Perspective projection (normal)

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 19: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

View volume: Perspective

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 20: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Field of view

– Angle between the rays corresponding to

opposite edges of a perspective image

– Determines ‘strength’ of perspective effects

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 21: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

Adapted from Steve Marschner, Cornell University

Page 22: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

Adapted from Steve Marschner, Cornell University

Page 23: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

3D Viewing

CG 12/13 - T7

Page 24: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Pipeline of transformations

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 25: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

CG 12/13 - T7

Page 26: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Mathematics of projection

• Always works in eye coordinates

– Assume eye point is at 0 and plane

perpendicular to z

• Orthographic case

– Simple projection: Just discard z

• Perspective case: scale diminishes with z

– And increases with d

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 27: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Orthographic projection

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 28: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

What about the view volume?

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 29: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Windowing transforms

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 30: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Viewport transformation

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 31: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Viewport transformation

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 32: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

What about the z direction?

• Two clipping planes further constrain the

view volume

– Near plane: parallel to view plane; things

between it and the viewpoint will not be

rendered

– Far plane: also parallel; things behind it will

not be rendered

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 33: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Orthographic projection

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 34: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Orthographic projection matrix

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 35: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Viewing transformation

CG 12/13 - T7

Advanced topic: Refer to the text book if interested!

Adapted from Steve Marschner, Cornell University

Page 36: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Orthographic transformation chain

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 37: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Perspective projection

CG 12/13 - T7

Page 38: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

View volume: Perspective (clipped)

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 39: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Perspective projection matrix

CG 12/13 - T7

Advanced topic: Refer to the text book if interested!

Adapted from Steve Marschner, Cornell University

Page 40: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Perspective transformation chain

CG 12/13 - T7 Adapted from Steve Marschner, Cornell University

Page 41: CG T7 - Projectionmcoimbra/lectures/CG_1213/CG_1213_T7_Projection.pdfMathematics of projection •Always works in eye coordinates –Assume eye point is at 0 and plane perpendicular

Summary

• Different types of projection

– Orthographic

– Perspective

• Integrate nicely into the transformation

chain

• Other elements:

– Viewing transform

– Viewport transform

CG 12/13 - T7