Skip to content

Instantly share code, notes, and snippets.

@mmalex
Created October 25, 2011 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmalex/f448ba84e94c61ab5924 to your computer and use it in GitHub Desktop.
Save mmalex/f448ba84e94c61ab5924 to your computer and use it in GitHub Desktop.
// paste this into http://www.iquilezles.org/apps/shadertoy/ for pictures!
// this is a gpu/webgl version of http://mainisusuallyafunction.blogspot.com/2011/10/quasicrystals-as-sums-of-waves-in-plane.html
// 'implementation' by @mmalex for http://news.ycombinator.com/item?id=3153835
// sorry for the unrolled loop, on my gpu/chrome combo, a for loop gives 0 output :(
// cant be bothered to work out why.
#ifdef GL_ES
precision highp float;
#endif
uniform float time;
uniform vec2 resolution;
void main(void)
{
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
float t=time*4.0; // change this for more speed
vec2 up=vec2(32.0,0.0); // change this for finer/coarser stripes
float s = 0.43388373911755; // sin and cos of pi / 7
float c = 0.90096886790241;
vec2 temp;
float sum=cos(dot(p,up)+t);
temp=up; up.x=dot(temp,vec2(c,s)); up.y=dot(temp,vec2(-s,c)); sum+=cos(dot(p,up)+t);
temp=up; up.x=dot(temp,vec2(c,s)); up.y=dot(temp,vec2(-s,c)); sum+=cos(dot(p,up)+t);
temp=up; up.x=dot(temp,vec2(c,s)); up.y=dot(temp,vec2(-s,c)); sum+=cos(dot(p,up)+t);
temp=up; up.x=dot(temp,vec2(c,s)); up.y=dot(temp,vec2(-s,c)); sum+=cos(dot(p,up)+t);
temp=up; up.x=dot(temp,vec2(c,s)); up.y=dot(temp,vec2(-s,c)); sum+=cos(dot(p,up)+t);
temp=up; up.x=dot(temp,vec2(c,s)); up.y=dot(temp,vec2(-s,c)); sum+=cos(dot(p,up)+t);
float a1=sum*0.25+0.5;
gl_FragColor = vec4(a1,a1,a1,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment