up to Schedule & Notes

Texture Lookup

A texture unit is given floating point coordinates and returns a value. There are three principal methods of computing the return value.

In what follows,

Then $(\hat{s},\hat{t})$ are in $[0,c-1] \times [0,r-1]$ and are the texel coordinates in the 2D texture array of size $c \times r$.

When reading the texture array at $M[\hat{s},\hat{t}]$, the coordinates are taken modulo $c$ and modulo $r$ so that they are always inside the array. This has the effect of "wrapping the coordinates around" when they go out of bounds.

Nearest Lookup

Given $(s,t)$, this method return the array texel whose centre is closest to $(\hat{s},\hat{t})$, that is:

$M[ \; \textrm{round}(\hat{s}), \; \textrm{round}(\hat{t}) \; ]$

Bilinear Interpolation

Given $(s,t)$, this method takes a weighted average of the four array texels closest to $(\hat{s},\hat{t})$.

The weights are determined by placing a texel-sized square at $(\hat{s},\hat{t})$, then weighting each of the four texels in proportion to the amount of overlap it has with the square.

For coordinates $(\hat{s},\hat{t})$, let

Then the weighted average is

$\begin{array}{rccl} & (1-\alpha) & (1-\beta) & M[S,T] \\ + & (1-\alpha) & \beta & M[S,T+1] \\ + & \alpha & (1-\beta) & M[S+1,T] \\ + & \alpha & \beta & M[S+1,T+1] \end{array}$

up to Schedule & Notes