-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.glsl
136 lines (111 loc) · 4.51 KB
/
background.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#pragma glslify: pModPolarBack = require(./hg_sdf/p-mod-polar-c.glsl)
#pragma glslify: pMod2 = require(./hg_sdf/p-mod2.glsl)
#ifndef range
#define range(start, stop, t) saturate((t - start) / (stop - start))
#endif
vec3 gammaEnc (in vec3 color) {
const vec3 enc = vec3(0.454545);
return pow(color, enc);
}
vec3 gammaDecode (in vec3 color) {
const vec3 dec = vec3(2.2);
return pow(color, dec);
}
vec3 getBackground (in vec2 uv, in float universe) {
// Convert from [-1,1] -> [0, 1]
vec2 coord = 0.5 * (uv.xy + vec2(1.0));
// --- Gradient index ---
// float bgIndex = saturate(0.5 * (1. * uv.y + 1.0));
float bgIndex = saturate(length(uv));
// bgIndex = pow(bgIndex, 4.);
// bgIndex += 0.1 * dot(sin(6. * uv), vec2(1));
bgIndex = 1. - bgIndex; // Flip
// Metadata
// --- Set colors / gradient ---
// Gradients
// vec3 color = mix(vec3(0.0), vec3(0.05, 0.025, 0.05), bgIndex);
// vec3 color = mix(vec3(0.03, 0.04, 0.04), vec3(0.125, 0.1, 0.1), bgIndex);
// vec3 color = mix(vec3(0.80, 0.75, 0.70), vec3(0.95, 0.95, 1), bgIndex);
// vec3 color = mix(vec3(0.2), vec3(0.5), bgIndex);
// const vec3 bgColor = #F2900A;
// vec3 color = mix(0.8 * bgColor, bgColor, bgIndex);
// color = mix(color, vec3(1), 0.6);
// // Rainbow dark background color
// float rainbowI = 0.5 * (atan(uv.y, uv.x) / PI + 1.);
// rainbowI += 0.125 * sin(TWO_PI * rainbowI + sin(1. * TWO_PI * rainbowI));
// rainbowI += norT;
// float rainbowValue = 1.;
// vec3 rainbow = 0.5 + 0.5 * cos(TWO_PI * (rainbowI + vec3(0, 0.33, 0.67)));
// vec3 color = mix(rainbowValue * rainbow, vec3(0.0), bgIndex);
// Hex color
// vec3 color = mix(#34A0E0, #60E083, saturate(1. * bgIndex));
// vec3 color = mix(0.25 * #91acff, 0.5 * #a19cff, saturate(1. * bgIndex));
// color *= 1.5;
// vec3 color = mix(vec3(0.8, 0.9165, 1), vec3(0.5), 0.00);
// color = mix(color, 0.7 * vec3(0, 1,0.8), bgIndex);
// Solid colors
// vec3 color = vec3(0.5);
vec3 color = vec3(1);
// vec3 color = vec3(1, 0, 0);
// vec3 color = vec3(0);
// vec3 color = mix(#5927F8, vec3(1), 0.20);
// vec3 color = #FBFBEF;
// -- Patterns --
// vec2 nQ = uv;
// float warpScale = 2.;
// nQ += warpScale * 0.10000 * cos( 2. * nQ.yx );
// nQ += warpScale * 0.05000 * cos( 4. * nQ.yx );
// nQ += warpScale * 0.02500 * cos( 8. * nQ.yx );
// float n = dot(cos(23.78 * nQ), sin(71.29 * nQ));
// n = dot(cos(vec2(0.2, 23.78) * nQ + n), sin(vec2(11.29, 0.7) * nQ));
// n = dot(uv, vec2(0.1)) + 0.2 * n + 8. * dot(uv, uv * cos(vec2(1,3) * uv));
// vec3 color = 0.5 + 0.5 * cos(TWO_PI * (n + vec3(uv, 1) + vec3(0, 0.33, 0.67)));
// // Grid
// const float size = 0.007;
// float sizeI = smoothstep(-1.0, 0.25, uv.y);
// uv *= rotMat2Back(0.35 * PI);
// vec2 c = pMod2(uv, vec2(size));
// vec2 absQ = abs(uv);
// float n = max(absQ.x, absQ.y) - (0.35 + 0.115 * sizeI) * size;
// n = 1. - step(0.0, n);
// vec3 color = 0.8 * vec3(n);
// // Stripes
// vec2 axis = vec2(1);
// float dI = dot(uv, axis);
// float period = 30.;
// float n = sin(period * TWO_PI * dI);
// // float cutoff = 0.8 * smoothstep(-0.5, 0.5, uv.y);
// float cutoff = 0.0;
// n = 1. - smoothstep(cutoff, cutoff + edge, n);
// vec3 color = mix(vec3(0.0), vec3(1), n);
// // Dots
// float size = 0.0265;
// vec2 c = pMod2(uv, vec2(size));
// float dotN = length(uv) - 0.3 * size;
// // n = sin(54. * TWO_PI * dI);
// // float dotCutoff = 0.8 * smoothstep(-0.5, 0.5, uv.y);
// float dotCutoff = 0.;
// dotN = smoothstep(dotCutoff, dotCutoff + edge, dotN);
// vec3 color = vec3(1.00 * dotN);
// // color = mix(mix(primeColor, vec3(1), dotN), color, m);
// Manipulations
// color = mix(color, #FFC070, saturate(smoothstep(0.0, 0.5, uv.y)));
// color *= 1.35; // Brighten
// color = pow(color, vec3(2.2));
// // Gradient tint
// vec3 gradientColor = 0.5 + 0.5 * cos(TWO_PI * (vec3(uv, cos(dot(uv, vec2(1)))) + vec3(0, 0.33, 0.67)));
// color *= mix(gradientColor, vec3(1), (0.70 + 0.2 * length(uv)));
// color *= mix(vec3(0.95), vec3(1, 0.8, 0.8), saturate(1. - 0.95 * (uv.y + 1.0)));
// color *= 1.2;
// color = mix(color, vec3(0.5), 0.10); // desaturate
// color = mix(color, vec3(1), mix(0.25, 0.80, 1. - bgIndex)); // lighten
// color = mix(color, vec3(0), 0.3); // Darken
// color *= 0.91;
// color *= 0.9 * mix(vec3(1, 1.2, 1.2), vec3(1.1, 1.0, 1.05), 1. - bgIndex); // Tint
// color *= vec3(0.9, 0.9, 1.0); // Tint
return color;
}
vec3 getBackground (in vec2 uv) {
return getBackground(uv, 0.);
}
vec3 background = vec3(0.);