Created
April 15, 2019 23:51
-
-
Save AlainBarrios/6cba9e435e68d60eba83c2df862eb76d to your computer and use it in GitHub Desktop.
Function to create shapes with glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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