Last active
June 12, 2022 10:50
-
-
Save rezof/7f881c9035d52cd272e5b340664dcec1 to your computer and use it in GitHub Desktop.
glsl helper functions
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 drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos) { | |
pos = pos - polygonCenter; | |
float d = 0.0; | |
float a = atan(pos.x, pos.y); | |
float r = TWO_PI / float(N); | |
d = cos(floor(0.5 + a / r)*r - a)*length(pos); | |
return (1.0 - smoothstep(radius, radius + radius/10.0, d)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment