Skip to content

Instantly share code, notes, and snippets.

@AlainBarrios
Created April 15, 2019 23:51
Show Gist options
  • Save AlainBarrios/6cba9e435e68d60eba83c2df862eb76d to your computer and use it in GitHub Desktop.
Save AlainBarrios/6cba9e435e68d60eba83c2df862eb76d to your computer and use it in GitHub Desktop.
Function to create shapes with glsl
float shape(vec2 p, int N, float size){
p = p * 2. - 1.;
float a = atan(p.x, p.y) + PI;
float r = TWO_PI / float(N);
float l = length(p);
float d = cos(floor(.5 + a / r) * r - a) * l;
return step(size, d);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment