To use it you only need a color rect
(Tested for godot 3.5 GLES2)
shader_type canvas_item;
uniform float noise_amount = 0.2;
uniform float scanline_amount = 0.1;
uniform float distortion_amount = 0.02;
uniform float roll_speed = 2.0;
float rand(vec2 co) {
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
void fragment() {
vec2 uv = SCREEN_UV;
float time = TIME;
float big_glitch_wave = abs(sin(time * 0.8) * cos(time * 2.3));
float is_big_glitch = step(0.85, big_glitch_wave);
float glitch_trigger = rand(vec2(floor(uv.y * 15.0), time));
float current_distortion = distortion_amount;
if (is_big_glitch > 0.0) {
current_distortion *= 8.0;
uv.x += sin(uv.y * 250.0 + time * 50.0) * current_distortion * 0.5;
} else if (glitch_trigger < noise_amount * 0.4) {
uv.x += sin(uv.y * 100.0 + time) * current_distortion * noise_amount * 2.0;
}
float vertical_saut = step(0.96, rand(vec2(time * 0.2, 0.0))) * sin(time * 30.0) * 0.08;
if (is_big_glitch > 0.0) {
vertical_saut += rand(vec2(time, 0.0)) * 0.3; }
uv.y += vertical_saut;
vec4 scene_color = texture(SCREEN_TEXTURE, uv);
vec3 final_color = scene_color.rgb;
float luma = dot(final_color, vec3(0.299, 0.587, 0.114));
float sat_factor = clamp(1.0 - (noise_amount * 1.5 + glitch_trigger * 0.3), 0.0, 1.0);
if (is_big_glitch > 0.0) {
sat_factor = 0.0;
}
final_color = mix(vec3(luma), final_color, sat_factor);
float violet_trigger = glitch_trigger;
if (is_big_glitch > 0.0) {
violet_trigger = rand(vec2(uv.y, time));
}
if (violet_trigger > 1.0 - (noise_amount * 0.3) || (is_big_glitch > 0.0 && violet_trigger > 0.4)) {
vec3 violet_tint = vec3(0.7, 0.0, 0.9);
vec3 green_tint = vec3(0.0, 0.8, 0.1);
vec3 anomaly_color = mix(violet_tint, green_tint, step(0.7, rand(vec2(time, uv.y))));
float mix_amount = (is_big_glitch > 0.0) ? 0.8 : 0.4;
final_color = mix(final_color, anomaly_color, mix_amount);
}
float noise = rand(uv + time);
float current_noise_amount = noise_amount;
if (is_big_glitch > 0.0) {
current_noise_amount = clamp(noise_amount + 0.5, 0.0, 0.9);
}
final_color = mix(final_color, vec3(noise), current_noise_amount);
float scanline = sin(uv.y * 450.0) * 0.5 + 0.5;
final_color = mix(final_color, final_color * scanline, scanline_amount);
float roll = fract(uv.y - time * roll_speed * 0.1);
float roll_line = smoothstep(0.92, 0.96, roll) * (1.0 - smoothstep(0.96, 1.0, roll));
float final_roll_power = (is_big_glitch > 0.0) ? 0.9 : 0.6;
final_color += vec3(roll_line * current_noise_amount * final_roll_power);
COLOR = vec4(final_color, 1.0);
}Join the discussion! Log in to share your thoughts.
Log In to Comment