Skip to content

Instantly share code, notes, and snippets.

@lhog
Created May 16, 2018 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lhog/b19b37ed931a973d8fa4e79fc8bfdfdc to your computer and use it in GitHub Desktop.
Save lhog/b19b37ed931a973d8fa4e79fc8bfdfdc to your computer and use it in GitHub Desktop.
//https://www.shadertoy.com/view/4scBDS
#define sum3(v) (v[0]+v[1]+v[2])
#define sqr(n) (n*n)
#define L(x, y) sqrt(sum3(sqr(vec3(texture(iChannel0, (U+vec2(x,y))/iResolution.xy).rgb)*vec3(.299, .587, .114))))
void mainImage( out vec4 O, in vec2 U ) {
vec3 a = vec3(-1, -2, -1), b = vec3(1, 2, 1);
float x = dot(vec3(L(-1,-1), L(-1,0), L(-1,1)), a)
+dot(vec3(L(1,-1), L(1,0), L(1,1)), b),
y = dot(vec3(L(-1,-1), L(0,-1), L(1,-1)), a)
+dot(vec3(L(-1,1), L(0,1), L(1,1)), b);
O.xyz = vec3(sqrt(x*x+y*y));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment