welcome
play

Welcome! INFOGR Lecture 2 Graphics Fundamentals 2 Synchronize - PowerPoint PPT Presentation

INFOGR Computer Graphics Jacco Bikker - April-July 2016 - Lecture 2: Graphics Fundamentals Welcome! INFOGR Lecture 2 Graphics Fundamentals 2 Synchronize http://www.cs.uu.nl/docs/vakken/gr Todays Agenda: The Raster


  1. INFOGR – Computer Graphics Jacco Bikker - April-July 2016 - Lecture 2: “Graphics Fundamentals” Welcome!

  2. INFOGR – Lecture 2 – “Graphics Fundamentals” 2 Synchronize http://www.cs.uu.nl/docs/vakken/gr

  3. Today’s Agenda: The Raster Display  Vector Math  Colors  2D Primitives  3D Primitives 

  4. INFOGR – Lecture 2 – “Graphics Fundamentals” 4 Raster Displays Discretization

  5. INFOGR – Lecture 2 – “Graphics Fundamentals” 5 Raster Displays Discretization Rasterization: “Converting a vector image into a raster image for output on a video display or printer or storage in a bitmap file format.” (Wikipedia)

  6. INFOGR – Lecture 2 – “Graphics Fundamentals” 6 Raster Displays Rasterization Improving rasterization: 1. Increase resolution;

  7. INFOGR – Lecture 2 – “Graphics Fundamentals” 7 Raster Displays Rasterization Improving rasterization: 1. Increase resolution; 2. Anti-aliasing; 3. Animation.

  8. INFOGR – Lecture 2 – “Graphics Fundamentals” 11 Raster Displays Discretization π =4 a 2 +b 2 = 𝑏 + 𝑐

  9. INFOGR – Lecture 2 – “Graphics Fundamentals” 12 Raster Displays CRT – Cathode Ray Tube Physical implementation – origins Electron beam zig-zagging over a fluorescent screen.

  10. INFOGR – Lecture 2 – “Graphics Fundamentals” 13 Raster Displays CRT – Cathode Ray Tube Physical implementation – consequences 0,0 y=1 x  Origin in the top-left corner of the screen  Axis system directly related to pixel count Not the coordinate system we expected… x=1 x=-1 0,0 y y=-1

  11. INFOGR – Lecture 2 – “Graphics Fundamentals” 14 Raster Displays Frame rate PAL: 25fps NTSC: 30fps (actually: 29.97) Typical laptop screen: 60Hz High-end monitors: 120-240Hz Cartoons: 12-15fps Human eye: ‘Frame - less’ Not a raster. How many fps / megapixels is ‘enough’?

  12. INFOGR – Lecture 2 – “Graphics Fundamentals” 15 Raster Displays Frame rate 0 ms 20 ms 40 ms 60 ms Frame 1 Frame 2 Frame 3 Sim 1 Sim 2 Sim 3 Input 1 Input 2 Input 3 Even 100 frames per second may result in a noticeable delay of 30ms. A very high frame rate minimizes the response time of the simulation.

  13. INFOGR – Lecture 2 – “Graphics Fundamentals” 16 Raster Displays Generating images on a raster Rendering: “The process of generating an image from a 2D or 3D model by means of a computer program.” (Wikipedia) Two main methods: 1. Ray tracing: for each pixel: what color do we assign to it? 2. Rasterization: for each triangle, which pixels does it affect?

  14. Today’s Agenda: The Raster Display  Vector Math  Colors  2D Primitives  3D Primitives 

  15. INFOGR – Lecture 2 – “Graphics Fundamentals” 18 Vector Math 2D space P x =0 width-1 P y =0 1 height-1 y=0 x=0 1 Conversion: P x = x * width P y = (1-y) * height

  16. INFOGR – Lecture 2 – “Graphics Fundamentals” 19 Vector Math 2D space 1 y=0 x=0 1 z

  17. INFOGR – Lecture 2 – “Graphics Fundamentals” 20 Vector Math Vectors The Euclidean length or In ℝ d , a vector can be defined magnitude of a vector is as an ordered d -tuple: calculated using: 𝑤 2 = 4 v 1 5 2 + 𝑤 2 2 + ⋯ + 𝑤𝑒 2 4 v 2 ǁ 𝑤ǁ = 𝑤 1 𝑤 = ... v d In 2D, this is similar to the Pythagorean theorem: A vector can also be defined by 𝑤 1 = 5 𝑏 2 + 𝑐 2 = 𝑑 2 its length and direction .

  18. INFOGR – Lecture 2 – “Graphics Fundamentals” 21 Vector Math Vectors A unit vector is a vector A vector can be normalized by with length = 1: dividing it by its magnitude: ǁ 𝑤ǁ = 1 𝑤 𝑤 𝑣𝑜𝑗𝑢 = ǁ 𝑤ǁ A null vector is a vector with length = 0, e.g.: Can we normalize every vector? 0 in ℝ 3 : 𝑤 = 0 0

  19. INFOGR – Lecture 2 – “Graphics Fundamentals” 22 Vector Math Vectors A 2D vector (𝑤 𝑦 , 𝑤 𝑧 ) can be Note: No seen as the point 𝑤 𝑦 , 𝑤 𝑧 in the Positions and vectors in ℝ 3 Cartesian plane. can be both represented by 3-tuples (𝑦, 𝑧, 𝑨) , but they are not the same! A 2D vector (𝑤 𝑦 , 𝑤 𝑧 ) can be seen as an offset from the origin . 4 1

  20. INFOGR – Lecture 2 – “Graphics Fundamentals” 23 Vector Math Vectors The sum of two vectors in ℝ d , Example: Ex 𝑤 = (𝑤 1 , 𝑤 2 , . . , 𝑤 𝑒 ) and (4,1) + (1,2) = (5,3) 𝑥 = (𝑥 1 , 𝑥 2 , . . , 𝑥 𝑒 ) 1 2 Vector subtraction is is defined as: 5 similarly defined. 3 𝑤 + 𝑥 = 4 (𝑤 1 + 𝑥 1 , 𝑤 2 + 𝑥 2 , … , 𝑤 𝑒 + 𝑥 𝑒 ) 1 Vector addition is commutative (as can be easily seen from the geometric interpretation): (4,1) + (1,2) = (5,3) = (1,2) + (4,1).

  21. INFOGR – Lecture 2 – “Graphics Fundamentals” 24 Vector Math Vectors The scalar multiple of a d- Two vectors 𝑤 and 𝑥 are dimensional vector 𝑤 is parallel if one is a scalar defined as: multiple of the other, i.e.: λ 𝑤 = (𝜇𝑤 1 , 𝜇𝑤 2 , . . , 𝜇𝑤 𝑒 ) there is a λ such that 𝑤 = λ𝑥 . Scalar multiplication can change the length of a vector. It can also change the direction of the vector, which is reversed if λ < 0.

  22. INFOGR – Lecture 2 – “Graphics Fundamentals” 25 Vector Math Vectors Parallel vectors are called In ℝ 2 , we can easily create a linearly dependent. normal vector for (𝑤 𝑦 , 𝑤 𝑧 ) : If they are not parallel, vectors 𝑜 = ( −𝑤 𝑧 , 𝑤 𝑦 ) are linearly independent . or A special case is when two vectors are perpendicular to 𝑜 = ( 𝑤 𝑧 , −𝑤 𝑦 ) each other; in this case, each vector is a normal vector of the Question: does this also work in ℝ 3 ? other.

  23. INFOGR – Lecture 2 – “Graphics Fundamentals” 26 Vector Math Bases We can use two linearly independent vectors to produce any vector: 𝑤 𝑤 𝑏 = λ 1 𝑣 + λ 2 𝑤 𝑏 This doesn’t just work for perpendicular vectors. 𝑣 𝑣

  24. INFOGR – Lecture 2 – “Graphics Fundamentals” 27 Vector Math Bases We can use two linearly independent vectors to produce any vector: 𝑏 = λ 1 𝑣 + λ 2 𝑤 This doesn’t just work for perpendicular vectors. Any pair of linearly This extends naturally to independent vectors form a higher dimensions. 2D basis .

  25. INFOGR – Lecture 2 – “Graphics Fundamentals” 28 Vector Math Bases “Any pair of linearly independent 1. The vectors are vectors form a 2D basis”: perpendicular to each other; The Cartesian coordinate system is 2. The vectors are unit vectors. an example of this. In this case the vectors (1,0) and (0,1) form an orthonormal basis:

  26. INFOGR – Lecture 2 – “Graphics Fundamentals” 29 Vector Math Bases y y z A coordinate system can be left handed or right handed. x x Note that this only affects the z interpretation of the vectors; the vectors themselves are the same in each case.

  27. INFOGR – Lecture 2 – “Graphics Fundamentals” 30 Vector Math Dot product Given vectors 𝑏 , 𝑣 and 𝑤 , we The dot product of vector know that: 𝑤 and 𝑥 is defined as: 𝑤 𝑏 = λ 1 𝑣 + λ 2 𝑤 𝑤 ∙ 𝑥 = 𝑤 1 𝑥 1 + 𝑤 2 𝑥 2 + ⋯ + 𝑤 𝑒 𝑥 𝑒 or We can determine λ 1 and λ 2 d using the dot product*. Σ 𝑤 ∙ 𝑥 = 𝑤 𝑗 𝑥 𝑗 𝑏 i=0 𝑣 *: AKA inner product or scalar product

  28. INFOGR – Lecture 2 – “Graphics Fundamentals” 31 Vector Math Dot product 𝑤 The dot product projects one Projecting a vector on two vector on another. linearly independent vectors yields a coordinate If 𝑏 and 𝑣 are unit vectors, we within the 2D basis. 𝑏 𝜇 2 can calculate the angle between them using the dot product: α 𝑣 λ = cos ∝ = 𝑣 ∙ 𝑏 𝜇 𝜇 1 or, if they are not normalized: This works regardless of the direction and scale 𝑣 ∙ 𝑏 of 𝑣 and 𝑤 , and also in ℝ 3 . cos ∝ = ǁ𝑣ǁ ǁ 𝑏ǁ

  29. INFOGR – Lecture 2 – “Graphics Fundamentals” 32 2D Transforms 𝑤 × 𝑥 Cross product The cross product can be used to calculate a vector perpendicular to a 2D basis formed by 2 vectors. It is defined as: 𝑤 𝑤 2 𝑥 3 – 𝑤 3 𝑥 2 𝑤 × 𝑥 = 𝑤 3 𝑥 1 – 𝑤 1 𝑥 3 𝑥 𝑤 1 𝑥 2 – 𝑤 2 𝑥 1 y Note: The cross product is only defined x in ℝ 3 . z

  30. INFOGR – Lecture 2 – “Graphics Fundamentals” 2D Transforms

  31. INFOGR – Lecture 2 – “Graphics Fundamentals” 2D Transforms

  32. INFOGR – Lecture 2 – “Graphics Fundamentals” 2D Transforms

  33. Today’s Agenda: The Raster Display  Vector Math  Colors  2D Primitives  3D Primitives 

  34. INFOGR – Lecture 2 – “Graphics Fundamentals” 37 Colors Color representation Computer screens emit light in three colors: red, green and blue. By additively mixing these, we can produce most colors: from black (red, green and blue turned off) to white (red, green and blue at full brightness). In computer graphics, colors are stored in discrete form. This has implications for:  Color resolution (i.e., number of unique values per component);  Maximum brightness (i.e., range of component values).

Recommend


More recommend