rasterization 03
play

Rasterization (03) RNDr. Martin Madaras, PhD. - PowerPoint PPT Presentation

Principles of Computer Graphics and Image Processing Rasterization (03) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk Last lessons summary 2 CG reference model 3 Computer Vision/ Computer Graphics Computer Graphics 4 CG reference


  1. Principles of Computer Graphics and Image Processing Rasterization (03) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk

  2. Last lessons summary 2

  3. CG reference model 3

  4. Computer Vision/ Computer Graphics Computer Graphics 4

  5. CG reference model  Geometry space  continuous  3Dimensional  Screen space  discrete  2Dimensional 5

  6. 3D Scene vs. 2D image 6

  7. Geometry vs. screen space 3D 2D Continuous Discrete Parametric Non-parametric Models Pixels 7

  8. 3D polygon rendering  Many applications use rendering of 3D polygons with direct illumination 8

  9. 3D polygon rendering  Many applications use rendering of 3D polygons with direct illumination Quake 3, ID software 9

  10. 3D polygon rendering  Many applications use rendering of 3D polygons with direct illumination CATIA, Dassault Systemes 10

  11. 3D polygon rendering  What steps are necessary to produce an image of a 3D scene? 11

  12. Ray Casting  One approach is to cast rays from the camera… 12

  13. Ray Casting  And find intersections with the scene…  We are going to describe different approach this lesson 13

  14. 3D polygon rendering  Second approach is called Rasterization  Way how to efficiently draw primitives into screen space 14

  15. How the lectures should look like #1 Ask questions, please!!! - Be communicative - www.slido.com #PPGSO03 - More active you are, the better for you! - 15

  16. Rasterization 16

  17. 3D rendering pipeline 3D polygons Modeling 1 Transformation Lighting Viewing Transformation Projection Transformation Clipping Scan Conversion 2D Image 17

  18. 3D rendering pipeline Modeling 1 Transformation array of vertex positions x,y,z { 0,1,0, 1,1,0, 1,0,0, 0,0,0} Lighting OpenGL executes steps of the 3D Viewing rendering pipeline for each polygon Transformation Projection Transformation Clipping Scan Conversion 2D Image 18

  19. 3D rendering pipeline 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Lighting Viewing Transformation Projection Transformation Clipping Scan Conversion 2D Image 19

  20. 3D rendering pipeline 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Illuminate according to light Lighting Viewing Transformation Projection Transformation Clipping Scan Conversion 2D Image 20

  21. 3D rendering pipeline 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Illuminate according to light Lighting Viewing Transform into 3D camera coordinate system Transformation Projection Transformation Clipping Scan Conversion 2D Image 21

  22. 3D rendering pipeline 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Illuminate according to light Lighting Viewing Transform into 3D camera coordinate system Transformation Projection Transform into 2D camera coordinate system Transformation Clip polygons outside of camera’s view Clipping Scan Conversion Draw pixels 2D Image 22

  23. 3D rendering pipeline 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Illuminate according to light Lighting Viewing Transform into 3D camera coordinate system Transformation Projection Transform into 2D camera coordinate system Transformation Clip polygons outside of camera’s view Clipping Scan Conversion Draw pixels 2D Image 23

  24. 3D rendering pipeline 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Illuminate according to light Lighting Viewing Transform into 3D camera coordinate system Transformation Projection Transform into 2D camera coordinate system Transformation Clip polygons outside of camera’s view Clipping Scan Conversion Draw pixels 2D Image 24

  25. 3D rendering pipeline 3D polygons Modeling  Model transformation 1 Transformation  local → global coordinates Lighting  View transformation Viewing  global → camera Transformation  Projection transformation Projection  camera → screen Transformation  Clipping, rasterization, Clipping texturing & Lighting Scan Conversion  might take place earlier 2D Image 25

  26. Transformations 3D polygons Transform into 3D world coordinate system Modeling 1 Transformation Illuminate according to light Lighting Viewing Transform into 3D camera coordinate system Transformation Projection Transform into 2D camera coordinate system Transformation Clip polygons outside of camera’s view Clipping Scan Conversion Draw pixels 2D Image 26

  27. Transformations P(x, y, z) 3D Object coordinates Modeling Transformation 3D World coordinates Viewing Transformation 3D Camera coordinates Projection Transformation 2D Camera coordinates Window to Viewport Transformation 2D Image coordinates Transformations map points from one coordinate system to another P’(x’, y’) 27

  28. Camera coordinates  Canonical coordinate system  Convention is right-handed (looking down -z)  Convenient for projection, clipping etc. 28

  29. Coordinate systems  DirectX <= 9, left handed only 29

  30. Local coordinates  Each object has its own coordinate system 30

  31. Global coordinates  One system for the whole scene 31

  32. Local → Global coordinates  Translation   1 0 0     = ( ' , ' , 1 ) ( , , 1 ) 0 1 0 x y x y     1 t t   x y 32

  33. Local → Global coordinates  Rotation     cos sin 0   = −     ( ' , ' , 1 ) ( , , 1 ) sin cos 0 x y x y     0 0 1 33

  34. Local → Global coordinates  All transformations combined 34

  35. Transformations  Transformation from one coordinate system to another one is a composition of partial transformations:  Translation  Rotation  Scaling 35

  36. All transformations  Model transformation  Unify coordinates by transforming local to global coordinates  View transformation  Transform global coordinates so that they are aligned with camera coordinates  T o make projection computable 36

  37. Model transformation  Transformation local → global  Combination of rotate, translate, scale  Matrix multiplication 37

  38. Model transformation  Translation, rotation, scaling         cos sin 0 0 0 s 1 0 0    x    −         sin cos 0 0 0 0 1 0 s y         1     0 0 1 0 0 1  t t  x y 38

  39. Camera coordinates  XY of screen + Z as direction of view 39

  40. Global→camera coordinates  T * R y * R x  Translation, rotation, rotation  T * R y * R x * R z  if the camera is rolled  Projection P  orthogonal, perspective, isometric ... 40

  41. Viewing Transformation  Mapping from world to camera coordinates  Eye position maps to origin  Right vector maps to X axis  Up vector maps to Y axis  Back vector maps to Z axis 41

  42. Finding the Viewing Transformation  We have the camera (in world coordinates)  We want T taking objects from world to camera 𝑞 𝐷 = 𝑈𝑞 𝑋  Trick: find T taking objects in camera to world 𝑞 𝑋 = 𝑈 −1 𝑞 𝐷 𝑦 ′ 𝑏 𝑐 𝑑 𝑒 𝑦 𝑧 ′ 𝑓 𝑔 𝑕 ℎ 𝑧 = 𝑨 𝑨 ′ 𝑗 𝑘 𝑙 𝑚 𝑥 𝑛 𝑜 𝑝 𝑞 𝑥′ 42

  43. Finding the Viewing Transformation  Trick: Map from camera coordinates to world  Origin maps to eye position  z axis maps to Back vector  y axis maps to Up vector  x axis maps to Right vector 𝑠 𝑣 𝑦 𝑐 𝑦 𝑓 𝑌 𝑦 ′ 𝑦 𝑦 𝑠 𝑣 𝑧 𝑐 𝑧 𝑓 𝑧 𝑧 ′ 𝑧 𝑧 = 𝑨 𝑨 ′ 𝑠 𝑣 𝑨 𝑐 𝑨 𝑓 𝑨 𝑨 𝑥 𝑥′ 𝑠 𝑣 𝑥 𝑐 𝑥 𝑓 𝑥 𝑥  T o get 𝑈 −1 we just need to invert 𝑈 43

  44. Finding the Viewing Transformation  Trick: Map from camera coordinates to world  Origin maps to eye position  z axis maps to Back vector  y axis maps to Up vector  x axis maps to Right vector 𝑠 𝑣 𝑦 𝑐 𝑦 𝑓 𝑌 𝑦 ′ 𝑦 𝑦 𝑠 𝑣 𝑧 𝑐 𝑧 𝑓 𝑧 𝑧 ′ 𝑧 𝑧 = 𝑨 𝑨 ′ 𝑠 𝑣 𝑨 𝑐 𝑨 𝑓 𝑨 𝑨 𝑥 𝑥′ 𝑠 𝑣 𝑥 𝑐 𝑥 𝑓 𝑥 𝑥  T o get 𝑈 −1 we just need to invert 𝑈 44

  45. Vectors vs Positions  There is a fundamental difference between vectors and positions in homogeneous coordinates!  Position  In homogeneous coordinates p = {x, y, z, 1}  Can be moved so translation will apply  Vector  In homogenous coordinates v = {x, y, z, 0}  Cannot be moved, its just direction 45

  46. Projections summary 46

  47. Projection types  Orthogonal 47

  48. Projection types  Parallel 48

  49. Projection types  Isometric (parallel but not orthogonal) 49

  50. Projection types  Perspective 50

  51. Projection types  Perspective 51

  52. Viewport transformation 52

Recommend


More recommend