LordXido commited on
Commit
a166afc
·
verified ·
1 Parent(s): 6030ed9

Delete shader.glsl

Browse files
Files changed (1) hide show
  1. shader.glsl +0 -62
shader.glsl DELETED
@@ -1,62 +0,0 @@
1
- precision highp float;
2
-
3
- uniform vec2 u_res;
4
- uniform float u_time;
5
- uniform float u_power;
6
- uniform float u_energy;
7
- uniform vec3 u_camPos;
8
- uniform mat3 u_camRot;
9
-
10
- #define MAX_STEPS 120
11
- #define MAX_DIST 10.0
12
- #define SURF_DIST 0.001
13
-
14
- float mandelbulb(vec3 p) {
15
- vec3 z = p;
16
- float dr = 1.0;
17
- float r = 0.0;
18
-
19
- for (int i = 0; i < 10; i++) {
20
- r = length(z);
21
- if (r > 2.0) break;
22
-
23
- float theta = acos(z.z / r);
24
- float phi = atan(z.y, z.x);
25
- dr = pow(r, u_power - 1.0) * u_power * dr + 1.0;
26
-
27
- float zr = pow(r, u_power);
28
- theta *= u_power;
29
- phi *= u_power;
30
-
31
- z = zr * vec3(
32
- sin(theta) * cos(phi),
33
- sin(phi) * sin(theta),
34
- cos(theta)
35
- ) + p;
36
- }
37
- return 0.5 * log(r) * r / dr;
38
- }
39
-
40
- float march(vec3 ro, vec3 rd) {
41
- float d = 0.0;
42
- for (int i = 0; i < MAX_STEPS; i++) {
43
- vec3 p = ro + rd * d;
44
- float ds = mandelbulb(p);
45
- d += ds;
46
- if (d > MAX_DIST || abs(ds) < SURF_DIST) break;
47
- }
48
- return d;
49
- }
50
-
51
- void main() {
52
- vec2 uv = (gl_FragCoord.xy - 0.5 * u_res) / u_res.y;
53
-
54
- vec3 rd = normalize(u_camRot * vec3(uv, 1.5));
55
- vec3 ro = u_camPos;
56
-
57
- float d = march(ro, rd);
58
- float glow = exp(-d * 0.8) * u_energy;
59
-
60
- vec3 col = vec3(glow, glow * 0.7, glow * 1.3);
61
- gl_FragColor = vec4(col, 1.0);
62
- }