Added setGlowQuality function

This commit is contained in:
Richard Davey 2023-02-27 13:47:33 +00:00
parent 1b31ec12c1
commit 7edc856154

View file

@ -169,5 +169,38 @@ module.exports = {
fragmentShaderSource = fragmentShaderSource.replace(/%count%/gi, maxTextures.toString()); fragmentShaderSource = fragmentShaderSource.replace(/%count%/gi, maxTextures.toString());
return fragmentShaderSource.replace(/%forloop%/gi, src); return fragmentShaderSource.replace(/%forloop%/gi, src);
},
/**
* Takes the Glow FX Shader source and parses out the __SIZE__ and __DIST__
* consts with the configuration values.
*
* @function Phaser.Renderer.WebGL.Utils.setGlowQuality
* @since 3.60.0
*
* @param {string} shader - The Fragment Shader source code to operate on.
* @param {Phaser.Game} game - The Phaser Game instance.
* @param {number} [quality] - The quality of the glow (defaults to 0.1)
* @param {number} [distance] - The distance of the glow (defaults to 10)
*
* @return {string} The modified Fragment Shader source.
*/
setGlowQuality: function (shader, game, quality, distance)
{
if (quality === undefined)
{
quality = game.config.glowFXQuality;
}
if (distance === undefined)
{
distance = game.config.glowFXDistance;
}
shader = shader.replace(/__SIZE__/gi, (1 / quality / distance).toFixed(7));
shader = shader.replace(/__DIST__/gi, distance.toFixed(0) + '.0');
return shader;
} }
}; };