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); |
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
vec2 rotate(vec2 v, float a) { | |
float s = sin(a); | |
float c = cos(a); | |
mat2 m = mat2(c, -s, s, c); | |
return m * v; | |
} |
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
mat4 rotationMatrix(vec3 axis, float angle) { | |
axis = normalize(axis); | |
float s = sin(angle); | |
float c = cos(angle); | |
float oc = 1.0 - c; | |
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, | |
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, | |
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, | |
0.0, 0.0, 0.0, 1.0); |
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
vec2 distortion(vec2 p, float freq, float amp, float t, float map, float speed){ | |
float phase = -1. * speed * freq; | |
float x = p.y * freq + t * phase; | |
float y = p.x * freq + t * .001 * phase; | |
float distX = cos(x+y) * amp; | |
float distY = sin(x-y) * amp; | |
vec2 distortion = vec2(distX * map, distY * map); |
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
mat2 scale2D(vec2 _scale){ | |
return mat2(_scale.x,0.0, | |
0.0,_scale.y); | |
} |
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 random (vec2 st) { | |
return fract(sin(dot(st.xy, | |
vec2(12.9898,78.233)))* | |
43758.5453123); | |
} |
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 voronoi(vec2 uv){ | |
float t = u_time; | |
vec2 i_st = floor(uv * 5.); | |
vec2 f_st = fract(uv * 5.); | |
float m_dist = 1.; | |
vec2 m_point; | |
for(int x = -1; x <= 1; x++){ |
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
vec2 centeredAspectRatio(vec2 uv, vec2 factor){ | |
return ( uv - .5 ) * factor + .5; | |
} |
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
vec2 centerUV(vec2 coord, vec2 coord2){ | |
return (coord - .5 * coord2) / min(coord2.x, coord2.y); | |
} |
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
mat3 gx = mat3(-1., 0., 1., -2., 0., 2., -1., 0., 1.); | |
mat3 gy = mat3(-1., -2., -1., 0., 0., 0., 1., 2., 1.); | |
float sobelEdge(sampler2D u_text,vec2 resolution, vec2 uv){ | |
float h = 0.; | |
float v = 0.; | |
for(int y = 0; y < 3; y++){ | |
for(int x = 0; x < 3; x++){ | |
vec2 d = vec2(y, x) / resolution; | |
vec4 img = texture2D(u_text, uv + d); |
OlderNewer