Forward Scattering - The Weblog of Nicholas Chapman
The weblog of Nicholas Chapman
Using a a single linearly interpolated sample to evaluate a weighted sum of two texels<br>Posted 13 Aug 2026
f(floor(x))<br>|-- f(x) f(floor(x)+1)<br>| \--*---|<br>| |<br>floor(x) ^ floor(x) + 1
Bilinear sampling at point x in gives
f_bilinear(x) = f(floor(x))(1 - alpha) + f(floor(x)+1) alpha
where alpha = x - floor(x)<br>e.g.<br>f_bilinear(x) = f(floor(x))(1 - (x - floor(x))) + f(floor(x) + 1) (x - floor(x))<br>= f(floor(x))(1 - x + floor(x)) + f(floor(x) + 1) (x - floor(x))
Suppose we want to evaluate<br>v = a f(x_0) + b f(x_0+1)
for some x_0, a, b.
Consider<br>C f_bilinear(x)<br>= C f(floor(x))(1 - x + floor(x)) + f(floor(x) + 1) (x - floor(x))
= f(floor(x))(C - C.x + C.floor(x)) + f(floor(x) + 1) (C.x - C.floor(x))
defining x_0 = floor(x):
= f(x_0)(C - C.x + C.x_0) + f(x_0 + 1) (C.x - C.x_0)
= f(x_0)(C - C.x + C.x_0) + f(x_0 + 1) (C.x - C.x_0)
= (C - C.x + C.x_0) f(x_0) + (C.x - C.x_0) f(x_0 + 1)
So for this to equal v = a f(x_0) + b f(x_0+1), we want
a = C - C x + C x_0<br>and<br>b = C x - C x_0
but<br>a + b<br>= C - C x + C x_0 + C x - C x_0<br>= C
consider
b = C x - C x_0<br>C x = b + C x_0<br>x = (b + C x_0)/C
x = (b + (a + b)x_0)/(a + b)<br>x = b/(a + b) + (a + b)x_0/(a + b)<br>x = b/(a + b) + x_0
alternatively:<br>x = b/(a + b) + (a + b)x_0/(a + b)<br>= (b + (a + b)x_0) / (a + b)
So we have
a f(x_0) + b f(x_0+1) = (a + b) f_bilinear(b/(a + b) + x_0)
Checking:
(a + b) f_bilinear(b/(a + b) + x_0) =
[if a >= 0 and b >= 0, then b/(a + b) 0 or b > 0, then (a + b) > 0, so b/(a + b) is defined and b/(a + b) > 0.]<br>[also since it is
Do you have a comment or feedback about this blog post? Please email me.<br>All content by Nicholas Chapman.
Pages
Intuitive Quantum Electrodynamics<br>Second Quantisation - a Quantisation Too Far<br>Kolmogorov complexity
Social media
Twitter / X
GitHub
YouTube
Flickr
Our software
Substrata
Indigo Renderer
Chaotica
Winter
Other blogs
CBloom rants
Conor Stokes blog
Random ASCII
Embedded in Academia
Preshing on Programming
Algorithmic Assertions
Nathan Reed's blog
The ryg blog
Bits, pixels, cycles and more (by Arseny K.)
Bart Wronski's blog
Hidden Grove
Aras P's blog
Neugierig.org: Tech Notes
nigeltao.github.io
Art, Tech and other Nonsense (by Max Liani)
Jason Booth's blog
The Danger Zone
Graphics Programming weekly
The blog at the bottom of the sea