Processing math: 100%
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 (ˆs,ˆt) are in [0,c1]×[0,r1] and are the texel coordinates in the 2D texture array of size c×r.

When reading the texture array at M[ˆs,ˆ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 (ˆs,ˆt), that is:

M[round(ˆs),round(ˆt)]

Bilinear Interpolation

Given (s,t), this method takes a weighted average of the four array texels closest to (ˆs,ˆt).

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

For coordinates (ˆs,ˆt), let

Then the weighted average is

(1α)(1β)M[S,T]+(1α)βM[S,T+1]+α(1β)M[S+1,T]+αβM[S+1,T+1]

up to Schedule & Notes