2019-12-29 02:20:57 +00:00
|
|
|
precision mediump float;
|
|
|
|
|
|
|
|
varying vec2 uv;
|
|
|
|
|
|
|
|
uniform vec3 uColor;
|
|
|
|
uniform sampler2D texture0;
|
|
|
|
|
2019-12-30 14:50:25 +00:00
|
|
|
uniform float uWidth;
|
|
|
|
uniform float uEdge;
|
|
|
|
|
|
|
|
uniform float uOutlineWidth;
|
|
|
|
uniform float uOutlineEdge;
|
|
|
|
|
|
|
|
uniform vec2 uOutlineOffset;
|
|
|
|
|
|
|
|
uniform vec3 uOutlineColor;
|
|
|
|
|
2019-12-29 02:20:57 +00:00
|
|
|
void main() {
|
2019-12-30 14:50:25 +00:00
|
|
|
float distance = 1.0 - texture2D(texture0, uv).a;
|
|
|
|
float alpha = 1.0 - smoothstep(uWidth, uWidth + uEdge, distance);
|
|
|
|
|
|
|
|
float distanceOutline = 1.0 - texture2D(texture0, uv + uOutlineOffset).a;
|
|
|
|
float alphaOutline = 1.0 - smoothstep(uOutlineWidth, uOutlineWidth + uOutlineEdge, distanceOutline);
|
|
|
|
|
|
|
|
float overallAlpha = alpha + (1.0 - alpha) * alphaOutline;
|
|
|
|
vec3 overallColor = mix(uOutlineColor, uColor, alpha / overallAlpha);
|
|
|
|
|
|
|
|
gl_FragColor = vec4(overallColor, overallAlpha);
|
2019-12-29 02:20:57 +00:00
|
|
|
}
|