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 Canvas) x w v z u y
Orthographic Projection Points are projected along rays that are perpendicular to canvas x w v z u y preserves size of object regardless of distance to canvas
Perspective Projection Points are projected along rays that go through a given point of projection x w v z u y objects closer to canvas appear larger
View Volume Specify near (n) and far (f) planes to enable efficient object removal objects outside the view volume are not processed x w v z u y n f view volume for orthographic projection
View Volume Specify near (n) and far (f) planes to enable efficient object removal objects outside the view volume are not processed x w v z u y n f view volume for perspective projection
Projection Matrix Find a matrix that transforms from World Space to Screen Space (to Canvas) given coordinates P v in the World, what are the coordinates P s on the Canvas x P s P v ? ? ? ? z ? ? ? ? u M proj = x y ? ? ? ? ? ? ? ? P v P s w v P s = M proj * P v y
Orthographic Projection Matrix Keep the (x, y) coordinates x s = x v y s = y v Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 x w P s P v z v u ? ? ? ? y ? ? ? ? M proj = ? ? ? ? ? ? ? ?
Orthographic Projection Matrix Keep the (x, y) coordinates x s = x v y s = y v Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 x w P s P v z v u 1 0 0 0 y 0 1 0 0 M proj = 0 0 0 1
Orthographic Projection Matrix Keep the (x, y) coordinates x s = x v y s = y v Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 x w P s P v z v u 1 0 0 0 y 0 1 0 0 M proj = Find A, B such that z s = A * z v + B and z v =n -> z s =0 0 0 0 1 z v =f -> z s =1
Orthographic Projection Matrix Keep the (x, y) coordinates x s = x v y s = y v Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 x w P s P v z v u 1 0 0 0 y 0 1 0 0 M proj = Find A, B such that z s = A * z v + B 0 0 A B and z v =n -> z s =0 0 = A*n + B A = 1 / (f – n) 0 0 0 1 z v =f -> z s =1 1 = A*f + B B = -n / (f – n)
Perspective Projection Matrix Transform the (x, y) coordinates from World Space to Screen Space Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 x P v w P s z v u y
Perspective Projection Matrix Consider only the YZ -plane (looking down x -axis) and calculate y s based on y v x P v u P s z v w z v y n z y s y v y s n P s P v ––– = ––– y s = n*y s / z v y v z v y
Perspective Projection Matrix Consider only the XZ -plane (looking down y -axis) and calculate x s based on x v x P v u P s z v w y x P v x s n P s x v ––– = ––– x s = n*x s / z v x s z x v z v n z v
Perspective Projection Matrix Use the homogeneous coordinate w to achieve division by z v y P v u P s z v w x n 0 0 0 x v n*x v n*x v n*y v z v = 0 n 0 0 y v n*y v * x s = –– y s = –– z v 1 z v z v 0 0 1 0
Perspective Projection Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 Find A, B such that z s = (A*z v + B * w) / z v = A + B / z v and z v =n -> z s =0 z v =f -> z s =1 n 0 0 0 0 n 0 0 M proj = 0 0 1 0
Perspective Projection Transform z such that z v = n maps to z s = 0 z v = f maps to z s = 1 Find A, B such that z s = (A*z v + B * w) / z v = A + B / z v and z v =n -> z s =0 0 = A + B / n A = f / (f - n) z v =f -> z s =1 1 = A + B / f B = -n*f / (f - n) n 0 0 0 0 n 0 0 M proj = 0 0 A B 0 0 1 0
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
The Camera Model (2D) u u e e v v camera parameters: e – eye point coordinates v – the directions of the view u – up vector e – what is the position (ex,ey) of the camera in the world The camera parameters and the coordinates of the model v – what are the coordinates are specifjed in world space (vx,vy) of the viewing direction in the world u – a vector perpendicular to v
The Camera Model (2D) To render the model need to: represent it from world space to camera view space coordinates – M view project it on the camera film – M proj u u y' e e v v y x' x
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes If we bring Camera to Center of World, coords for camera == coords for World What matrix M view – will align the Camera with the Center of the World
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes 1 0 -ex 0 1 -ey T 0 0 1 If we bring Camera to Center of World, coords for camera == coords for World What matrix M view – will bring the Camera with the Center of the World
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes If we align Camera withWorld axes, coords for camera == coords for World What matrix M view – will align the Camera with the Center of the World
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes vx vy 0 R ux uy 0 0 0 1 If we align Camera withWorld axes, coords for camera == coords for World What matrix M view – will align the Camera with the Center of the World
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes If we bring/align Camera to Center of World, coords for camera == coords for World What matrix M view – will bring/align the Camera with the Center of the World
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes T
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes 1 0 -ex 0 1 -ey T 0 0 1
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes 1 0 -ex 0 1 -ey T 0 0 1 R
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes 1 0 -ex 0 1 -ey T 0 0 1 R vx vy 0 ux uy 0 0 0 1
The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes 1 0 -ex 0 1 -ey T 0 0 1 R vx vy 0 ux uy 0 0 0 1 M view = R*T
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
The Camera Model (3D) u u e e w v w v 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
The Camera Model (3D) World to View space transformation ( M view ) – align camera axes with the world axes u e w v u e w v
The Camera Model (3D) World to View space transformation ( M view ) – align camera axes with the world axes u e w v u T e w v
The Camera Model (3D) World to View space transformation ( M view ) – align camera axes with the world axes u 1 0 -0 -ex e 0 1 0 -ey w 0 0 1 -ez v u T 0 0 0 1 e w v
The Camera Model (3D) World to View space transformation ( M view ) – align camera axes with the world axes u 1 0 -0 -ex e 0 1 0 -ey w 0 0 1 -ez v u T 0 0 0 1 e w v u R e w v
The Camera Model (3D) World to View space transformation ( M view ) – align camera axes with the world axes u 1 0 -0 -ex e 0 1 0 -ey w 0 0 1 -ez v u T 0 0 0 1 e w v wx wy wz 0 ux uy uz 0 u vx vy vz 0 R 0 0 0 1 e w v
The Camera Model (3D) World to View space transformation ( M view ) – align camera axes with the world axes u 1 0 -0 -ex e 0 1 0 -ey w 0 0 1 -ez v u T 0 0 0 1 e w v wx wy wz 0 ux uy uz 0 u vx vy vz 0 R 0 0 0 1 e M view = R*T w v
Specifying The Camera Model Typically the camera is specified by e – eye point coordinates c – a point in the direction of the gaze u u – (approximate) up vector e From these need to calculate w v v – the direction of the view c 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)
Transformations via Camera x w v z u y to make bunny bigger, just scale it – canvas.scale(...)
Transformations via Camera x w v z u y to make bunny bigger, just scale it – canvas.scale(...)
Transformations via Camera x w v z u y OR to make bunny bigger bring camera closer
Transformations via Camera x w v z u y to move bunny, just translate it – canvas.translate(...)
Recommend
More recommend