45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
shader_type canvas_item;
|
|
render_mode unshaded;
|
|
|
|
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
|
|
uniform vec4 add_color : source_color = vec4(1.0);
|
|
uniform sampler2D fringe_color;
|
|
uniform float fringe_threshold;
|
|
uniform float threshold;
|
|
varying vec4 global_center;
|
|
varying vec4 screen_center;
|
|
void vertex() {
|
|
vec4 local_center = vec4(0.0, 0.0, 0.0, 1.0);
|
|
|
|
// Transform local center to global coordinates
|
|
global_center = CANVAS_MATRIX * local_center;
|
|
// Called for every vertex the material is visible on.
|
|
}
|
|
|
|
void fragment() {
|
|
// Called for every pixel the material is visible on.
|
|
vec4 color = texture(screen_texture, SCREEN_UV);
|
|
vec4 acol = add_color;
|
|
acol.a = min(acol.a, color.a);
|
|
//COLOR = mix(color, add_color, acol.a);
|
|
vec2 ucrd = vec2(UV.x - 0.5, UV.y - 0.5) * 2.0;
|
|
float d = ucrd.x * ucrd.x + ucrd.y * ucrd.y;
|
|
if(d < threshold * threshold){
|
|
float ft = threshold - fringe_threshold;
|
|
if(d < ft * ft){
|
|
COLOR = vec4(mix(color.rgb, add_color.rgb, acol.a), color.a);
|
|
}else{
|
|
vec4 f_col = texture(fringe_color, vec2((pow(d, .5) - ft)/fringe_threshold));
|
|
COLOR = vec4(mix(color.rgb, f_col.rgb, acol.a), color.a);
|
|
}
|
|
}else{
|
|
COLOR = vec4(UV, 0, 0);
|
|
}
|
|
|
|
}
|
|
|
|
//void light() {
|
|
// // Called for every pixel for every light affecting the CanvasItem.
|
|
// // Uncomment to replace the default light processing function with this one.
|
|
//}
|