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); 
}
This shader is a port from an existing Shadertoy project. Shadertoy shaders are by default protected under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license unless anything else has been stated by the author. For more info, see our License terms.

More from RayL019

starfield angled

Attack of the Smarties

BUBBLE TEA TIME

Related shaders

Single-pass gaussian blur

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments