intro math review opengl pipeline week 1 tue may 10
play

Intro, Math Review, OpenGL Pipeline Week 1, Tue May 10 - PowerPoint PPT Presentation

University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Intro, Math Review, OpenGL Pipeline Week 1, Tue May 10 http://www.ugrad.cs.ubc.ca/~cs314/Vmay2005 Introduction Expectations hard course!


  1. Vector-Vector Multiplication � multiply: vector * vector = scalar u • v � dot product, aka inner product � � � � u v 1 1 � � � � ( ) ( ) ( ) u • v = u ∗ v + u ∗ v + u ∗ v � � � � 2 2 1 1 1 2 3 3 � � � � � � � � u v 3 3 ��

  2. Vector-Vector Multiplication � multiply: vector * vector = scalar u • v � dot product, aka inner product � � � � u v 1 1 � � � � ( ) ( ) ( ) u • v = u ∗ v + u ∗ v + u ∗ v � � � � 2 2 1 1 1 2 3 3 � � � � � � � � u v 3 3 u • v = u v cos θ � geometric interpretation u � lengths, angles � can find angle between two θ vectors v ��

  3. Dot Product Geometry � can find length of projection of u onto v u u • v = u v cos θ θ u • v v u cos θ = v u cos θ � as lines become perpendicular, u • v → 0 ��

  4. Dot Product Example � � � � u v 1 1 � � � � ( ) ( ) ( ) u • v = u ∗ v + u ∗ v + u ∗ v � � � � 2 2 1 1 1 2 3 3 � � � � � � � � u v 3 3 � � � � 6 1 � � � � 1 • 7 = ( 6 * 1 ) + ( 1 * 7 ) + ( 2 * 3 ) = 6 + 7 + 6 = 19 � � � � � � � � � � � � 2 3 ��

  5. Vector-Vector Multiplication, The Sequel � multiply: vector * vector = vector � � � � � � � cross product u v u v − u v 1 1 2 3 3 2 � � � � � � � algebraic u × v = u v − u v � � � � � � 2 2 3 1 1 3 � � � � � � � � � � � � u v − u v u v 3 3 1 2 2 1 � geometric a × b a × b = u v sin θ parallelogram a × b � b area φ perpendicular a × b � to parallelogram a ��

  6. RHS vs LHS Coordinate Systems � right-handed coordinate system convention right hand rule: z index finger x, second finger y; right thumb points up y x z = x × y � left-handed coordinate system left hand rule: index finger x, second finger y; left thumb points down x y z = x × y z ��

  7. Basis Vectors � take any two vectors that are linearly independent (nonzero and nonparallel) � can use linear combination of these to define any other vector: b c = w a + w b 1 2 c c = 2 a + 0.5 b a 0.5 b 2 a ��

  8. Orthonormal Basis Vectors � if basis vectors are orthonormal (orthogonal (mutually perpendicular) and unit length) � we have Cartesian coordinate system � familiar Pythagorean definition of distance orthonormal algebraic properties y x = y = 1 , x x • y = 0 y 5 . 0 + x 2 = c 0.5 y 2 x ��

  9. Basis Vectors and Origins � coordinate system: just basis vectors � can only specify offset: vectors � coordinate frame: basis vectors and origin � can specify location as well as offset: points p p = o + x + i y j j o i ��

  10. Working with Frames p = o + x + i y j j F 1 F 1 o p i F 1 F 1 ��

  11. Working with Frames p = o + x + i y j j F 1 F 1 o p i F 1 F p = (3,- -1) 1) p = (3, 1 ��

  12. Working with Frames p = o + x + i y j j F 1 F 1 o p i F 1 F p = (3,- -1) 1) p = (3, F 2 F j 1 2 o i F 2 F 2 ��

  13. Working with Frames p = o + x + i y j j F 1 F 1 o p i F 1 F p = (3,- -1) 1) p = (3, F 2 F j 1 2 o i F 2 F p = (- -1.5,2) 1.5,2) p = ( 2 ��

  14. Working with Frames p = o + x + i y j j F 1 F 1 o p i F 1 F p = (3,- -1) 1) p = (3, F 2 F j 1 2 o i F 2 F p = (- -1.5,2) 1.5,2) p = ( 2 j i o F 3 F F 3 F 3 3 ��

  15. Working with Frames p = o + x + i y j j F 1 F 1 o p i F 1 F p = (3,- -1) 1) p = (3, F 2 F j 1 2 o i F 2 F p = (- -1.5,2) 1.5,2) p = ( 2 j i o F 3 F F 3 F 3 p = (1,2) p = (1,2) 3 ��

  16. Named Coordinate Frames p = o + a x + b y + c z � origin and basis vectors � pick canonical frame of reference � then don’t have to store origin, basis vectors � just p = ( a , b , c ) � convention: Cartesian orthonormal one on previous slide � handy to specify others as needed � airplane nose, looking over your shoulder, ... � really common ones given names in CG � object, world, camera, screen, ... ��

  17. Lines � slope-intercept form y 0 = ) y , x ( � y = mx + b f � implicit form y=b � y – mx – b = 0 x x=a � Ax + By + C = 0 f(x,y) = y - mx - b � f(x,y) = 0 m = -b/a ��

  18. Implicit Functions � find where function is 0 f � plug in (x,y), check if � 0: on line f(x,y)=0 � < 0: inside y x � > 0: outside � analogy: terrain y f(x,y)=0 � sea level: f=0 � altitude: function value x � topo map: equal-value contours (level sets) ��

  19. Implicit Circles 2 2 2 f ( x , y ) = ( x − x ) + ( y − y ) − r � c c � circle is points (x,y) where f(x,y) = 0 2 = p = ( x , y ), c = ( x , y ) : ( p − c ) • ( p − c ) − r 0 � c c � points p on circle have property that vector from c to p dotted with itself has value r 2 2 2 p c 0 − − r = � � points points p on the circle have property that squared distance from c to p is r 2 p c 0 − − r = � � points p on circle are those a distance r from center point c ��

  20. Parametric Curves � parameter: index that changes continuously � � � � � (x,y): point on curve x g ( t ) � � = � � � t: parameter � � � � y h ( t ) � vector form p = ( t ) f � ��

  21. 2D Parametric Lines p (-1.0) � � � � x � = x 0 + t ( x 1 − x 0 ) � � � � � � � � p (-0.5) y y 0 + t ( y 1 − y 0 ) p ( t ) = p + t ( p − p ) p (0.0) � p 0 0 1 0 p (0.25) p ( t ) = o + t ( d ) � p (0.5) p 1 - p 0 � start at point p 0, p (1.0) p 1 go towards p 1 , according to parameter t p (1.5) � p (0) = p 0 , p (1) = p 1 ��

  22. Linear Interpolation � parametric line is example of general concept p ( ) = p + ( p − p ) t t � 0 1 0 � interpolation � p goes through a at t = 0 � p goes through b at t = 1 � linear � weights t , (1- t ) are linear polynomials in t ��

  23. Matrix-Matrix Addition � add: matrix + matrix = matrix � � � � � � + + m m n n n m n m 11 12 11 12 11 11 12 12 � � � � � � + = � � � � � � m m n n n + m n + m 21 22 21 22 21 21 22 22 � example � � � − � � � � − � 1 3 2 5 1 + ( − 2 ) 3 + 5 1 8 � � � � � � � � + = = � � � � � � � � 2 4 7 1 2 + 7 4 + 1 9 5 ��

  24. Scalar-Matrix Multiplication � multiply: scalar * matrix = matrix � � � � * * m m a m a m 11 12 11 12 � � � � a = � � � � m m a * m a * m 21 22 21 22 � example � � � � � � 2 4 3 * 2 3 * 4 6 12 � � � � � � 3 = = � � � � � � 1 5 3 * 1 3 * 5 3 15 ��

  25. Matrix-Matrix Multiplication � row by column � � � � � � m m n n p p 11 12 11 12 11 12 � � � � � � = � � � � � � m m n n p p 21 22 21 22 21 22 p = m n + m n 11 11 11 12 21 ��

  26. Matrix-Matrix Multiplication � row by column � � � � � � m m n n p p 11 12 11 12 11 12 � � � � � � = � � � � � � m m n n p p 21 22 21 22 21 22 p = m n + m n 11 11 11 12 21 p = m n + m n 21 21 11 22 21 ��

  27. Matrix-Matrix Multiplication � row by column � � � � � � m m n n p p 11 12 11 12 11 12 � � � � � � = � � � � � � m m n n p p 21 22 21 22 21 22 p = m n + m n 11 11 11 12 21 p = m n + m n 21 21 11 22 21 p = m n + m n 12 11 12 12 22 ��

  28. Matrix-Matrix Multiplication � row by column � � � � � � m m n n p p 11 12 11 12 11 12 � � � � � � = � � � � � � m m n n p p 21 22 21 22 21 22 p = m n + m n 11 11 11 12 21 p = m n + m n 21 21 11 22 21 p = m n + m n 12 11 12 12 22 p = m n + m n 22 21 12 22 22 ��

  29. Matrix-Matrix Multiplication � row by column � � � � � � m m n n p p 11 12 11 12 11 12 � � � � � � = � � � � � � m m n n p p 21 22 21 22 21 22 p = m n + m n 11 11 11 12 21 p = m n + m n 21 21 11 22 21 p = m n + m n 12 11 12 12 22 p = m n + m n 22 21 12 22 22 � noncommutative: AB != BA ��

  30. Matrix Multiplication � can only multiply if number of left rows = number of right cols � � � legal h i � � � � a b c � � j k � � � � e f g � � � � l m � undefined � � a b c � � � � h i � � e f g � � � � j k � � � � o p q ��

  31. Matrix-Vector Multiplication � points as column vectors: postmultiply � � � � � � x ' x m m m m 11 12 13 14 � � � � � � p' = Mp y ' y � m m m m � � � � � 21 22 23 24 = � � � � � � z ' z m m m m � � � � 31 32 33 34 � � � � � � � � h ' � � h m m m m 41 42 43 44 � points as row vectors: premultiply T � � m m m m 11 12 13 14 � � T T T m m m m � � p' = p M [ ] [ ] 21 22 23 24 x ' y ' z ' h ' = x y z h � � m m m m � � 31 32 33 34 � � � � m m m m 41 42 43 44 ��

  32. Matrices T � � � � � transpose m m m m m m m m 11 12 13 14 11 21 31 41 � � � � m m m m m m m m � � � � 21 22 23 24 12 22 32 42 = � � � � m m m m m m m m � � � � 31 32 33 34 13 23 33 43 � � � � � � � � m m m m m m m m 41 42 43 44 14 24 34 44 � � 1 0 0 0 � identity � � 0 1 0 0 � � � � 0 0 1 0 � � � � 0 0 0 1 − 1 � inverse AA = I � not all matrices are invertible ��

  33. Matrices and Linear Systems � linear system of n equations, n unknowns 3 + 7 + 2 = 4 x y z 2 x − 4 y − 3 z = − 1 5 x + 2 y + z = 1 � matrix form Ax = b � � � � � � 3 7 2 4 x � � � � � � 2 4 3 1 − − y = − � � � � � � � � � � � � � � � � � � 5 2 1 z − 1 ��

  34. Rendering Pipeline ��

  35. Reading � RB Chap. Introduction to OpenGL � RB Chap. State Management and Drawing Geometric Objects � RB Appendix Basics of GLUT � (Basics of Aux in v 1.1) ��

  36. Rendering � goal � transform computer models into images � may or may not be photo-realistic � interactive rendering � fast, but limited quality � roughly follows a fixed patterns of operations � rendering pipeline � offline rendering � ray-tracing � global illumination ��

  37. Rendering � tasks that need to be performed (in no particular order): � project all 3D geometry onto the image plane � geometric transformations � determine which primitives or parts of primitives are visible � hidden surface removal � determine which pixels a geometric primitive covers � scan conversion � compute the color of every visible surface point � lighting, shading, texture mapping ��

  38. Rendering Pipeline � what is the pipeline? � abstract model for sequence of operations to transform geometric model into digital image � abstraction of the way graphics hardware works � underlying model for application programming interfaces (APIs) that allow programming of graphics hardware � OpenGL � Direct 3D � actual implementation details of rendering pipeline will vary ��

  39. Rendering Pipeline Model/View Model/View Perspective Perspective Geometry Geometry Model/View Perspective Geometry Lighting Lighting Clipping Clipping Lighting Clipping Transform. Transform. Transform. Database Transform. Transform. Database Transform. Database Frame- - Frame Frame- Scan Scan Depth Scan Depth Depth Texturing Texturing Texturing Blending Blending Blending buffer buffer buffer Conversion Conversion Test Conversion Test Test ��

  40. Geometry Database Geometry Geometry Geometry Database Database Database � geometry database � application-specific data structure for holding geometric information � depends on specific needs of application � triangle soup, points, mesh with connectivity information, curved surface ��

  41. Model/View Transformation Model/View Model/View Geometry Geometry Model/View Geometry Transform. Transform. Database Transform. Database Database � modeling transformation � map all geometric objects from local coordinate system into world coordinates � viewing transformation � map all geometry from world coordinates into camera coordinates ��

  42. Lighting Model/View Model/View Geometry Geometry Model/View Geometry Lighting Lighting Lighting Transform. Transform. Database Transform. Database Database � lighting � compute brightness based on property of material and light position(s) � computation is performed per-vertex ��

  43. Perspective Transformation Model/View Model/View Perspective Geometry Perspective Geometry Model/View Perspective Geometry Lighting Lighting Lighting Transform. Transform. Transform. Database Transform. Transform. Database Transform. Database � perspective transformation � projecting the geometry onto the image plane � projective transformations and model/view transformations can all be expressed with 4x4 matrix operations ��

  44. Clipping Model/View Model/View Perspective Perspective Geometry Geometry Model/View Perspective Geometry Lighting Lighting Clipping Clipping Lighting Clipping Transform. Transform. Transform. Database Transform. Transform. Database Transform. Database � clipping � removal of parts of the geometry that fall outside the visible screen or window region � may require re - tessellation of geometry ���

Recommend


More recommend