shader_type canvas_item;
uniform float outline_width = 1.0;
uniform vec4 outline_color: source_color = vec4(1,0,0,1);
void fragment() {
vec2 uv = UV;
vec2 uv_up = uv + vec2(0,TEXTURE_PIXEL_SIZE.y)*outline_width;
vec2 uv_down = uv + vec2(0,-TEXTURE_PIXEL_SIZE.y)*outline_width;
vec2 uv_left = uv + vec2(TEXTURE_PIXEL_SIZE.x,0)*outline_width;
vec2 uv_right = uv + vec2(-TEXTURE_PIXEL_SIZE.x,0)*outline_width;
vec4 color_up = texture(TEXTURE,uv_up);
vec4 color_down = texture(TEXTURE,uv_up);
vec4 color_left = texture(TEXTURE,uv_left);
vec4 color_right = texture(TEXTURE,uv_right);
vec4 outline = color_down + color_up + color_left + color_right;
outline.rgb = outline_color.rgb;
vec4 original_color = texture(TEXTURE,UV);
COLOR = mix(outline,original_color,original_color.a);
}
标签:Godot,outline,color,uv,shader,TEXTURE,边框,vec4,vec2
From: https://www.cnblogs.com/draft/p/18554594