UNPKG

phaser

Version:

A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.

38 lines (37 loc) 1.18 kB
module.exports = [ '#pragma phaserTemplate(shaderName)', 'precision mediump float;', 'uniform sampler2D uMainSampler;', 'uniform float uRadius;', 'uniform float uStrength;', 'uniform vec2 uPosition;', 'uniform vec4 uColor;', 'uniform int uBlendMode;', 'varying vec2 outTexCoord;', 'void main ()', '{', ' float vignette = 1.0;', ' vec2 position = vec2(uPosition.x, 1.0 - uPosition.y);', ' float d = length(outTexCoord - position);', ' if (d <= uRadius)', ' {', ' float g = d / uRadius;', ' vignette = sin(g * 3.14 * uStrength);', ' }', ' vec4 color = uColor;', ' vec4 texture = texture2D(uMainSampler, outTexCoord);', ' if (uBlendMode == 1)', ' {', ' color.rgb = texture.rgb + color.rgb;', ' }', ' else if (uBlendMode == 2)', ' {', ' color.rgb = texture.rgb * color.rgb;', ' }', ' else if (uBlendMode == 3)', ' {', ' color.rgb = 1.0 - ((1.0 - texture.rgb) * (1.0 - color.rgb));', ' }', ' gl_FragColor = mix(texture, color, vignette);', '}', ].join('\n');