diff --git a/engine/src/flutter/impeller/compiler/shader_lib/impeller/constants.glsl b/engine/src/flutter/impeller/compiler/shader_lib/impeller/constants.glsl index 1c8afc3aa4..ccb73b5df9 100644 --- a/engine/src/flutter/impeller/compiler/shader_lib/impeller/constants.glsl +++ b/engine/src/flutter/impeller/compiler/shader_lib/impeller/constants.glsl @@ -24,8 +24,11 @@ const float kHalfSqrtTwo = 0.70710678118; // sqrt(3) const float kSqrtThree = 1.73205080757; +// The default mip bias to use when sampling textures. +// This value biases towards sampling from a lower mip level (bigger size), +// which results in sharper looking images when mip sampling is enabled. This is +// the same constant that Skia uses. const float kDefaultMipBias = -0.475; - const float kDefaultMipBiasHalf = -0.475hf; #endif diff --git a/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl b/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl index 1a504d16d3..56be817085 100644 --- a/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl +++ b/engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl @@ -15,6 +15,9 @@ /// If `y_coord_scale` < 0.0, the Y coordinate is flipped. This is useful /// for Impeller graphics backends that use a flipped framebuffer coordinate /// space. +/// +/// A negative mip bias is applied to improve the sharpness of scaled down +/// images when mip sampling is enabled. See `kDefaultMipBias` for more detail. vec4 IPSample(sampler2D texture_sampler, vec2 coords, float y_coord_scale) { return texture(texture_sampler, IPRemapCoords(coords, y_coord_scale), kDefaultMipBias);