05 · Texture mapping

A floor made of just two triangles, textured. Change the filter to see aliasing and mipmaps; switch interpolation to see why texture coordinates must be interpolated perspective-correctly. Companion to notes/08.

How the affine mode works

A GPU always interpolates vertex-shader outputs perspective-correctly: it interpolates a/w and 1/w linearly on screen and divides. To show what plain screen-space interpolation looks like, the vertex shader outputs uv·w and w, and the fragment shader divides one by the other. The GPU's correction and ours cancel out, leaving the affine result and its kink along the triangles' shared diagonal.