Rendering Pipeline http://www.songho.ca/opengl/gl_transform.html M - - PowerPoint PPT Presentation

rendering pipeline
SMART_READER_LITE
LIVE PREVIEW

Rendering Pipeline http://www.songho.ca/opengl/gl_transform.html M - - PowerPoint PPT Presentation

Rendering Pipeline http://www.songho.ca/opengl/gl_transform.html M model M view *M proj World space View space Screen space P canvas = M proj M view M model * P world Projections Compute coordinates from World Space to Screen Space (to


slide-1
SLIDE 1

Rendering Pipeline

Mmodel Mview*Mproj World space View space Screen space

P’canvas = Mproj Mview Mmodel * Pworld

http://www.songho.ca/opengl/gl_transform.html

slide-2
SLIDE 2

Projections

Compute coordinates from World Space to Screen Space (to Canvas) v w u y z x

slide-3
SLIDE 3

Orthographic Projection

Points are projected along rays that are perpendicular to canvas v w u y x z preserves size of object regardless of distance to canvas

slide-4
SLIDE 4

Perspective Projection

Points are projected along rays that go through a given point of projection v w u y x z

  • bjects closer to canvas appear larger
slide-5
SLIDE 5

View Volume

Specify near (n) and far (f) planes to enable efficient object removal

  • bjects outside the view volume are not processed

v w u n f view volume for orthographic projection y z x

slide-6
SLIDE 6

View Volume

Specify near (n) and far (f) planes to enable efficient object removal

  • bjects outside the view volume are not processed

view volume for perspective projection v w u n z y x f

slide-7
SLIDE 7

Projection Matrix

Find a matrix that transforms from World Space to Screen Space (to Canvas) given coordinates Pv in the World, what are the coordinates Ps on the Canvas

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

Mproj =

u

Pv Ps y z x

v w

Pv Ps y x

Ps = Mproj * Pv

slide-8
SLIDE 8

Orthographic Projection Matrix

Keep the (x, y) coordinates xs = xv ys = yv Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1 v w u Pv Ps

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

Mproj =

y x z

slide-9
SLIDE 9

Orthographic Projection Matrix

Keep the (x, y) coordinates xs = xv ys = yv Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1 v w Pv Ps

1 1 1

Mproj =

u y x z

slide-10
SLIDE 10

Orthographic Projection Matrix

Keep the (x, y) coordinates xs = xv ys = yv Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1 v w Pv Ps

1 1 1

Mproj =

u y x z Find A, B such that zs = A * zv + B and zv=n -> zs=0 zv=f -> zs=1

slide-11
SLIDE 11

Orthographic Projection Matrix

Keep the (x, y) coordinates xs = xv ys = yv Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1 v w Pv Ps

1 1 A B 1

Mproj =

u Find A, B such that zs = A * zv + B and zv=n -> zs=0 0 = A*n + B A = 1 / (f – n) zv=f -> zs=1 1 = A*f + B B = -n / (f – n) x z y

slide-12
SLIDE 12

Perspective Projection Matrix

Transform the (x, y) coordinates from World Space to Screen Space Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1 v w Pv u Ps y z x

slide-13
SLIDE 13

Perspective Projection Matrix

Consider only the YZ-plane (looking down x-axis) and calculate ys based on yv v u Pv w Ps y z x Pv Ps y z n zv

ys n ––– = ––– ys = n*ys / zv yv zv

yv ys

slide-14
SLIDE 14

Perspective Projection Matrix

Consider only the XZ-plane (looking down y-axis) and calculate xs based on xv v u Pv w Ps y z x Pv Ps x z n zv

xs n ––– = ––– xs = n*xs / zv xv zv

xs xv

slide-15
SLIDE 15

Perspective Projection Matrix

v u Pv w Ps x z y

n*xv n*yv

xs = –– ys = –– zv zv

n n 1 xv yv zv 1

*

n*xv n*yv zv =

Use the homogeneous coordinate w to achieve division by zv

slide-16
SLIDE 16

Perspective Projection

Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1

n n 1

Mproj =

Find A, B such that zs = (A*zv + B * w) / zv

= A + B / zv

and zv=n -> zs=0 zv=f -> zs=1

slide-17
SLIDE 17

Perspective Projection

Transform z such that zv = n maps to zs = 0 zv = f maps to zs = 1

n n A B 1

Mproj =

Find A, B such that zs = (A*zv + B * w) / zv

= A + B / zv

and zv=n -> zs=0 0 = A + B / n A = f / (f - n) zv=f -> zs=1 1 = A + B / f B = -n*f / (f - n)

slide-18
SLIDE 18

Rendering Pipeline

Mmodel Mview*Mproj World space View space Screen space

P’canvas = Mproj Mview Mmodel * Pworld

http://www.songho.ca/opengl/gl_transform.html

slide-19
SLIDE 19

The Camera Model (2D)

v u e camera parameters: e – eye point coordinates v – the directions of the view u – up vector e – what is the position (ex,ey)

  • f the camera in the world

v – what are the coordinates (vx,vy) of the viewing direction in the world u – a vector perpendicular to v v u e The camera parameters and the coordinates of the model are specifjed in world space

slide-20
SLIDE 20

The Camera Model (2D)

v u e To render the model need to: represent it from world space to camera view space coordinates – Mview project it on the camera film – Mproj v u e x y x' y'

slide-21
SLIDE 21

The Camera Model (2D)

World to View space transformation (Mview) – align camera axes with the world axes If we bring Camera to Center of World, coords for camera == coords for World What matrix Mview – will align the Camera with the Center of the World

slide-22
SLIDE 22

The Camera Model (2D)

World to View space transformation (Mview) – align camera axes with the world axes If we bring Camera to Center of World, coords for camera == coords for World What matrix Mview – will bring the Camera with the Center of the World

1

  • ex

1

  • ey

1

T

slide-23
SLIDE 23

The Camera Model (2D)

World to View space transformation (Mview) – align camera axes with the world axes If we align Camera withWorld axes, coords for camera == coords for World What matrix Mview – will align the Camera with the Center of the World

slide-24
SLIDE 24

The Camera Model (2D)

World to View space transformation (Mview) – align camera axes with the world axes If we align Camera withWorld axes, coords for camera == coords for World What matrix Mview – will align the Camera with the Center of the World

vx vy ux uy 1

R

slide-25
SLIDE 25

The Camera Model (2D)

World to View space transformation (Mview) – align camera axes with the world axes If we bring/align Camera to Center of World, coords for camera == coords for World What matrix Mview – will bring/align the Camera with the Center of the World

slide-26
SLIDE 26

The Camera Model (2D)

T

World to View space transformation (Mview) – align camera axes with the world axes

slide-27
SLIDE 27

The Camera Model (2D)

T

1

  • ex

1

  • ey

1

World to View space transformation (Mview) – align camera axes with the world axes

slide-28
SLIDE 28

The Camera Model (2D)

T R

1

  • ex

1

  • ey

1

World to View space transformation (Mview) – align camera axes with the world axes

slide-29
SLIDE 29

The Camera Model (2D)

T R

1

  • ex

1

  • ey

1 vx vy ux uy 1

World to View space transformation (Mview) – align camera axes with the world axes

slide-30
SLIDE 30

The Camera Model (2D)

T R

1

  • ex

1

  • ey

1 vx vy ux uy 1

Mview = R*T

World to View space transformation (Mview) – align camera axes with the world axes

slide-31
SLIDE 31

Rendering Pipeline

Mmodel Mview*Mproj World space View space Screen space

P’canvas = Mproj Mview Mmodel * Pworld

http://www.songho.ca/opengl/gl_transform.html

slide-32
SLIDE 32

The Camera Model (3D)

camera parameters: e – eye point coordinates v – the directions of the view u – up vector The camera parameters and the coordinates of the 3Dmodels are specifjed in world space v u e w v u e w

slide-33
SLIDE 33

The Camera Model (3D)

World to View space transformation (Mview) – align camera axes with the world axes v u e w v u e w

slide-34
SLIDE 34

The Camera Model (3D)

T

World to View space transformation (Mview) – align camera axes with the world axes v u e w v u e w

slide-35
SLIDE 35

The Camera Model (3D)

T

World to View space transformation (Mview) – align camera axes with the world axes v u e w v u e w

1

  • ex

1

  • ey

1

  • ez

1

slide-36
SLIDE 36

The Camera Model (3D)

T R

World to View space transformation (Mview) – align camera axes with the world axes v u e w v u e w v u e w

1

  • ex

1

  • ey

1

  • ez

1

slide-37
SLIDE 37

The Camera Model (3D)

T R

World to View space transformation (Mview) – align camera axes with the world axes v u e w v u e w v u e w

1

  • ex

1

  • ey

1

  • ez

1 wx wy wz ux uy uz vx vy vz 1

slide-38
SLIDE 38

The Camera Model (3D)

T R

World to View space transformation (Mview) – align camera axes with the world axes v u e w v u e w v u e w

1

  • ex

1

  • ey

1

  • ez

1 wx wy wz ux uy uz vx vy vz 1

Mview = R*T

slide-39
SLIDE 39

Specifying The Camera Model

Typically the camera is specified by e – eye point coordinates c – a point in the direction of the gaze u – (approximate) up vector From these need to calculate v – the direction of the view w – the tilt of the camera The calculations v – a vector from e to c w = u x v – here x is the vector cross product (not dot product) c v u e w

slide-40
SLIDE 40

Transformations via Camera

v w u y x z to make bunny bigger, just scale it – canvas.scale(...)

slide-41
SLIDE 41

Transformations via Camera

v w u y x z to make bunny bigger, just scale it – canvas.scale(...)

slide-42
SLIDE 42

Transformations via Camera

v w u y x z OR to make bunny bigger bring camera closer

slide-43
SLIDE 43

Transformations via Camera

v w u y x z to move bunny, just translate it – canvas.translate(...)

slide-44
SLIDE 44

Transformations via Camera

v w u y x z OR to move the bunny, move the camera

slide-45
SLIDE 45

Transformations via Camera

v w u y x z to rotate the bunny, just rotate it – canvas.rotate(...)

slide-46
SLIDE 46

Transformations via Camera

v w u y x z to rotate the bunny, just rotate it – canvas.rotate(...)

slide-47
SLIDE 47

Transformations via Camera

v w u y x z OR to rotate the bunny, rotate the camera

slide-48
SLIDE 48

Cross Product

The cross product of two vectors yields a third vector perpendicular to the original a b c = a x b a b c = b x a

c = a x b cx = ay bz - az by cy = az bx - ax bz cz = ax by - ay bx ax ay az ax bx by bz bx

Not commutative

a x b ≠ b x a