diff --git a/src/Magnum/Text/DistanceFieldGlyphCacheGL.cpp b/src/Magnum/Text/DistanceFieldGlyphCacheGL.cpp index 9af4e90db..a71812a88 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCacheGL.cpp +++ b/src/Magnum/Text/DistanceFieldGlyphCacheGL.cpp @@ -89,8 +89,10 @@ GlyphCacheFeatures DistanceFieldGlyphCacheGL::doFeatures() const { void DistanceFieldGlyphCacheGL::doSetImage(const Vector2i& offset, const ImageView2D& image) { GL::Texture2D input; input.setWrapping(GL::SamplerWrapping::ClampToEdge) - .setMinificationFilter(GL::SamplerFilter::Linear) - .setMagnificationFilter(GL::SamplerFilter::Linear); + /* Use nearest filter to avoid minor rounding errors on ES2 compared to + texelFetch() on ES3+ */ + .setMinificationFilter(GL::SamplerFilter::Nearest, GL::SamplerMipmap::Base) + .setMagnificationFilter(GL::SamplerFilter::Nearest); /* The constructor already checked that the ratio is an integer multiple, so this division should lead to no information loss */ diff --git a/src/Magnum/TextureTools/DistanceFieldGL.h b/src/Magnum/TextureTools/DistanceFieldGL.h index a9daa400d..977702a6f 100644 --- a/src/Magnum/TextureTools/DistanceFieldGL.h +++ b/src/Magnum/TextureTools/DistanceFieldGL.h @@ -155,6 +155,11 @@ class MAGNUM_TEXTURETOOLS_EXPORT DistanceFieldGL { * OpenGL ES) and @p rectangle size is expected to be a multiple of 2, * as that's what the generator shader relies on for correct pixel * addressing. + * + * @attention For consistent results on implementations that don't + * support @glsl texelFetch() @ce and have rely on regular texture + * filtering it's recommended to use @ref GL::SamplerFilter::Nearest + * on the @p input. */ #ifdef DOXYGEN_GENERATING_OUTPUT void operator()(GL::Texture2D& input, GL::Framebuffer& output, const Range2Di& rectangle, const Vector2i& imageSize