Lecture_006_Perspective_Projection_and_Texture_Mapping

Transformations

Transformation of Coordinate System

Transformation of Coordinate System

Transformation on camera is the same as transformation on all triangles

Clipping

View Frustum: a near and a far plane

View Frustum: a near and a far plane

Clipping: eliminating triangles not in view frustum to save rasterizing primitives

Clipping Half Overlapped Triangles by Splitting Shape to Triangles

Clipping Half Overlapped Triangles by Splitting Shape to Triangles

Why near/far clipping planes?

Z-Fighting Effect is Larger with no Enough Precision in Depth Buffer (don't set near, far plane too big)

Z-Fighting Effect is Larger with no Enough Precision in Depth Buffer (don't set near, far plane too big)

Non-Perspective Frustum Transformation: it is not perspective because it warpped space that aligns to camera's perspective

Non-Perspective Frustum Transformation: it is not perspective because it warpped space that aligns to camera's perspective

To again get perspective: copy z to w in homogeneous coordinate.

Full Perspective Matrix: takes view frustum and projection into account

Full Perspective Matrix: takes view frustum and projection into account

Screen Transformation

Translate 2D viewing plane to pixel coordinates

  1. reflect about x-axis
  2. translate by (1, 1)
  3. scale by (W / 2, H / 2)

Color Interpolation

Color Interpolation: we want to use vertex color to interpolate color inside triangle

Color Interpolation: we want to use vertex color to interpolate color inside triangle

Linear interpolation in 1D

Linear interpolation in 1D

Linear interpolation in 1D is Linear Combination of Two Functions

Linear interpolation in 1D is Linear Combination of Two Functions

In 1D: since we have equation \hat{f}(t) = (1 - t)f_i + tf_j, we can think of this as a linear combination of two functions.

Linear interpolation in 2D

Linear interpolation in 2D

Linear Interpolation in 2D:

\begin{bmatrix} a\\ b\\ c\\ \end{bmatrix} = \frac{1}{(x_y_i - x_iy_j)+(x_ky_j - x_jy_k)+(x_iy_k - x_ky_i)} \begin{bmatrix} f_i(y_k - y_j) + f_j(y_i - y_k) + f_k(y_j - y_i)\\ f_i(x_j - x_k) + f_j(x_k - x_i) + f_k(x_i - x_j)\\ f_i(x_ky_j - x_jy_k) + f_j(x_iy_k - x_ky_i) + f_k(x_jy_i - x_iy_j)\\ \end{bmatrix}

Linear interpolation in 2D is Linear Combination of Three Functions

Linear interpolation in 2D is Linear Combination of Three Functions

These picture describes the same as above complicated function.

Interpolate based on the three triangular area creased by a point in triangle

Interpolate based on the three triangular area creased by a point in triangle

Barycentric Coordinates: \phi_i(x), \phi_j(x), \phi_k(x)

Triangular Half-plane Test

Triangular Half-plane Test

We should not interpolate in screen space, but in 3D space. How to solve this problem?

We should not interpolate in screen space, but in 3D space. How to solve this problem?

Perspective Incorrect Interpolation: compute barycentric coordinates using 2D coordinates leads to derivative discontinuity

Perspective Incorrect Interpolation: compute barycentric coordinates using 2D coordinates leads to derivative discontinuity

Perspective Correct Interpolation: we interpolate attribute \phi

  1. compute depth z at each vertex
  2. interpolate \frac{1}{z} and \frac{\phi}{z} using 2D barycentric coordinates to give perspective
  3. divide interpolated \frac{\phi}{z} by interpolated \frac{1}{z}

normal map and displacement map

normal map and displacement map

Texture Mapping

Texture Mapping

Texture Coordinates

Texture Coordinates

Periodic Texture Coordinates

Periodic Texture Coordinates

Given a model with UV:

Sampled Texture Space might be warpped, it is hard to avoid aliasing

Sampled Texture Space might be warpped, it is hard to avoid aliasing

Solution to Magnification

Solution to Magnification

Magnification: camera too close to object

Aliasing due to minification

Aliasing due to minification

Ideal minification result

Ideal minification result

Minification: camera too far to object

Mip Map

Mip Map: a specific prefiltering technique

MIP map (L.Williams 83) store prefiltered image at every possible scale

MIP map (L.Williams 83) store prefiltered image at every possible scale

MIP map storage cost is low

MIP map storage cost is low

Calculating MIP Map Level by estimating region cover using partial derivative

Calculating MIP Map Level by estimating region cover using partial derivative

Different MIP Map Levels

Different MIP Map Levels

MIP Map all level 1

MIP Map all level 1

MIP Map all level 4

MIP Map all level 4

But we don't want jumps between MIP Map levels

But we don't want jumps between MIP Map levels

MIP Map blending

MIP Map blending

Tri-linear Interpolation: interpolation after interpolation

Tri-linear Interpolation: interpolation after interpolation

Isotropic Filtering (Trilinear) vs. Anisotropic Filtering

Isotropic Filtering (Trilinear) vs. Anisotropic Filtering

Pipeline:

  1. from screen space (x, y) to barycentric coordinates
  2. using barycentric coordinates to interpolate (u, v) stored in vertices
  3. approximate \frac{du}{dx}, \frac{du}{dy}, \frac{dv}{dx}, \frac{dv}{dy} by taking differences of screen-adjacent samples and compute mip map level d
  4. convert normalized texture coordinate (u, v) \in [0, 1] to pixel locations in texture image (U, V) \in [W, H].
  5. determine address of pixels for filter (8 neighbors for trilinear)
  6. Load texels into local registers
  7. tri-linear interpolation according to (U, V, d)
  8. maybe anisotropic filtering

Table of Content