-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrt.html
69 lines (67 loc) · 1.54 KB
/
mrt.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><repa-shader> demo</title>
<script type="module" src="../src/repa-shader.js"></script>
<style>
body {
margin: 0;
padding: 0;
background: repeating-linear-gradient(45deg, #333, #333 10px, #666 10px, #666 20px);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
#fsinput {
width: 90vw;
height: 50vh;
}
</style>
</head>
<body>
<repa-shader fs-input="fsinput" mouse snippets="noise.glsl" width=512 height=512 render-target-count=2>
<script type="x-shader/x-fragment">
#define R rotate2D
vec2 c=FC.xy;
vec2 uv=FC.xy/r.xy;
vec2 q;
vec2 p=(c+c-r)/r.y;
vec2 n;
vec4 color;
float S=6.;
float a;
float d=dot(p,p);
float e=200.;
p/=.7-d;
p+=t/PI;
for(float i = 0.; i < e; i++) {
color+=(texture(b1,(c/r-.5)*i/e+.5))/e;
p*=R(5.);
n*=R(5.);
a+=dot(sin(q=p*S+i-abs(n)*R(t*.2))/S,r/r);
n+=cos(q),S*=1.1;
}
// a = max(s,.9-a*.2-d);
a = max(0.,.9-a*.2-d);
o1=pow(a+a*vec4(8,4,1,0)/e,color+40.);
float center = smoothstep(.45, .55, uv.x);
o0=center*color + o1;
</script>
</repa-shader>
<div>
<textarea id="fsinput"></textarea>
</div>
<button id="update">Update</button>
<script>
const updateButton = document.getElementById('update');
updateButton.addEventListener('click', () => {
const fsinput = document.getElementById('fsinput');
const shader = document.querySelector('repa-shader');
shader.render(fsinput.value);
});
</script>
</body>
</html>