-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisolate.html
More file actions
765 lines (687 loc) · 21.5 KB
/
isolate.html
File metadata and controls
765 lines (687 loc) · 21.5 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Shader Art</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<div>
Isolate<br/>
<br/><br/>
More shaders:<br/>
<a href ="./index.html">[home]</a>
</div>
</body>
<script>
// -- https://xemantic.github.io/shader-web-background/
const shaderWebBackground={};
(()=>{'use strict';
const t=(a,b)=>{
b.initHalfFloatRGBATexture(b.width,b.height);
a.texParameteri(a.TEXTURE_2D,
a.TEXTURE_MIN_FILTER,a.LINEAR);
a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER, a.LINEAR);
a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);
a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)
},
x=(a,b)=>{
console.warn("shader-web-background cannot shade, adding fallback CSS classes");
document.documentElement.classList.add("shader-web-background-fallback");
b.classList.add("shader-web-background-fallback");
if(a instanceof shaderWebBackground.GlError)console.warn("Not sufficient WebGL support:", a);
else throw a;
};
function y(a,b){
if(!a)throw new shaderWebBackground.ConfigError(b);
}
function z(a){y(a instanceof HTMLCanvasElement,"config.canvas must be instance of canvas");
return a}
function A(){
const a=document.createElement("canvas"),b=a.style;
a.id="shader-web-background";
b.width="100vw";
b.height="100vh";
b.position="fixed";
b.top="0";
b.left="0";
b.zIndex=-9999;
return a
}
function B(a,b,c){
y(a instanceof HTMLScriptElement&&a.type===b,'Shader source element of id "'+ c+'" should be of type: <script type="'+(b+'" id="'+c+'">'))
}
function D(a){
const b=document.getElementById(a);
y(b,'Missing shader source: <script type="x-shader/x-fragment" id="'+ (a+'">'));
B(b,"x-shader/x-fragment",a);
return b.text
}
function E(a){
a+="Vertex";
const b=document.getElementById(a);
return b?(B(b,"x-shader/x-vertex",a),b.text):"attribute vec2 V;void main(){gl_Position=vec4(V,0,1);}"
}
function F(a,b){
"loading"!==document.readyState?b():window.addEventListener(a,b)
}
class G{constructor(a,b,c,d){
this.g=c;
const l=a.gl;
this.h=()=>{for(const f of d)f.u(l, f.location,b)};
this.i=()=>{
var f=c.v,h=a.gl;
h.bindBuffer(h.ARRAY_BUFFER,a.j);
h.enableVertexAttribArray(f);
h.vertexAttribPointer(f,2,h.FLOAT,!1,0,0);h.drawArrays(h.TRIANGLE_STRIP,0,4);h.disableVertexAttribArray(f);
h.bindBuffer(h.ARRAY_BUFFER,null);
f=a.gl;
for(h=0;h<a.g;h++)f.activeTexture(f.TEXTURE0+h),f.bindTexture(f.TEXTURE_2D,null);a.g=0
}
}
}
function H(a){
var b={antialias:!1,depth:!1,alpha:!1};
try{return new I(a,b)}
catch(c){throw new shaderWebBackground.GlError(c.message);}
}
function J(a,b,c,d,l,f){
function h(e,m,n){
try{{
var k=p;const q=k.gl,P=K(k,e,q.VERTEX_SHADER,m),Q=K(k,e,q.FRAGMENT_SHADER,n),v=q.createProgram();q.attachShader(v,P);q.attachShader(v,Q);q.linkProgram(v);var r=v
} return r }
catch(q){throw new shaderWebBackground.ConfigError(q.message);}
}
const p=H(a),w=[],g={
gl:p.gl,
canvas:a,
width:0,
height:0,
cssPixelRatio:0,
cssWidth:0,
cssHeight:0,
isOverShader:(e,m)=>{
const n=a.getBoundingClientRect();
return e>=n.left&&e<=n.right&&m>=n.top&&m<=n.bottom
},
toShaderX:e=>(e-a.getBoundingClientRect().left)*g.cssPixelRatio+.5,
toShaderY:e=>a.height-(e-a.getBoundingClientRect().top)*g.cssPixelRatio-.5,
s:()=>g.cssWidth!==a.clientWidth||g.cssHeight!==a.clientHeight?(g.resize(),!0):!1,
resize:()=>{
const e=window.devicePixelRatio||1,m=a.clientWidth,n=a.clientHeight,k=Math.floor(m*e),r=Math.floor(n*e);
a.width=k;
a.height=r;
g.width=k;
g.height=r;
g.cssPixelRatio=e;
g.cssWidth=m;
g.cssHeight=n;
p.gl.viewport(0,0,p.canvas.width,p.canvas.height);
for(const q of w)q.g.l(k,r)
},
texture:(e,m)=>{
{
var n=p;
const k=n.gl;
m=m instanceof L?m.g:m;
k.activeTexture(k.TEXTURE0+n.g);
k.bindTexture(k.TEXTURE_2D,m);
k.uniform1i(e,n.g++)
}
},
buffers:{
},
initHalfFloatRGBATexture:(e,m)=>{ p.h.g(e,m) }
},
R=Object.keys(b).length-1;
let S=0;
for(const e in b){
if(S++<R){
const k=b[e].texture||t;
g.buffers[e]=M(
p,()=>{
k(p.gl,g)
}
)
}
const m=N(p,h(e,E(e),D(e)),g.buffers[e]),n=b[e].uniforms||{ };
var u=Object.keys(n);
for(const k of m.m)y(n[k.name],'No configuration for uniform "'+k.name+'" defined in shader "'+e+'"'),u=u.filter(r=>r!==k.name);
0!==u.length&&console.warn('Extra uniforms configured for shader "'+e+'", which are not present in the shader code - might have been removed by GLSL compiler if not used: '+u.join(", "));
u=m.m.map(k=>({
location:k.location,u:n[k.name]
}));
w.push(new G(p,g,m,u))
}const C=()=>{
g.s()&&d&&d(g.width,g.height,g);
l&&l(g);
for(const e of w)e.g.i(e.h,e.i);
f&&f(g);
requestAnimationFrame(C)
};
F("load",()=>{
g.resize();
c&&c(g);
d&&d(g.width,g.height,g);
requestAnimationFrame(C)
});
return g
}
shaderWebBackground.Error=class extends Error{
constructor(a){
super(a);
this.name="shaderWebBackground.Error"
}
};
shaderWebBackground.ConfigError=class extends shaderWebBackground.Error{
constructor(a){
super(a);
this.name="shaderWebBackground.ConfigError"
}
};
shaderWebBackground.GlError=class extends shaderWebBackground.Error{
constructor(a){
super(a);
this.name="shaderWebBackground.GlError"
}
};
shaderWebBackground.shade=function(a){
y(a,"Missing config argument");
const b=a.canvas?z(a.canvas):A();
y(a.shaders,"No shaders specified in config");
try{
const c=J(b,a.shaders,a.onInit,a.onResize,a.onBeforeFrame,a.onAfterFrame);
a.canvas||F("DOMContentLoaded",()=>{
document.body.appendChild(b)
});
return c
}catch(c){
(a.onError||x)(c,b)
}
};
const O=[-1,1,1,1,-1,-1,1,-1];
function T(a,b){
return a.j(a.gl.getExtension(b),b+" extension is not supported")
}
class U{
constructor(a,b){
this.gl=a;
this.j=b
}g(){
}
}
class V extends U{
constructor(a,b){
super(a,b);
this.h=T(this,"OES_texture_half_float");
T(this,"OES_texture_half_float_linear")
}
g(a,b){
const c=this.gl;
c.texImage2D(c.TEXTURE_2D,0,c.RGBA,a,b,0,c.RGBA,this.h.HALF_FLOAT_OES,null)
}
}
class W extends U{
constructor(a,b){
super(a,b);
T(this,"EXT_color_buffer_float");
this.gl.getExtension("OES_texture_float_linear")
}g(a,b){
const c=this.gl;
c.texImage2D(c.TEXTURE_2D,0,c.RGBA16F,a,b,0,c.RGBA,c.HALF_FLOAT,null)
}
}
function X(a){
a=a.split(/\r?\n/);
const b=a.length.toString().length;
var c=[];
a.forEach((d,l)=>{
l=(l+1).toString();
l=l.length>=b?l:" ".repeat(b-l.length)+l;
c.push(l+": "+d+"\n")
});
return c.join("")
}
function M(a,b){
return new L( a.gl,()=>{ b(a.gl) } )
}
function N(a,b,c){
const d=a.gl;
a=[];
const l=d.getProgramParameter(b,d.ACTIVE_UNIFORMS);
for(let f=0;
f<l;
f++){
const h=d.getActiveUniform(b,f);
a.push({
name:h.name,location:d.getUniformLocation(b,h.name)
})
}
return{
v:d.getAttribLocation(b,"V"),m:a,l:c?(f,h)=>c.l(f,h):()=>{
},i:(f,h)=>{
d.useProgram(b);
f();
c?(f=c.g,c.g=c.h,c.h=f,c.i(h)):h()
}
}
}
function K(a,b,c,d){
a=a.gl;
c=a.createShader(c);
a.shaderSource(c,d);
a.compileShader(c);
if(!a.getShaderParameter(c,a.COMPILE_STATUS)){
const l=String(a.getShaderInfoLog(c));
a.deleteShader(c);
b="Cannot compile shader - "+b+": "+l;
console.log(b);
console.log(X(d));
throw Error(b);
}
return c
}
class I{
constructor(a,b){
this.canvas=a;
const c=(l,f)=>{
if(!l)throw Error(f);
return l
};
let d=a.getContext("webgl2",b);
if(d)this.h=new W(d,c);
else if(d=a.getContext("webgl",b))this.h=new V(d,c);
c(d,"webgl context not supported on supplied canvas element: "+a);
this.gl=d;
a=d.createBuffer();
d.bindBuffer(d.ARRAY_BUFFER,a);
d.bufferData(d.ARRAY_BUFFER,new Float32Array(O),d.STATIC_DRAW);
d.bindBuffer(d.ARRAY_BUFFER,null);
this.j=a;
this.buffers={ };
this.g=0
}
}
function Y(a){
const b=a.gl,c=b.createTexture();
b.bindTexture(b.TEXTURE_2D,c);
a.o(b);
b.bindTexture(b.TEXTURE_2D,null);
return c
}
class L{
constructor(a,b){
this.j=a.createFramebuffer();
this.gl=a;
this.o=b;
this.g=this.h=null
}
l(){
this.h&&this.gl.deleteTexture(this.h);
this.g&&this.gl.deleteTexture(this.g);
this.h=Y(this);
this.g=Y(this)
}
i(a){
const b=this.gl;
b.bindFramebuffer(b.FRAMEBUFFER,this.j);
b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this.g,0);
a();
b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,null,0);
b.bindFramebuffer(b.FRAMEBUFFER,null)
}
};
})()
//# sourceMappingURL=dist/shader-web-background.min.js.map
</script>
<script type="x-shader/x-fragment" id="image">
precision mediump float;
uniform float time;
float fade;
float fadeTo;
uniform vec2 mouse;
uniform vec2 resolution;
#define PI 3.1415926538
/*
int mod(int a, int b)
{
return a - b * int(ceil(a/b) - 1);
}
//returns an integer of the time (in seconds) capped by modulo
int ti(int maxValue)
{
int t = int(time);
//modulus stopped working so we have to use this horrific function (x - y * floor(x/y))
return return t - maxValue * floor(t/maxValue);
}
bool chance(float probability)
{
}
*/
//just shorthand for a vec4 of all the same color and 1.0
vec4 vec4x(float inp){
return vec4(inp,inp,inp,1.0);
}
//a fash hash function to convert a float into a seemingly random float between 0 and 1
float hash1(float n){
return fract(sin(n) * 43758.5453123);
}
float hash2(float n){
return fract(-sin(n) * 12345.6789012);
}
float hash3(float n){
return fract(-tan(n) * 54321.2109876);
}
float betterHash(float n) {
return fract(sin(n * 12.9898) * 43758.5453123 + cos(n * 78.233) * 12345.6789);
}
//return time scale
float ts(float scale)
{
return time * scale;
}
float ranf()
{
return hash3(hash2(float(time) * 0.000001) * hash1(float(time) * 0.00001));
}
//just gives a sin of (time * tscale)
float sint(float tscale)
{
return sin(time * tscale);
}
//oscillates with time * tscale between low and high
float osc(float low, float high, float tscale)
{
float range = high - low;
float osc = cos(time * tscale) * range * 0.5;
return low + osc;
}
float safeDivide(float numerator, float denominator)
{
float safeDenom = sign(denominator) * max(abs(denominator), 0.00000001);
return numerator / safeDenom;
}
//xssx
vec4 noiseBW()
{
vec2 pos = gl_FragCoord.xy / resolution.xy;
vec2 cpos = pos - vec2(0.5,0.5) * vec2(osc(5.0, 15.0, 0.01), osc(5.0, 15.0, 0.014));
float oscResX = osc(10., 180., 0.07);
float oscResY = osc(10., 60., 0.19);
vec2 posClamp = vec2(ceil(cpos.x * oscResX), ceil(cpos.y* oscResY)) / vec2(osc(5.0, 15.0, 0.017), osc(5.0, 15.0, 0.015));
vec4 color = vec4x(0.0);
float h1 = hash1(hash2(safeDivide(time , fract(posClamp.x * posClamp.y))));
float h2 = hash1(hash2(safeDivide(time , fract(posClamp.x / posClamp.y))));
float h3 = hash1(hash2(time / fract(1.0 + posClamp.x * 1.1 * posClamp.y)));
float o1 = osc(8.0, 10.0, 0.161);
float o2 = osc(8.0, 10.0, 0.111);
float o3 = osc(8.0, 10.0, 0.131);
return vec4(pow(h1, o1), pow(h1, o2), pow(h1,o3), 1.0);
}
//fisheye. center is inverse zoom of center (0..1). Outerscale is the scale of the outer range of the canvas
vec2 fisheye(vec2 pos, float center, float outerScale){
vec2 scaled = pos * vec2(outerScale, outerScale);
vec2 magniPos = scaled * scaled * scaled;
return (scaled * center) + (magniPos * outerScale * (1.0 - center));
}
//sinusoidally oscillates between `from` and `to` at the rate of `rate` per second and with a cycle offset of `offset`
float custy(float from, float to, float inp, float rate, float offset)
{
return (cos((inp * PI * rate) + offset) * -0.5) + 0.5;
}
//shorthand for cos(time * timescale) * maxScale
float ct(float timeScale, float maxScale){
return cos(time * timeScale) * maxScale;
}
//simple linear interpolation between two floats
float lerpf(float fA, float fB, float lp){
return (fA * (1.0 - lp)) + fB * lp;
}
//linear interpolation from vecA to vecB to the degree of lp. Supports lp<0 and lp>1
vec4 lerpv(vec4 vecA, vec4 vecB, float lp)
{
return (vecA * (1.0 - lp)) + vecB * lp;
}
//Converts a value into a sinusoid which is 0 at inp=0 and 1 at inp =1
float cosy(float inp)
{
return (cos(inp * PI) * -0.5) + 0.5;
}
//Like cosy, but rounded
float check(float inp){
return ceil(cos(inp * PI * -1.0));
}
//Like checkerboard, but smooth on the X axis
float cylindricalChecker(float from, float to, vec2 pos, float rateX, float rateY, float rowShift){
//cos(pos.x * PI *2) would be 1 complete cycle of verical bars
vec2 cycle = pos * 2.0 * PI;
//cos(cycle.x * rateX) would make rateX vertical bars
cycle *= vec2(rateX, rateY);
// an oscillating 0 or 1 offset woould be ceil(cos(cycle.y)) * PI
float offseX = ceil(cos(-cycle.y)) * PI * rowShift;
//calculate based on pos.x, offset 0 or 1 based on pos.y
float checkX = cos(cycle.x + offseX) * 0.99;
return (from * (1.0 - checkX)) + (to * checkX);
}
//an accidental dizzying thing based on checker
//cos(pos.x * PI *2) would be 1 complete cycle of verical bars
float warped(float from, float to, vec2 pos, float rateX, float rateY, float warp){
vec2 cycle = pos * 2.0 * PI;
//cos(cycle.x * rateX) would make rateX vertical bars
cycle *= vec2(rateX, rateY);
// an oscillating 0 or 1 offset woould be ceil(cos(cycle.y)) * PI
float offseX = cos(-cycle.y) * PI * warp;
//calculate based on pos.x, offset 0 or 1 based on pos.y
float checkX = cos(cycle.x + offseX) * 0.99;
return (from * (1.0 - checkX)) + (to * checkX);
}
vec4 freqmod(vec2 pos)
{
vec2 cpos = pos - vec2(0.5,0.5);
vec2 fpos = fisheye(cpos, -0.11 + (sin(time * 0.031) * 0.24), 1.0);
vec2 swirlpos = fpos + vec2(sin(time * 0.005) * 0.3, cos(time * 0.007) * 0.3 ); //swirling around the center
vec2 wob = vec2(swirlpos.x + (cos(swirlpos.x * 20.0) * 0.2), swirlpos.y + (cos(swirlpos.y * 20.0) * 0.2));
//a squiggly wobbled version of pos, where the position of x and y oscillate to a degree of woobleStr
float wobbleStrX = 0.2;
float wobbleStrY = 0.2;
float wobXCt = 2.0;
float wobYCt = 2.0;
float wobX = pos.x + custy(-wobbleStrX, wobbleStrX, cos(pos.y * wobXCt), wobXCt, 0.0);
float wobY = pos.y + custy(-wobbleStrY, wobbleStrY, cos(pos.x * wobYCt), wobYCt, 0.0);
vec2 wobbled = vec2(wobX, wobY);
float bas = cosy(time * 0.1);
float fromRed = 0.0;
float fromGrn = 0.0;
float fromBlu = 0.2;
float toRed = 0.9;
float toGrn = 0.1;
float toBlu = 0.8;
float pass1r = custy(fromRed, toRed, cosy((0.5 + wobbled.x) * cosy(time * 0.00044) * 0.5), 0.2, 0.0);
float pass1g = custy(fromGrn, toGrn, cosy((0.5 + wobbled.x) * cosy(time * 0.0065) * 20.0), 0.4, 0.333);
float pass1b = custy(fromBlu, toBlu, cosy((0.5 + wobbled.x) * cosy(time * 0.01) * 40.0), 0.1, 0.667);
vec4 pass1 = vec4(pass1r, pass1g, pass1b, 1.0);
vec4 passwX = vec4x(cosy(wob.x * 2.0));
vec4 passwY = vec4x(cosy(wob.y * 2.0));
//gl_FragColor = lerp(passwX, passwY, 0.5);
float color = warped(0.0, 0.5, swirlpos, 2.0, 2.0 + cos(time * 0.015) * 9.0, 2.0 + (cos(time* 0.01) * 2.0));
float halfcol = color * 0.5;
float halfred = halfcol * cos(time * 0.0021 * cosy(cpos.y * cos(time * 0.05) * 0.24));
float halfgrn = halfcol * cos(time * 0.0014 * cosy(cpos.y * cos(time * 0.06) * 0.16));
float halfblu = halfcol * cos(time * 0.0007);
return vec4(halfcol + halfred, halfcol + halfgrn, halfcol + halfblu, 1.0);
}
float dotted(float from, float to, vec2 pos, float rateX, float rateY, float rowShift){
//cos(pos.x * PI *2) would be 1 complete cycle of verical bars
vec2 cycle = pos * 2.0 * PI;
//cos(cycle.x * rateX) would make rateX vertical bars
cycle *= vec2(rateX, rateY);
// an oscillating 0 or 1 offset woould be ceil(cos(cycle.y)) * PI
float offseX = ceil(cos(-cycle.y) * 0.95) * PI * rowShift;
//calculate based on pos.x, offset 0 or 1 based on pos.y
float checkX = cos(cycle.x + offseX) * 0.95;
return (from * (1.0 - checkX)) + (to * checkX);
}
vec2 nearestGridPoint(float gridX, float gridY, vec2 pos)
{
float retX = ceil((pos.x * gridX) / gridX);
float retY = ceil((pos.x * gridX) / gridX);
return vec2 (retX - pos.x, retY - pos.y);
}
float rounded(float value, float pivot)
{
return ceil(value - pivot);
}
vec2 rotate(vec2 pos, float theta) //rotation of theta radians
{
return vec2((pos.x * cos(theta)) - (pos.y*sin(theta)) , (pos.y * cos(theta)) + (pos.x*sin(theta) ));
}
vec2 sphereModPos(vec2 pos){
return vec2(mod((pos.x - 0.5) , cos(PI * (pos.y - 0.5))), pos.y);
}
vec2 spherePos(vec2 uv) {
float phi = (uv.y - 0.5) * PI; // Map to [-π/2, π/2]
float scale = max(cos(phi), 0.000001); // safe divide
vec2 correctedUV;
correctedUV.x = mod(uv.x / scale, 1.0); // Scale X to compensate for pole distortion
correctedUV.y = uv.y; // Keep Y unchanged
return correctedUV;
}
//uses pos.x and .y to provide a 0 or 1 in a checkerboard with period rateX and rateY
float checker(float from, float to, vec2 pos, float rateX, float rateY, float rowShift){
//cos(pos.x * PI *2) would be 1 complete cycle of verical bars
vec2 cycle = pos * 2.0 * PI;
//cos(cycle.x * rateX) would make rateX vertical bars
cycle *= vec2(rateX, rateY);
// an oscillating 0 or 1 offset woould be ceil(cos(cycle.y)) * PI
float offseX = ceil(cos(-cycle.y) * 0.95) * PI * rowShift;
//calculate based on pos.x, offset 0 or 1 based on pos.y
float checkX = ceil(cos(cycle.x + offseX) * 0.95);
return (from * (1.0 - checkX)) + (to * checkX);
}
vec4 checkerboard(vec2 pos)
{
vec2 cpos = pos - vec2(0.5, 0.5); //center-based position
vec2 swirlpos = cpos + vec2(ct(0.091, 0.3), ct(0.072, 0.3)); //swirling around the center
vec2 fishpos = fisheye(swirlpos, 0.45+ ct(0.0814, 0.25), 1.8);
float redMax = ct(0.56, 0.20);
float redMin = 0.05 + ct(0.257, 0.05);
float redRate = 10.0 + ct(0.01258, 8.0);
float red = dotted(redMin, redMax, fishpos, redRate, 20.0, ct(0.1259, 2.0));
float grnRate = 50.0 + ct(0.0751, 79.0);
float grnMin = 0.05 + ct(0.252, 0.05);
float grnMax = ct(0.253, 0.15);
float grn = dotted(grnMin, grnMax, fishpos, grnRate, 20.0, ct(0.5, 10.0));
float bluRate = 30.0 + ct(0.054, 29.0);
float bluMin = 0.15 + ct(0.257, 0.15);
float bluMax = ct(0.059, 0.75);
float blu = dotted(bluMin, bluMax, fishpos, bluRate, 20.0, ct(0.05, 2.0));
blu = lerpf(blu, blu*blu, cosy(time* 0.2));
vec4 pass1 = vec4(red,grn,blu, 1.0);
//gl_FragColor = lerp(passwX, passwY, 0.5);
float pass2Color = checker(0.0, 0.5, swirlpos, 20.0, 20.0 + cos(time * 0.15) * 19.0, 20.0 + (cos(time* 0.1) * 20.0));
float halfcol = pass2Color * 0.5;
float halfred = halfcol * cos(time * 0.211 * cosy(cpos.y * sin(time * 0.053) * 0.248));
float halfgrn = halfcol * cos(time * 0.142 * cosy(cpos.y * sin(time * 0.063) * 0.165));
float halfblu = halfcol * cosy(time * 0.078);
vec4 pass2 = vec4(halfcol + halfred, halfcol + halfgrn, halfcol + halfblu, 1.0);
float pass3Color = warped(0.0, 0.5, swirlpos, 20.0, 20.0 + cos(time * 0.15) * 19.0, 20.0 + (cos(time* 0.1) * 20.0));
vec4 pass3 = vec4x(pass3Color);
vec4 lerp1 = lerpv(pass1, pass2, (cosy(time * 0.12) * 0.2) + (cosy(time * 0.17) * 0.6));
vec4 lerp2 = lerpv(lerp1, pass3, (cosy(time * 0.18) * 0.03) + (cosy(time * 0.09) * 0.03));
return lerp2;
}
vec4 intet(vec2 inpo)
{
vec2 pos = inpo; // 0..1 based position
float movingPos = -inpo.y + (time * 0.2);
float PIx2 = PI * 2.;
float cars = 6. / PI;
float sinX1 = (ceil(sin(PIx2 * movingPos * cars)) * 0.2) - 0.2; //alternates between 0 and -0.4 at a rate of pos
float sinX2 = (ceil(sin(PIx2 * movingPos * cars * 4. )) * 0.9) - 0.8;
float sinX = (sinX1 + sinX2);
float ceild = ceil(sinX);
vec4 color = vec4x(ceild * 0.5);
return lerpv(vec4(0.), color, ct(0.1, 0.9));
}
void main(void)
{
vec2 pos = (gl_FragCoord.xy / resolution.xy);
vec2 po1 = vec2(pow(pos.x, 3.), pow(pos.y, 3.));
float rhythm = 0.125;
vec2 po3 = pos * vec2(ct(0.11, 0.01), ct(0.14, 0.03));
vec2 pom = pos.xy + vec2(0.0, ts(0.03));
vec4 pattern2 =freqmod(po3);
vec4 pattern3 =freqmod(po1);
vec4 pattern4 =checkerboard(pos);
vec4 combo4 = lerpv(pattern4, pattern3, ct(rhythm , 1.));
vec2 gp = nearestGridPoint(5., 6., pom);
float distGP = sqrt((gp.x* gp.x) + (gp.y*gp.y));
vec4 combo5 = lerpv(pattern4, pattern2, rounded(distGP, 2.21));
gl_FragColor = combo5;
}
</script>
<script>
shaderWebBackground.shade({
shaders: {
image: {
uniforms: {
time: (gl, loc) => gl.uniform1f(loc, performance.now() / 1000),
resolution: (gl, loc) => {
const canvas = gl.canvas; // Assuming the canvas element
gl.uniform2f(loc, canvas.width, canvas.height);
}
}
}
}
});
</script>
<style>
.shader-web-background-fallback {
background-position: center;
background-size: cover;
background-attachment: fixed;
}
div {
position:relative;
height:20%;
width:10%;
background-color: black;
text-align: center;
border: 3px solid white;
padding: 20px;
margin: auto; /* Centers it horizontally */
opacity: 0.8;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
header {
height: 100vh;
}
html {
box-sizing: border-box;
background: black;
font-size: 1.7vmin;
font-family: sans-serif;
scroll-behavior: smooth;
line-height: 2em;
}
*, *:before, *:after {
box-sizing: inherit;
}
body, h1, h2, p, ul, blockquote {
color: white;
overflow-x: hidden;
overflow-y: hidden;
text-align: center;
margin: 0;
padding: 0;
}
p, ul {
margin-top: .618rem;
margin-bottom: .618rem;
}
</style>
</html>