Bicubic Texture Interpolation using Linear Filtering

This notebook shows how to implement bicubic texture filtering in GLSL using just four linearly-filtered texture samples. The technique is described in GPU Gems 2, Chapter 20 and implemented based on this Stack Overflow answer. The function works as a drop-in replacement for texture2D(), requiring only an additional vec2 texture size parameter since WebGL 1 lacks the textureSize() function.

The default B-spline basis produces smooth continuity but doesn’t pass through the control points, which can make the result look slightly blurry. The Catmull-Rom basis does pass through control points but requires 16 texture fetches from nearest-neighbor filtering. Try “Grayscale random” with “Contours” enabled to see how bicubic interpolation achieves smooth continuity compared to linear interpolation’s C⁰ continuity.

This notebook also includes implementations of linear filtering from nearest-neighbor samples (4 fetches) and bicubic filtering from nearest-neighbor samples (16 fetches) for comparison.