05-Rasterization

76 阅读1分钟

Perspective Projection

field-of-view and aspect ratio

Snipaste_2024-02-20_11-31-02.png
由fovY和距离、高度之间相互换算

Snipaste_2024-02-20_11-34-53.png

Canonical cube to screen

1. What's a screen ?

  • An array of pixels
  • Size of the array : resolution(分辨率)
  • A typical kind of raster display

2. Raster==screen in German

  • Rasterize==drawing on the screen

3. Pixel

  • A pixel is a square with uniform color
  • color is a mixture of red,green and blue

Defining the screen space

Snipaste_2024-02-20_11-45-39.png indeces are from (0,0)(0,0) to(width1,height1)(width-1, height-1)

Transform

Snipaste_2024-02-20_13-14-55.png

  1. Irrelevant to z
  2. Transform in xy plane
  3. Viewport transform matrix:

Snipase_2024-02-20_13-14-19.png

Rasterization:

Triangles-Fundamental Shape Primitives

Why triangles?

  • Basic polygen
  • Break up other polygens
  • Guaranteed to planar
  • Well defined for interpolating

Sampling

Evaluating a function at a point is sampling.
We can discretize a function by sampling.

Define Binary Function

Snipaste_2024-02-20_14-52-11.png

for(int x=0; x< x_max;x++)
    for(int y=0; y< y_max; y++ )
        inside(triangle , x+0.5 , y+0.5 )

Using a Bounding Box

No need to check all pixels Snipaste_2024-02-20_14-57-52.png

Incremental Triangle Traversal

suitable for thin and rotated triangles

Snipaste_2024-02-20_15-01-06.png