mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Added setGlowQuality function
This commit is contained in:
parent
1b31ec12c1
commit
7edc856154
1 changed files with 33 additions and 0 deletions
|
@ -169,5 +169,38 @@ module.exports = {
|
|||
fragmentShaderSource = fragmentShaderSource.replace(/%count%/gi, maxTextures.toString());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue