Sharp Bilinear Filters: Big Clean Pixels for Pixel Art
a day ago
- #Shader Programming
- #Pixel Art
- #OpenGL
- The article discusses the implementation of sharp bilinear filtering in OpenGL to improve the scaling of pixel art without introducing unwanted artifacts.
- It explains the issues with traditional bilinear filtering, such as blurriness when scaling down textures, and introduces the concept of sharp bilinear filtering as a solution.
- The author references several sources that inspired the implementation, including blog posts by Cole Cecil and Algorithmic Pensieve, which provide shader-based solutions for pixel art scaling.
- Detailed mathematical derivation is provided for the sharp bilinear filtering technique, explaining how to blend texels only at the borders to maintain sharpness.
- The article includes code snippets for both OpenGL 3.2 and OpenGL 2.1, showing how to implement the shaders for sharp bilinear filtering.
- It mentions the use of GLSL functions like `dFdx()`, `dFdy()`, and `fwidth()` to handle texture coordinates and blending dynamically.
- The author highlights the importance of updating texture wrap parameters to `GL_CLAMP_TO_EDGE` to avoid artifacts when scaling beyond texture boundaries.
- The technique is not limited to simple textured rectangles but can be applied to any textured graphical primitive, including rotated or 3D-projected textures.