welcome
play

Welcome! 1 2 Todays Agenda: Projection Pipeline Recap - PowerPoint PPT Presentation

1 INFOGR Computer Graphics J. Bikker - April-July 2015 - Lecture 6: "Transformations" Welcome! 1 2 Todays Agenda: Projection Pipeline Recap Rasterization 2 INFOGR Lecture 6


  1. 1 INFOGR – Computer Graphics J. Bikker - April-July 2015 - Lecture 6: "Transformations" Welcome! 1

  2. 2 Today’s Agenda: Projection  Pipeline Recap  Rasterization  2

  3. INFOGR – Lecture 6 – "Transformations" 3 Perspective Projection – Applying matrices, working our way backwards Goal: create 2D images of 3D scenes Standard approach: linear perspective (in contrast to e.g. fisheye views) Parallel projection: Perspective projection: 3

  4. INFOGR – Lecture 6 – "Transformations" 4 Perspective Parallel projection: Maps 3D points to 2D by moving them along a projection direction until they hit an image plane . Perspective projection: Maps 3D points to 2D by projecting them along lines that pass through a single viewpoint until they hit an image plane. 4

  5. INFOGR – Lecture 6 – "Transformations" 5 Perspective 5

  6. INFOGR – Lecture 6 – "Transformations" 6 Perspective 6

  7. INFOGR – Lecture 6 – "Transformations" 7 Perspective 7

  8. INFOGR – Lecture 6 – "Transformations" 8 Perspective 8

  9. INFOGR – Lecture 6 – "Transformations" 9 Perspective 9

  10. INFOGR – Lecture 6 – "Transformations" 10 Perspective 10

  11. INFOGR – Lecture 6 – "Transformations" 11 Perspective Perspective projection World space (3D) Screen space (2D) We get our 3D objects perspective correct on the 2D screen by applying a sequence of matrix operations. 11

  12. INFOGR – Lecture 6 – "Transformations" 12 Perspective Perspective projection E y 𝑒 The camera is defined by: 𝑚 𝑜  Its position E 𝑊  The view direction 𝑊  The image plane (defined by its distance 𝑔 𝑒 and the field of view) 𝑠 FOV The view frustum is the volume visible from the camera. It is defined by: x z  A near and a far plane 𝑜 and 𝑔 ;  A left and a right plane 𝑚 and 𝑠 ; The world according to the camera:  A top and a bottom plane 𝑢 and 𝑐 (in 3D). Camera space 12

  13. INFOGR – Lecture 6 – "Transformations" 13 Perspective 𝑨 = 𝑔 x Perspective projection 𝑨 = 𝑜 Camera space: looking down negative 𝑨 . -z We can now map from (𝑦, 𝑧, 𝑨) to (𝑦 𝑡 , 𝑧 𝑡 ) y (but this mapping is not trivial) Projection (and later: clipping) becomes easier when we switch to an orthographic view volume. x This time the mapping is: 𝑨 = 𝑔 𝑨 = 𝑜 𝑦, 𝑧, 𝑨 → 𝑦, 𝑧 → 𝑦 𝑡 , 𝑧 𝑡 . Going from camera space to the orthographic -z view volume can be achieved using a matrix y multiplication. 13

  14. INFOGR – Lecture 6 – "Transformations" 14 Perspective Perspective projection The final transform is the one that takes us from the orthographic view volume to the canonical view volume. Again, this is done using a matrix. 𝑨 = −1 𝑨 = 1 𝑦 = 1 -z 𝑦 = −1 14

  15. INFOGR – Lecture 6 – "Transformations" 15 Perspective Perspective projection World space  camera space  orthographic view  canonical view I × M camera × M ortho × M canonical These can be collapsed into a single 4 × 4 matrix. 15

  16. INFOGR – Lecture 6 – "Transformations" 16 Perspective Perspective projection We need one last transform: From canonical view (-1..1) to 2D screen space ( 𝑂 𝑦 × 𝑂 𝑧 ). Screen space (2D) Canonical view screen  16

  17. INFOGR – Lecture 6 – "Transformations" 17 Perspective Perspective projection STEP ONE: canonical view to screen space This is assuming we already threw away 𝑨 to get an orthographic projection. We will however Vertices in the canonical view are combine all matrices in the end, so we actually orthographically projected on an 𝑜 𝑦 × 𝑜 𝑧 image. need a 4 × 4 matrix: We need to map the square [-1,1] 2 onto a rectangle 0, 𝑜 𝑦 × [0, 𝑜 𝑧 ] . Matrix: 𝑜 𝑦 𝑜 𝑦 𝑜 𝑦 𝑜 𝑦 0 0 0 2 2 2 2 𝑜 𝑧 𝑜 𝑧 𝑜 𝑧 𝑜 𝑧 𝑁 𝑤𝑞 = 0 0 0 2 2 2 2 0 0 1 0 0 0 1 0 0 0 1 17

  18. INFOGR – Lecture 6 – "Transformations" 18 Perspective Perspective projection STEP ONE: canonical view to screen space We now know the final transform for the vertices: 𝑦 𝑡𝑑𝑠𝑓𝑓𝑜 𝑦 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 𝑧 𝑡𝑑𝑠𝑓𝑓𝑜 𝑧 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 = 𝑁 𝑤𝑞 𝑨 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 𝑨 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 1 1 Next step: getting from the orthographic view volume to the canonical view volume. 18

  19. INFOGR – Lecture 6 – "Transformations" 19 Perspective Perspective projection STEP TWO: orthographic view volume to canonical view volume The orthographic view volume is an axis aligned box 𝑚, 𝑠 × 𝑐, 𝑢 × [𝑜, 𝑔] . We want to scale this to a 2 × 2 × 2 box centered around the origin. Combined: Scaling to [-1,1]: Moving the center to the origin: 2 2 − 𝑚 + 𝑠 − 𝑚 + 𝑠 0 0 0 1 0 0 0 0 𝑠 − 𝑚 2 𝑠 − 𝑚 𝑠 − 𝑚 2 2 − 𝑐 + 𝑢 − 𝑐 + 𝑢 0 0 0 0 1 0 0 0 × = 𝑢 − 𝑐 2 𝑢 − 𝑐 𝑢 − 𝑐 2 2 − 𝑜 + 𝑔 − 𝑜 + 𝑔 0 0 0 0 0 1 0 0 𝑜 − 𝑔 2 𝑜 − 𝑔 𝑜 − 𝑔 0 0 0 1 0 0 0 1 0 0 0 1 19

  20. INFOGR – Lecture 6 – "Transformations" 20 Perspective Perspective projection STEP TWO: orthographic view volume to canonical view volume The final transforms for the vertices are thus: 𝑦 𝑡𝑑𝑠𝑓𝑓𝑜 𝑦 𝑝𝑠𝑢ℎ𝑝 𝑧 𝑡𝑑𝑠𝑓𝑓𝑜 𝑧 𝑝𝑠𝑢ℎ𝑝 = 𝑁 𝑤𝑞 𝑁 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 𝑨 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 𝑨 𝑝𝑠𝑢ℎ𝑝 1 1 Next step: getting from camera space to the orthographic view volume. 20

  21. INFOGR – Lecture 6 – "Transformations" 21 Perspective Perspective projection Translate: 1 0 0 −𝐹 𝑦 STEP THREE: camera space to orthographic view volume 0 1 0 −𝐹 𝑧 0 0 1 −𝐹 𝑨 0 0 0 1 E y x i.e., the inverse of the camera translation. Rotate: -z We will use the inverse y of the basis defined by the camera orientation. x z 21

  22. INFOGR – Lecture 6 – "Transformations" 22 Perspective Perspective projection 𝑣𝑞 STEP THREE: camera space to orthographic view volume 𝑧 𝑨 Basis defined by the camera orientation: 𝑦 z-axis: −𝑊 (convention says we look down – z) x-axis: −𝑊 × 𝑣𝑞 y-axis: 𝑊 × 𝑦 𝑊 Matrix: Inverse: 𝑌 𝑦 𝑍 −𝑊 0 𝑌 𝑦 𝑌 𝑧 𝑌 𝑨 0 1 0 0 −𝐹 𝑦 𝑦 𝑦 𝑌 𝑧 𝑍 −𝑊 0 0 1 0 −𝐹 𝑧 𝑍 𝑍 𝑍 0 × = 𝑁 𝑑𝑏𝑛𝑓𝑠𝑏 𝑧 𝑧 𝑦 𝑧 𝑨 𝑌 𝑨 𝑍 −𝑊 0 0 0 1 −𝐹 𝑨 −𝑊 −𝑊 −𝑊 0 𝑨 𝑨 𝑦 𝑧 𝑨 0 0 0 1 0 0 0 1 0 0 0 1 22

  23. INFOGR – Lecture 6 – "Transformations" 23 Perspective 𝑨 = 𝑔 x Perspective projection 𝑨 = 𝑜 STEP THREE: camera space to orthographic view volume -z The combined transform so far: y 𝑦 𝑡𝑑𝑠𝑓𝑓𝑜 𝑦 𝑥𝑝𝑠𝑚𝑒 𝑧 𝑡𝑑𝑠𝑓𝑓𝑜 𝑧 𝑥𝑝𝑠𝑚𝑒 = 𝑁 𝑤𝑞 𝑁 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 𝑁 𝑑𝑏𝑛𝑓𝑠𝑏 𝑨 𝑑𝑏𝑜𝑝𝑜𝑗𝑑𝑏𝑚 𝑨 𝑥𝑝𝑠𝑚𝑒 1 1 x 𝑨 = 𝑔 One thing is still missing: perspective. 𝑨 = 𝑜 -z y 23

  24. INFOGR – Lecture 6 – "Transformations" 24 Perspective Perspective projection Q: What is perspective? A: The size of an object on the screen is proportional to 1/𝑨 . More precisely: 𝑒 𝑒 𝑧 𝑡 = 𝑨 𝑧 (and 𝑦 𝑡 = 𝑨 𝑦 ) where 𝑒 is the distance of the view plane to the camera. Q: How do we capture scaling based on distance in a matrix? A: … Dividing by z can’t be done using linear nor affine transforms. 24

  25. INFOGR – Lecture 6 – "Transformations" 25 Perspective Perspective projection Let’s have a look at homogeneous coordinates again. Recall: 𝑏 1 𝑦 + 𝑐 1 𝑧 + 𝑑 1 𝑨 𝑦 𝑏 1 𝑐 1 𝑑 1 𝑧 𝑏 2 𝑦 + 𝑐 2 𝑧 + 𝑑 2 𝑨 = 𝑏 2 𝑐 2 𝑑 2 𝑨 𝑏 3 𝑦 + 𝑐 3 𝑧 + 𝑑 3 𝑨 𝑏 3 𝑐 3 𝑑 3 With homogeneous coordinates, we get: (𝑏 1 𝑦 + 𝑐 1 𝑧 + 𝑑 1 𝑨 + 𝑈 𝑦 )/1 𝑏 1 𝑐 1 𝑑 1 𝑈 𝑏 1 𝑦 + 𝑐 1 𝑧 + 𝑑 1 𝑨 + 𝑈 𝑦 𝑦 𝑦 (𝑏 2 𝑦 + 𝑐 2 𝑧 + 𝑑 2 𝑨 + 𝑈 𝑧 )/1 𝑏 2 𝑐 2 𝑑 2 𝑈 𝑧 𝑏 2 𝑦 + 𝑐 2 𝑧 + 𝑑 2 𝑨 + 𝑈 𝑧 𝑧 = = 𝑨 (𝑏 3 𝑦 + 𝑐 3 𝑧 + 𝑑 3 𝑨 + 𝑈 𝑨 )/1 𝑏 3 𝑐 3 𝑑 3 𝑈 𝑏 3 𝑦 + 𝑐 3 𝑧 + 𝑑 3 𝑨 + 𝑈 𝑨 𝑨 1 0 0 0 1 1 1 25

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