diff --git a/src/core/settings.js b/src/core/settings.js index 9fa4f8f..9c89d57 100644 --- a/src/core/settings.js +++ b/src/core/settings.js @@ -37,6 +37,22 @@ MIPMAP_TEXTURES: true, /** + * This bias will be added to the mipmap LOD calculation, as well as the bias provided by + * one of the texture sampling functions in GLSL. This LOD calculation is used to select + * the mipmap level or pair of mipmap levels to sample from. A positive bias means that + * larger mipmaps will be selected even when the texture is viewed from farther away. + * This can cause visual aliasing, but in small quantities it can make textures a bit + * more sharp. + * See {@link https://www.khronos.org/opengl/wiki/Sampler_Object#LOD_bias} for more info + * + * @static + * @memberof PIXI.settings + * @type {number} + * @default 0 + */ + MIPMAP_LOD_BIAS: 0, + + /** * Default resolution / device pixel ratio of the renderer. * * @static diff --git a/src/core/settings.js b/src/core/settings.js index 9fa4f8f..9c89d57 100644 --- a/src/core/settings.js +++ b/src/core/settings.js @@ -37,6 +37,22 @@ MIPMAP_TEXTURES: true, /** + * This bias will be added to the mipmap LOD calculation, as well as the bias provided by + * one of the texture sampling functions in GLSL. This LOD calculation is used to select + * the mipmap level or pair of mipmap levels to sample from. A positive bias means that + * larger mipmaps will be selected even when the texture is viewed from farther away. + * This can cause visual aliasing, but in small quantities it can make textures a bit + * more sharp. + * See {@link https://www.khronos.org/opengl/wiki/Sampler_Object#LOD_bias} for more info + * + * @static + * @memberof PIXI.settings + * @type {number} + * @default 0 + */ + MIPMAP_LOD_BIAS: 0, + + /** * Default resolution / device pixel ratio of the renderer. * * @static diff --git a/src/core/sprites/webgl/generateMultiTextureShader.js b/src/core/sprites/webgl/generateMultiTextureShader.js index b5e067a..f25bec7 100644 --- a/src/core/sprites/webgl/generateMultiTextureShader.js +++ b/src/core/sprites/webgl/generateMultiTextureShader.js @@ -1,6 +1,7 @@ import Shader from '../../Shader'; import { readFileSync } from 'fs'; import { join } from 'path'; +import settings from '../../settings'; const fragTemplate = [ 'varying vec2 vTextureCoord;', @@ -59,7 +60,7 @@ } src += '\n{'; - src += `\n\tcolor = texture2D(uSamplers[${i}], vTextureCoord);`; + src += `\n\tcolor = texture2D(uSamplers[${i}], vTextureCoord, ${settings.MIPMAP_LOD_BIAS});`; src += '\n}'; }