rasterization
play

Rasterization CS 148: Summer 2016 Introduction of Graphics and - PowerPoint PPT Presentation

Rasterization CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain http://iloveshaders.blogspot.com/2011/05/how-rasterization-process-works.html Render [ren-der]: The process of generating an image from a description of a


  1. Rasterization CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain http://iloveshaders.blogspot.com/2011/05/how-rasterization-process-works.html

  2. Render [ren-der]: The process of generating an image from a description of a scene by means of a computer program https://en.wikipedia.org/wiki/Rendering_(computer_graphics) 2 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  3. Two Ways to Render an Image 3 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  4. Two Ways to Render an Image Projection: 3D description to 2D description 4 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  5. Two Ways to Render an Image Rasterization http://iloveshaders.blogspot.com/2011/05/how-rasterization-process-works.html 5 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  6. Two Ways to Render an Image Raytracing http://upload.wikimedia.org/wikipedia/commons/8/83/Ray_trace_diagram.svg 6 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  7. Rasterization 7 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  8. Rasterize [rastərʌɪz]: Rasterize [rastərʌɪz] : To convert vector data to raster – pixel or dot – format. To convert vector data to raster format. 8 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  9. Rasterization Process “A triangle is here, a circle “This pixel is yellow…” is there, …” 9 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  10. Scan Conversion Figuring out which pixels to shade. 10 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  11. The Basics: Framebuffer 11 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  12. The Basics: Framebuffer Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel Pixel 12 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  13. Framebuffer Coordinates + y Pixel Center (2,1) (1,1) (0,0) + x 13 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  14. Problem + y + x 14 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  15. The Basics: Scan Conversion + y + x 15 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  16. The Basics: Scan Conversion + y + x 16 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  17. Convention + y Must intersect diamond + x 17 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  18. Convention + y Must intersect diamond + x 18 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  19. Desirable Properties • Fast • Simple • Integer arithmetic 19 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  20. Bresenham’s Algorithm • Introduced in 1967 • Best-fit approximation under some conditions 20 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  21. Bresenham’s Algorithm • Introduced in 1967 Variation by Pitteway (1967) “Midpoint Algorithm” • Best-fit approximation under some conditions 21 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  22. Bresenham’s Algorithm • Equation of a line 22 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  23. Bresenham’s Algorithm • Equation of a line Assumption: 23 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  24. Bresenham’s Algorithm • Equation of a line Assumption: Easy fix via rotation/reflection 24 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  25. Bresenham’s Algorithm Stategy Every step: increment x • Keep track of “error” ϵ • At every step accumulate • 𝜗 ← 𝜗 + 𝑛 • ' If 𝜗 ≥ • ( Increment y • Reset 𝜗 ← 𝜗 + 𝑛 − 1 • Start with 𝜗 = 𝑛 𝜗 • 1 25 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  26. Bresenham’s Algorithm Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝜗 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 + 𝒏 − 𝟐 else 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 1 26 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  27. Bresenham’s Algorithm Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝜗 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 + 𝒏 − 𝟐 else 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 1 27 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  28. Bresenham’s Algorithm Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝜗 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 1 28 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  29. Bresenham’s Algorithm Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝜗 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 (𝑦0,𝑧0) 𝒚 ← 𝒚 + 𝟐 𝑦,𝑧 29 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  30. Bresenham’s Algorithm Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝑦,𝑧 𝜗 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 (𝑦0,𝑧0) 𝒚 ← 𝒚 + 𝟐 30 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  31. Bresenham’s Algorithm Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝑦,𝑧 𝜗 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 (𝑦0,𝑧0) 𝒚 ← 𝒚 + 𝟐 31 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  32. Bresenham’s Algorithm 𝜗 Algorithm line( 𝒚𝟏, 𝒛𝟏,𝒚𝟐, 𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝑦,𝑧 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) if 𝝑 > 𝟐 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 (𝑦0,𝑧0) 𝒚 ← 𝒚 + 𝟐 32 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  33. Bresenham’s Algorithm line( 𝒚𝟏, 𝒛𝟏, 𝒚𝟐,𝒛𝟐 ) 𝒚 ← 𝒚𝟏 𝐳 ← 𝒛𝟏 𝝑 = 𝒏 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) 𝟐 if 𝝑 > 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 33 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  34. Bresenham’s Algorithm line( 𝒚𝟏, 𝒛𝟏, 𝒚𝟐,𝒛𝟐 ) => 𝜗 = 𝑛 = 𝒚 ← 𝒚𝟏 =? ⇒ Δ𝑦 𝜗 = Δ𝑧 𝐳 ← 𝒛𝟏 ⇒ 2Δ𝑦 𝜗 = 2Δ𝑧 𝝑 = 𝒏 Use 𝑒 = 2Δ𝑦 𝜗 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) 𝟐 if 𝝑 > 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 34 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  35. Bresenham’s Algorithm line( 𝒚𝟏, 𝒛𝟏, 𝒚𝟐,𝒛𝟐 ) => 𝜗 = 𝑛 = 𝒚 ← 𝒚𝟏 =? ⇒ Δ𝑦 𝜗 = Δ𝑧 𝐳 ← 𝒛𝟏 ⇒ 2Δ𝑦 𝜗 = 2Δ𝑧 𝒆 = 𝟑𝚬𝐳 Use 𝑒 = 2Δ𝑦 𝜗 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) 𝟐 if 𝝑 > 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 35 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  36. Bresenham’s Algorithm line( 𝒚𝟏, 𝒛𝟏, 𝒚𝟐,𝒛𝟐 ) ' 𝜗 > 𝒚 ← 𝒚𝟏 ( ⇒ 2Δ𝑦 𝜗 > Δx 𝐳 ← 𝒛𝟏 ⇒ 𝑒 > Δ𝑦 𝒆 = 𝟑𝚬𝐳 while 𝒚 < 𝒚𝟐 pixel( 𝒚, 𝒛 ) 𝟐 if 𝝑 > 𝟑 𝒛 ← 𝒛 + 𝟐 𝝑 ← 𝝑 − 𝟐 𝝑 ← 𝝑 + 𝒏 𝒚 ← 𝒚 + 𝟐 36 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

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