rasterization - students.cs.ubc.cacs-314/vsep2020/... · rasterization © 2020 enrique rosales the...

33
Rasterization Computer Graphics © 2020 Enrique Rosales

Upload: others

Post on 26-Jan-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

  • Rasterization

    Computer Graphics

    © 2020 Enrique Rosales

  • Rasterization

    © 2020 Enrique Rosales

    The Rasterization stage generates the fragments of each triangle and assigns their interpolated values.

    Continuous Discrete

  • Rasterization

    © 2020 Enrique Rosales

    The first step is to define which pixels are inside the triangle.

  • Rasterization

    © 2020 Enrique Rosales

    One option could be to check all pixels to see if they are inside the triangle.

    ?

  • Rasterization

    © 2020 Enrique Rosales

    One option could be to check all pixels to see if there are inside the triangle.

    That would be a bad idea in the case

    of having a small triangle inside a huge screen space.

  • Rasterization

    © 2020 Enrique Rosales

    Another option could be to compute a

    bounding box first to test only the pixels inside the box.

  • Rasterization

    © 2020 Enrique Rosales

    Another option could be to compute a

    bounding box first to test only the pixels inside the box.

    Also a bad idea in a case like this.

  • Rasterization

    © 2020 Enrique Rosales

    The solution is an algorithm called “Scan-Line Fill” or “Scan Conversion”

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    We first split the triangle with a horizontal lines.

    1

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    We get four edges, that are called “edge trackers.”

    𝑒𝑑𝑔𝑒 𝑡𝑟𝑎𝑐𝑘𝑒𝑟𝑠

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    For each edge tracker, we compute its intersection with each row of pixels.

    2𝑒𝑑𝑔𝑒 1

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    For each edge tracker, we compute its intersection with each row of pixels.

    2

    𝑒𝑑𝑔𝑒 2

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    For each edge tracker, we compute its intersection with each row of pixels.

    2

    𝑒𝑑𝑔𝑒 3

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    For each edge tracker, we compute its intersection with each row of pixels.

    2𝑒𝑑𝑔𝑒 4

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    We get a set of pixels ordered by the edge trackers.

    2

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    We sort the pixels by scan line (row) and increasing x-coordinate.

    3

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    Fill the span between pairs of intersections.

    4

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    Final result

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    We can do the same to an entire set of triangles.

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    This is also called “Trapezoid splitting”

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    This is also called “Trapezoid splitting”

    https://patents.google.com/patent/US20040257607

    Sadhana Gupta et al.

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    However, this is good for large triangles but not so fast for high-density meshes.

    https://patents.google.com/patent/US20040257607

    Sadhana Gupta et al.

  • Scan-Line algorithm

    © 2020 Enrique Rosales

    However, this is good for large triangles but not so fast for high-density meshes.

    https://tinyurl.com/y4gne4teMust see:

    This method is not as relevant anymore, its an old school method.

    The “edge walking” is still interesting

  • Modern Solution

    © 2020 Enrique Rosales

    ?

  • Modern Solution

    © 2020 Enrique Rosales

    Modern GPUs (2020) use edge equations.

  • Modern Solution

    © 2020 Enrique Rosales

    The problem is parallelized by rasterizing a coarse resolution first.

  • Modern Solution

    © 2020 Enrique Rosales

    The problem is parallelized by rasterizing a coarse resolution first.

  • Modern Solution

    © 2020 Enrique Rosales

    Then, incrementing the resolution from the sections that survive.

  • Modern Solution

    © 2020 Enrique Rosales

    Then, incrementing the resolution from the sections that survive.

  • Modern Solution

    © 2020 Enrique Rosales

    Then, incrementing the resolution from the sections that survive.

  • Modern Solution

    © 2020 Enrique Rosales

    Until we have the final result.

  • Computer Graphics

    © 2020 Enrique Rosales

    Algorithms evolve depending on hardware, trends, and other factors.

    There is no such thing as a dead algorithm.

    They can always come back.

  • Thanks

    © 2020 Enrique Rosales

    Composite Transformations