Lecture05 Rasterization 1 (Triangles)

Slide

Perspective Projection

  • What’s near plane’s l,r,b,t then?
    • If explicitly specified, good
    • Sometimes people prefer: vertical field-of-view (fovY) and aspect ratio (assume symmetry i.e. l=-r, b = -t)
  • How to convert from fovY and aspect to l, r, b, t?
    • Trivial
      tan ⁡ f o v Y 2 = t ∣ n ∣ \tan{\frac{fovY}{2}}=\frac{t}{\lvert n\rvert} tan2fovY=nt
      a s p e c t = r t aspect=\frac{r}{t} aspect=tr

Canonical Cube to Screen

  • What is a screen?
    • An array of pixels
    • Size of the array: resolution
    • A typical kind of raster display
  • Raster = screen in German
    • Rasterize = drawing onto screen
  • Pixel (FYI, short of ‘picture element’)
    • For now: A pixel is a little square with uniform color
    • Color is a mixture of (red, green, blue)
  • Defining the screen space
    • Slightly different from the ‘tiger book’
    • Irrelevant to z
    • Transform in xy plane: [ − 1 , 1 ] 2 [-1,1]^2 [1,1]2 to [ 0 , width ] × [ 0 , height ] [0,\text{width}]\times[0,\text{height}] [0,width]×[0,height]
    • Viewport transform matrix:
      M v i e w p o r t = ( w i d t h 2 0 0 w i d t h 2 0 h e i g h t 2 0 h e i g h t 2 0 0 1 0 0 0 0 1 ) M_{viewport}=\begin{pmatrix}\frac{width}2&0&0&\frac{width}2\\0&\frac{height}2&0&\frac{height}2\\0&0&1&0\\0&0&0&1\end{pmatrix} Mviewport= 2width00002height0000102width2height01

Rasterization: Drawing to Raster Displays

Triangles - Fundamental Shape Primitives

Why triangles?

  • Most basic polygon
    • Break up other polygons
  • Unique properties
    • Guaranteed to be planar
    • Well-defined interior
    • Well-defined method for interpolating values at vertices over triangle (barycentric interpolation)

A Simple Approach: Sampling

Evaluating a function at a point is sampling.

We can discretize a function by sampling.

for (int x = 0; x < xmax; ++x) {
  output[x] = f(x);
}

Sampling is a core idea in graphics.

We sample time (1D), area (2D), direction (2D), volume (3D)…

  1. Rasterization = Sampling A 2D Indicator Function
for (int x = 0; x < xmax; ++x) {
  for (int y = 0; y < ymax; ++y) {
    image[x][y] = inside(tri, x + 0.5, y + 0.5); 
  }
}
  1. Evaluating inside(tri, x, y)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值