Skip to content

Commit 72b6ef6

Browse files
committed
[resources] add utilities
1 parent c04204e commit 72b6ef6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

resources/utils.glsl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,25 @@
55
vec2 uv = gl_FragCoord.xy / resolution;
66
uv = 2.0 * uv - 1.0;
77
uv.x *= resolution.x / resolution.y;
8+
9+
10+
mat2 rot(float a) {
11+
float c = cos(a);
12+
float s = sin(a);
13+
return mat2(c, -s, s, c);
14+
}
15+
16+
17+
float rand(vec2 s) {
18+
return fract(sin(dot(s, vec2(1321.1241, 125.2134)) * 74.57));
19+
}
20+
21+
22+
ivec2 pixelate(vec2 uv, float size) {
23+
return ivec2(floor(uv / size));
24+
}
25+
26+
27+
float gyroid(vec3 p) {
28+
return dot(sin(p), cos(p.yzx));
29+
}

0 commit comments

Comments
 (0)