Skip to content

Instantly share code, notes, and snippets.

Created May 12, 2013 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save anonymous/5565091 to your computer and use it in GitHub Desktop.
Save anonymous/5565091 to your computer and use it in GitHub Desktop.
// warping hexagons, WIP. @psonice_cw
// I'm sure there's a less fugly way of making a hexagonal grid, but hey :)
// Maybe - Try this...
// Simplify!
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
// 1 on edges, 0 in middle
float hex(vec2 p) {
p.x *= 0.57735*2.0;
p.y += mod(floor(p.x), 2.0)*0.5;
p = abs((mod(p, 1.0) - 0.5));
return abs(max(p.x*1.5 + p.y, p.y*2.0) - 1.0);
}
void main(void) {
vec2 pos = gl_FragCoord.xy;
vec2 p = pos/20.0;
float r = (1.0 -0.7)*0.5;
gl_FragColor = vec4(smoothstep(0.0, r + 0.05, hex(p)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment