Skip to content

Instantly share code, notes, and snippets.

@rezof
Last active June 12, 2022 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezof/7f881c9035d52cd272e5b340664dcec1 to your computer and use it in GitHub Desktop.
Save rezof/7f881c9035d52cd272e5b340664dcec1 to your computer and use it in GitHub Desktop.
glsl helper functions
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