UNPKG

phaser

Version:

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

26 lines (25 loc) 936 B
module.exports = [ '#pragma phaserTemplate(shaderName)', 'precision mediump float;', 'uniform sampler2D uMainSampler;', 'uniform vec4 uColor;', 'uniform vec4 uIsolateThresholdFeather;', 'varying vec2 outTexCoord;', 'void main()', '{', ' vec4 color = texture2D(uMainSampler, outTexCoord);', ' vec3 unpremultipliedColor = color.rgb / color.a;', ' float isolate = uIsolateThresholdFeather.x;', ' float threshold = uIsolateThresholdFeather.y;', ' float feather = uIsolateThresholdFeather.z;', ' float match = distance(unpremultipliedColor, uColor.rgb);', ' match = clamp(match - threshold, 0.0, 1.0);', ' match = clamp(match / feather, 0.0, 1.0);', ' if (isolate == 1.0)', ' {', ' match = 1.0 - match;', ' }', ' match = mix(1.0, match, uColor.a);', ' gl_FragColor = color * match;', '}', ].join('\n');