GLSL Edge Detection Yesterday, I read 834144373’s ShaderToy code which did GLSL Edge Detection in 97 chars, it was really simple and fast:
1 2 3 4 |
void mainImage(out vec4 o, vec2 u) { o -= o - length(fwidth(texture2D(iChannel0,u/iResolution.xy)))*3.; } |
Meanwhile, the rendering result is astonishingly awesome: However, there are some noise from the GLSL edge detection. Thus, I have made a little improvement on this algorithm and produced cleaner edges in this ShaderToy…