High Pass vs Fwidth
https://www.shadertoy.com/view/MdSfWV
Shader code
shader_type canvas_item;
uniform sampler2D iChannel0;
#define USE_BILATERAL_FILTER
uniform float strength : hint_range(0.0, 5.0, 0.1) = 1.0;
uniform bool simple_edge = false;
void fragment()
{
vec2 iResolution = 1.0 / SCREEN_PIXEL_SIZE;
float[] kernel = {-1., -1., -1., -1., 8., -1., -1., -1., -1.};
vec2 delta = 1.0 / iResolution.xy;
vec2[] offset =
{-delta, vec2(0.0, -delta.y), vec2(delta.x, -delta.y),
vec2(-delta.x, 0.0), vec2(0.0), vec2(delta.x, 0.0),
vec2(-delta.x, delta.y), vec2(0.0, delta.y), delta};
vec2 uv = UV;
vec3 col = vec3(0.0);
for (int i = 0; i < 9; ++i)
{
col += texture(iChannel0, uv + offset[i]).rgb * kernel[i] * strength;
}
float simpleEdge = length(fwidth(texture(iChannel0, uv)));
if (simple_edge == true) col = vec3(simpleEdge);
COLOR = vec4(col, 1.0);
}