Skip to content

Instantly share code, notes, and snippets.

@syoyo
Created October 9, 2015 15:03
Show Gist options
  • Save syoyo/44620be1c77195bc736e to your computer and use it in GitHub Desktop.
Save syoyo/44620be1c77195bc736e to your computer and use it in GitHub Desktop.
Bilinear interpolation of alpha value
// Simple Bilinear interpolation(e.g. texture filtering)
// w0 + w1 + w2 + w3 = 1.0f;
// a[0] ~ a[3] = alpha value of 2x2 pixels.
float ret = w0 * a[0] + w1 * a[1] + w2 * a[2] + w3 * a[3];
// Sometimes ret become 0x3ffffff if all a's are 1.0f(0x3f800000) due to numerical error?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment