Skip to content

Instantly share code, notes, and snippets.

@AlainBarrios
AlainBarrios / rotate2d.frag
Last active April 17, 2019 15:36
rotation for uv space in 2d
vec2 rotate(vec2 v, float a) {
float s = sin(a);
float c = cos(a);
mat2 m = mat2(c, -s, s, c);
return m * v;
}
@AlainBarrios
AlainBarrios / shape.frag
Created April 15, 2019 23:51
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);