I am trying the following code on a project that looks like this:

The final result should be something closer to this though:

Can someone have a look at my implementation below?
shader_type canvas_item;
const float PI = 3.14159265;
uniform float TILE_SIZE = 16.0;
//precision highp float;
uniform float Amount = 1.0;
highp vec3 rgb2hsv(highp vec3 c)
{
highp vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
highp vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
highp vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
highp float d = q.x - min(q.w, q.y);
highp float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
highp vec3 hsv2rgb(highp vec3 c)
{
highp vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
highp vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
highp vec3 posterize(highp vec3 color, highp float steps)
{
return floor(color * steps) / steps;
}
highp float quantize(highp float n, highp float steps)
{
return floor(n * steps) / steps;
}
highp vec4 downsample(highp sampler2D sampler, highp vec2 uv, highp float pixelSize, highp vec2 screen_pixel_size)
{
return texture(sampler, uv - mod(uv, vec2(pixelSize) / (1.0 / screen_pixel_size).xy));
}
highp float rand_t(highp float n)
{
return fract(sin(n) * 43758.5453123);
}
highp float noise_f(highp float p)
{
highp float fl = floor(p);
highp float fc = fract(p);
return mix(rand_t(fl), rand_t(fl + 1.0), fc);
}
highp float rand(highp vec2 n)
{
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}
highp float noise(highp vec2 p)
{
highp vec2 ip = floor(p);
highp vec2 u = fract(p);
u = u * u * (3.0 - 2.0 * u);
highp float res = mix(
mix(rand(ip), rand(ip + vec2(1.0, 0.0)), u.x),
mix(rand(ip + vec2(0.0,1.0)), rand(ip + vec2(1.0,1.0)), u.x), u.y);
return res * res;
}
highp vec3 edge(highp sampler2D sampler, highp vec2 uv, highp float sampleSize, highp vec2 screen_pixel_size)
{
highp float dx = sampleSize / (1.0 / screen_pixel_size).x;
highp float dy = sampleSize / (1.0 / screen_pixel_size).y;
return (
mix(downsample(sampler, uv - vec2(dx, 0.0), sampleSize, screen_pixel_size), downsample(sampler, uv + vec2(dx, 0.0), sampleSize, screen_pixel_size), mod(uv.x, dx) / dx) +
mix(downsample(sampler, uv - vec2(0.0, dy), sampleSize, screen_pixel_size), downsample(sampler, uv + vec2(0.0, dy), sampleSize, screen_pixel_size), mod(uv.y, dy) / dy)
).rgb / 2.0 - texture(sampler, uv).rgb;
}
highp vec3 distort(highp sampler2D sampler, highp vec2 uv, highp float edgeSize, highp vec2 screen_pixel_size, highp float time)
{
highp vec2 pixel = vec2(1.0) / (1.0 / screen_pixel_size).xy;
highp vec3 field = rgb2hsv(edge(sampler, uv, edgeSize, screen_pixel_size));
highp vec2 distort = pixel * sin((field.rb) * PI * 2.0);
highp float shiftx = noise(vec2(quantize(uv.y + 31.5, (1.0 / screen_pixel_size).y / TILE_SIZE) * time, fract(time) * 300.0));
highp float shifty = noise(vec2(quantize(uv.x + 11.5, (1.0 / screen_pixel_size).x / TILE_SIZE) * time, fract(time) * 100.0));
highp vec3 rgb = texture(sampler, uv + (distort + (pixel - pixel / 2.0) * vec2(shiftx, shifty) * (50.0 + 100.0 * Amount)) * Amount).rgb;
highp vec3 hsv = rgb2hsv(rgb);
hsv.y = mod(hsv.y + shifty * pow(Amount, 5.0) * 0.25, 1.0);
return posterize(hsv2rgb(hsv), floor(mix(256.0, pow(1.0 - hsv.z - 0.5, 2.0) * 64.0 * shiftx + 4.0, 1.0 - pow(1.0 - Amount, 5.0))));
}
void fragment()
{
// highp vec2 uv = FRAGCOORD.xy / (1.0 / SCREEN_PIXEL_SIZE).xy;
highp vec2 uv = SCREEN_UV;
//Amount = uv.x; // Just erase this line if you want to use the control at the top
highp float wow = clamp(mod(noise_f(TIME + uv.y), 1.0), 0.0, 1.0) * 2.0 - 1.0;
highp vec3 finalColor;
finalColor += distort(SCREEN_TEXTURE, uv, 8.0, SCREEN_PIXEL_SIZE, TIME);
COLOR = vec4(finalColor, 1.0);
}