You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
Plaintext
35 lines
1.0 KiB
Plaintext
shader_type canvas_item;
|
|
|
|
uniform float shift_strength : hint_range(0.0, 1.0);
|
|
uniform float blur_strength : hint_range(0.0, 1.0);
|
|
uniform float vignette_alpha : hint_range(0.0, 1.0);
|
|
uniform float vignette_inner : hint_range(0.0, 1.0) = 0.5;
|
|
uniform float vignette_outer : hint_range(0.0, 2.0) = 1.0;
|
|
|
|
void fragment() {
|
|
vec3 color = vec3(0);
|
|
|
|
//模糊+色移
|
|
float shift = 0.01 * shift_strength;
|
|
float blur = 0.01 * blur_strength;
|
|
vec2 direction = UV - vec2(0.5);
|
|
float f = 0.1;
|
|
color *= f;
|
|
for(int i=1; i < 10; i++) {
|
|
vec2 target_uv = UV - blur * direction * float(i);
|
|
vec3 target_color = vec3(0);
|
|
target_color.r = texture(TEXTURE, vec2(target_uv.x + shift, target_uv.y)).r;
|
|
target_color.g = texture(TEXTURE, target_uv).g;
|
|
target_color.b = texture(TEXTURE, vec2(target_uv.x - shift, target_uv.y)).b;
|
|
color += target_color * f;
|
|
}
|
|
|
|
//暗角
|
|
float x = abs(UV.r-.5)*2.0;
|
|
float y = abs(UV.g-.5)*2.0;
|
|
float q = 1.0-(1.0-sqrt(x*x+y*y)/vignette_outer)/(1.0-vignette_inner);
|
|
q = clamp(q*vignette_alpha,0.0,1.1);
|
|
color *= (1.0-q);
|
|
|
|
COLOR.rgb = color;
|
|
} |