rendering pipeline
play

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


  1. 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

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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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 = ? ? ? ? ? ? ? ?

  9. 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

  10. 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

  11. 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)

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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

  19. 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

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. 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

  26. The Camera Model (2D) World to View space transformation ( M view ) – align camera axes with the world axes T

  27. 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

  28. 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

  29. 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

  30. 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

  31. 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

  32. 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

  33. 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

  34. 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

  35. 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

  36. 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

  37. 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

  38. 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

  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 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)

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

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

  42. Transformations via Camera x w v z u y OR to make bunny bigger bring camera closer

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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend