mlpcardgame/UIAssets/Effects/FadeBorder.shader

34 lines
794 B
Text
Raw Permalink Normal View History

2019-06-12 22:36:35 +00:00
shader_type canvas_item;
render_mode blend_mix,unshaded;
uniform vec4 effect_color : hint_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float effect_width : hint_range(0, 0.5) = 0.1;
uniform float effect_offset : hint_range(0, 0.5) = 0;
void fragment() {
vec2 uv = UV;
// Apply offset
if (uv.x < 0.5) {
uv.x -= effect_offset;
} else {
uv.x += effect_offset;
}
if (uv.y < 0.5) {
uv.y -= effect_offset;
} else {
uv.y += effect_offset;
}
uv = clamp(uv, 0, 1);
COLOR = effect_color;
if (uv.x < effect_width) {
COLOR.a *= uv.x / effect_width;
} else if (uv.x > 1.0-effect_width) {
COLOR.a *= ((1.0 - uv.x) / effect_width);
}
if (uv.y < effect_width) {
COLOR.a *= uv.y / effect_width;
} else if (uv.y > 1.0-effect_width) {
COLOR.a *= ((1.0 - uv.y) / effect_width);
}
}