@thi.ng/shader-ast-stdlib 0.12.21 → 0.12.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dev/grayscott.js DELETED
@@ -1,425 +0,0 @@
1
- (function() {
2
- function createShader(gl, source, type) {
3
- const shader = gl.createShader(type);
4
- gl.shaderSource(shader, source);
5
- gl.compileShader(shader);
6
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
7
- throw new Error(gl.getShaderInfoLog(shader) + source);
8
- }
9
- return shader;
10
- }
11
-
12
- function createProgramFromSource(
13
- gl,
14
- vertexShaderSource,
15
- fragmentShaderSource
16
- ) {
17
- const program = gl.createProgram();
18
- gl.attachShader(
19
- program,
20
- createShader(gl, vertexShaderSource, gl.VERTEX_SHADER)
21
- );
22
- gl.attachShader(
23
- program,
24
- createShader(gl, fragmentShaderSource, gl.FRAGMENT_SHADER)
25
- );
26
- gl.linkProgram(program);
27
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
28
- throw new Error(gl.getProgramInfoLog(program));
29
- }
30
- return program;
31
- }
32
-
33
- function createVbo(gl, array, usage) {
34
- const vbo = gl.createBuffer();
35
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
36
- gl.bufferData(
37
- gl.ARRAY_BUFFER,
38
- array,
39
- usage !== undefined ? usage : gl.STATIC_DRAW
40
- );
41
- gl.bindBuffer(gl.ARRAY_BUFFER, null);
42
- return vbo;
43
- }
44
-
45
- function createIbo(gl, array) {
46
- const ibo = gl.createBuffer();
47
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);
48
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array, gl.STATIC_DRAW);
49
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
50
- return ibo;
51
- }
52
-
53
- function getUniformLocations(gl, program, keys) {
54
- const locations = {};
55
- keys.forEach((key) => {
56
- locations[key] = gl.getUniformLocation(program, key);
57
- });
58
- return locations;
59
- }
60
-
61
- function createFramebuffer(gl, sizeX, sizeY) {
62
- const framebuffer = gl.createFramebuffer();
63
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
64
- const texture = gl.createTexture();
65
- gl.bindTexture(gl.TEXTURE_2D, texture);
66
- gl.texImage2D(
67
- gl.TEXTURE_2D,
68
- 0,
69
- gl.RG32F,
70
- sizeX,
71
- sizeY,
72
- 0,
73
- gl.RG,
74
- gl.FLOAT,
75
- null
76
- );
77
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
78
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
79
- gl.framebufferTexture2D(
80
- gl.FRAMEBUFFER,
81
- gl.COLOR_ATTACHMENT0,
82
- gl.TEXTURE_2D,
83
- texture,
84
- 0
85
- );
86
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
87
- gl.bindTexture(gl.TEXTURE_2D, null);
88
- return {
89
- framebuffer: framebuffer,
90
- texture: texture
91
- };
92
- }
93
-
94
- const VERTICES_POSITION = new Float32Array([
95
- -1.0,
96
- -1.0,
97
- 1.0,
98
- -1.0,
99
- -1.0,
100
- 1.0,
101
- 1.0,
102
- 1.0
103
- ]);
104
-
105
- const VERTICES_INDEX = new Int16Array([0, 1, 2, 3, 2, 1]);
106
-
107
- const FILL_SCREEN_VERTEX_SHADER_SOURCE = `#version 300 es
108
-
109
- layout (location = 0) in vec2 position;
110
-
111
- void main(void) {
112
- gl_Position = vec4(position, 0.0, 1.0);
113
- }
114
- `;
115
-
116
- const INITIALIZE_FRAGMENT_SHADER_SOURCE = `#version 300 es
117
-
118
- precision highp float;
119
-
120
- out vec2 o_state;
121
-
122
- uniform vec2 u_resolution;
123
- uniform vec2 u_randomSeed;
124
-
125
-
126
- float random(vec2 x){
127
- return fract(sin(dot(x,vec2(12.9898, 78.233))) * 43758.5453);
128
- }
129
-
130
-
131
- float valuenoise(vec2 x) {
132
- vec2 i = floor(x);
133
- vec2 f = fract(x);
134
-
135
- vec2 u = f * f * (3.0 - 2.0 * f);
136
-
137
- return mix(
138
- mix(random(i), random(i + vec2(1.0, 0.0)), u.x),
139
- mix(random(i + vec2(0.0, 1.0)), random(vec2(i + vec2(1.0, 1.0))), u.x),
140
- u.y
141
- );
142
- }
143
-
144
- float fbm(vec2 x) {
145
- float sum = 0.0;
146
- float amp = 0.5;
147
- for (int i = 0; i < 5; i++) {
148
- sum += amp * valuenoise(x);
149
- amp *= 0.5;
150
- x *= 2.01;
151
- }
152
- return sum;
153
- }
154
-
155
- void main(void) {
156
- vec2 st = (2.0 * gl_FragCoord.xy - u_resolution) / min(u_resolution.x, u_resolution.y);
157
- if (fbm(gl_FragCoord.xy * 0.01 + random(u_randomSeed) * 1000.0 + vec2(392.43, 193.34)) < 0.3) {
158
- o_state = vec2(1.0);
159
- } else {
160
- o_state = vec2(0.0);
161
- }
162
-
163
- }
164
- `;
165
-
166
- const UPDATE_FRAGMENT_SHADER_SOURCE = `#version 300 es
167
-
168
- precision highp float;
169
-
170
- out vec2 o_state;
171
-
172
- uniform sampler2D u_stateTexture;
173
- uniform float u_timeStep;
174
- uniform float u_spaceStep;
175
- uniform vec2 u_diffusion;
176
- uniform float u_feed;
177
- uniform float u_kill;
178
-
179
- void main(void) {
180
- ivec2 coord = ivec2(gl_FragCoord.xy);
181
- ivec2 stateTextureSize = textureSize(u_stateTexture, 0);
182
-
183
- vec2 state = texelFetch(u_stateTexture, coord, 0).xy;
184
-
185
- vec2 left = texelFetch(u_stateTexture, ivec2(coord.x != 0 ? coord.x - 1 : stateTextureSize.x - 1, coord.y), 0).xy;
186
- vec2 right = texelFetch(u_stateTexture, ivec2(coord.x != stateTextureSize.x - 1 ? coord.x + 1 : 0, coord.y), 0).xy;
187
- vec2 down = texelFetch(u_stateTexture, ivec2(coord.x, coord.y != 0 ? coord.y - 1 : stateTextureSize.y - 1), 0).xy;
188
- vec2 up = texelFetch(u_stateTexture, ivec2(coord.x, coord.y != stateTextureSize.y - 1 ? coord.y + 1 : 0), 0).xy;
189
-
190
- vec2 laplacian = (left + right + up + down - 4.0 * state) / (u_spaceStep * u_spaceStep);
191
-
192
- o_state = state + u_timeStep * (u_diffusion * laplacian + vec2(
193
- state.x * state.x * state.y - (u_feed + u_kill) * state.x,
194
- -state.x * state.x * state.y + u_feed * (1.0 - state.y)
195
- ));
196
- }
197
- `;
198
-
199
- const RENDER_FRAGMNET_SHADER_SOURCE = `#version 300 es
200
-
201
- precision highp float;
202
-
203
- out vec4 o_color;
204
-
205
- uniform sampler2D u_stateTexture;
206
- uniform int u_target;
207
- uniform int u_rendering;
208
- uniform float u_spaceStep;
209
-
210
- float getValue(ivec2 coord) {
211
- vec2 state = texelFetch(u_stateTexture, ivec2(coord), 0).xy;
212
-
213
- if (u_target == 0) {
214
- return state.x;
215
- } else if (u_target == 1) {
216
- return state.y;
217
- } else {
218
- return abs(state.x - state.y);
219
- }
220
- }
221
-
222
- vec3 render2d(ivec2 coord) {
223
- return vec3(getValue(coord));
224
- }
225
-
226
- vec3 lambert(vec3 color, vec3 normal, vec3 lightDir) {
227
- return color * max(dot(normal, lightDir), 0.0);
228
- }
229
-
230
- vec3 render3d(ivec2 coord) {
231
- ivec2 stateTextureSize = textureSize(u_stateTexture, 0);
232
- float state = getValue(coord);
233
- float left = getValue(ivec2(coord.x != 0 ? coord.x - 1 : stateTextureSize.x - 1, coord.y));
234
- float right = getValue(ivec2(coord.x != stateTextureSize.x - 1 ? coord.x + 1 : 0, coord.y));
235
- float down = getValue(ivec2(coord.x, coord.y != 0 ? coord.y - 1 : stateTextureSize.y - 1));
236
- float up = getValue(ivec2(coord.x, coord.y != stateTextureSize.y - 1 ? coord.y + 1 : 0));
237
-
238
- vec3 dx = vec3(2.0 * u_spaceStep, 0.0, (right - left) / (2.0 * u_spaceStep));
239
- vec3 dy = vec3(0.0, 2.0 * u_spaceStep, (up - down) / (2.0 * u_spaceStep));
240
-
241
- vec3 normal = mix(normalize(cross(dx, dy)), vec3(0.0, 0.0, 1.0), 0.5);
242
-
243
- vec3 baseColor = mix(vec3(0.0, 0.05, 0.1), vec3(0.7, 1.0, 0.1), clamp(state, 0.0, 1.00));
244
- vec3 color = vec3(0.0);
245
- color += baseColor * lambert(vec3(1.5), normal, vec3(1.0, 1.0, 1.0));
246
- color += baseColor * lambert(vec3(0.5), normal, vec3(-1.0, -1.0, 0.3));
247
- return color;
248
- }
249
-
250
- void main(void) {
251
- vec2 state = texelFetch(u_stateTexture, ivec2(gl_FragCoord.xy), 0).xy;
252
-
253
- if (u_rendering == 0) {
254
- o_color = vec4(render2d(ivec2(gl_FragCoord.xy)), 1.0);
255
- } else {
256
- o_color = vec4(render3d(ivec2(gl_FragCoord.xy)), 1.0);
257
- }
258
- }
259
- `;
260
-
261
- const parameters = {
262
- "diffusion U": 0.0009,
263
- "diffusion V": 0.004,
264
- feed: 0.09,
265
- kill: 0.06,
266
- "space step": 0.05,
267
- "time step": 0.15,
268
- "time scale": 50.0,
269
- target: 0,
270
- rendering: 1,
271
- reset: (_) => reset()
272
- };
273
-
274
- const canvas = document.getElementById("canvas");
275
- const gl = canvas.getContext("webgl2");
276
- gl.getExtension("EXT_color_buffer_float");
277
-
278
- const initializeProgram = createProgramFromSource(
279
- gl,
280
- FILL_SCREEN_VERTEX_SHADER_SOURCE,
281
- INITIALIZE_FRAGMENT_SHADER_SOURCE
282
- );
283
- const updateProgram = createProgramFromSource(
284
- gl,
285
- FILL_SCREEN_VERTEX_SHADER_SOURCE,
286
- UPDATE_FRAGMENT_SHADER_SOURCE
287
- );
288
- const renderProgram = createProgramFromSource(
289
- gl,
290
- FILL_SCREEN_VERTEX_SHADER_SOURCE,
291
- RENDER_FRAGMNET_SHADER_SOURCE
292
- );
293
- const initializeUniforms = getUniformLocations(gl, initializeProgram, [
294
- "u_resolution",
295
- "u_randomSeed"
296
- ]);
297
- const updateUniforms = getUniformLocations(gl, updateProgram, [
298
- "u_stateTexture",
299
- "u_diffusion",
300
- "u_feed",
301
- "u_kill",
302
- "u_timeStep",
303
- "u_spaceStep"
304
- ]);
305
- const renderUniforms = getUniformLocations(gl, renderProgram, [
306
- "u_stateTexture",
307
- "u_target",
308
- "u_rendering",
309
- "u_spaceStep"
310
- ]);
311
-
312
- const vao = gl.createVertexArray();
313
- gl.bindVertexArray(vao);
314
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, createIbo(gl, VERTICES_INDEX));
315
- gl.bindBuffer(gl.ARRAY_BUFFER, createVbo(gl, VERTICES_POSITION));
316
- gl.enableVertexAttribArray(0);
317
- gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
318
- gl.bindVertexArray(null);
319
-
320
- const renderToFillScreen = function() {
321
- gl.bindVertexArray(vao);
322
- gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
323
- gl.bindVertexArray(null);
324
- };
325
-
326
- let animationId = null;
327
- const reset = function() {
328
- if (animationId !== null) {
329
- cancelAnimationFrame(animationId);
330
- }
331
-
332
- canvas.width = window.innerWidth;
333
- canvas.height = window.innerHeight;
334
- gl.viewport(0.0, 0.0, canvas.width, canvas.height);
335
-
336
- let stateFbObjR = createFramebuffer(gl, canvas.width, canvas.height);
337
- let stateFbObjW = createFramebuffer(gl, canvas.width, canvas.height);
338
- const swapFramebuffer = function() {
339
- const tmp = stateFbObjR;
340
- stateFbObjR = stateFbObjW;
341
- stateFbObjW = tmp;
342
- };
343
-
344
- const initialize = function() {
345
- gl.bindFramebuffer(gl.FRAMEBUFFER, stateFbObjW.framebuffer);
346
- gl.useProgram(initializeProgram);
347
- gl.uniform2f(
348
- initializeUniforms["u_resolution"],
349
- canvas.width,
350
- canvas.height
351
- );
352
- gl.uniform2f(
353
- initializeUniforms["u_randomSeed"],
354
- Math.random() * 1000.0,
355
- Math.random() * 1000.0
356
- );
357
- renderToFillScreen();
358
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
359
- swapFramebuffer();
360
- };
361
-
362
- const update = function(deltaTime) {
363
- gl.bindFramebuffer(gl.FRAMEBUFFER, stateFbObjW.framebuffer);
364
- gl.useProgram(updateProgram);
365
- gl.activeTexture(gl.TEXTURE0);
366
- gl.bindTexture(gl.TEXTURE_2D, stateFbObjR.texture);
367
- gl.uniform1i(updateUniforms["u_stateTexture"], 0);
368
- gl.uniform2f(
369
- updateUniforms["u_diffusion"],
370
- parameters["diffusion U"],
371
- parameters["diffusion V"]
372
- );
373
- gl.uniform1f(updateUniforms["u_feed"], parameters["feed"]);
374
- gl.uniform1f(updateUniforms["u_kill"], parameters["kill"]);
375
- gl.uniform1f(updateUniforms["u_timeStep"], deltaTime);
376
- gl.uniform1f(
377
- updateUniforms["u_spaceStep"],
378
- parameters["space step"]
379
- );
380
- renderToFillScreen();
381
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
382
- swapFramebuffer();
383
- };
384
-
385
- const render = function() {
386
- gl.useProgram(renderProgram);
387
- gl.activeTexture(gl.TEXTURE0);
388
- gl.bindTexture(gl.TEXTURE_2D, stateFbObjR.texture);
389
- gl.uniform1i(renderUniforms["u_stateTexture"], 0);
390
- gl.uniform1i(renderUniforms["u_target"], parameters["target"]);
391
- gl.uniform1i(
392
- renderUniforms["u_rendering"],
393
- parameters["rendering"]
394
- );
395
- gl.uniform1f(
396
- renderUniforms["u_spaceStep"],
397
- parameters["space step"]
398
- );
399
- renderToFillScreen();
400
- };
401
-
402
- initialize();
403
- let simulationSeconds = 0.0;
404
- let previousRealSeconds = performance.now() * 0.001;
405
- const loop = function() {
406
- const currentRealSeconds = performance.now() * 0.001;
407
- const nextSimulationSeconds =
408
- simulationSeconds +
409
- parameters["time scale"] *
410
- Math.min(0.2, currentRealSeconds - previousRealSeconds);
411
- previousRealSeconds = currentRealSeconds;
412
-
413
- const timeStep = parameters["time step"];
414
- while (nextSimulationSeconds - simulationSeconds > timeStep) {
415
- update(timeStep);
416
- simulationSeconds += timeStep;
417
- }
418
- render();
419
-
420
- animationId = requestAnimationFrame(loop);
421
- };
422
- loop();
423
- };
424
- reset();
425
- })();
@@ -1,252 +0,0 @@
1
- /**
2
- * @param _s27 vec4
3
- */
4
- function permute4(_s27) {
5
- return vec4.modn(vec4.mul(_s27, vec4.addvn(vec4.mulvn(_s27, 34), 1)), 289);
6
- }
7
- /**
8
- * @param _s28 vec3
9
- */
10
- function snoise3(_s28) {
11
- let /*vec3*/ _s29 = vec3.floor(
12
- vec3.addvn(_s28, vec3.dot(_s28, env.vec3n(0.3333333333333333)))
13
- );
14
- let /*vec3*/ _s2a = vec3.addvn(
15
- vec3.sub(_s28, _s29),
16
- vec3.dot(_s29, env.vec3n(0.16666666666666666))
17
- );
18
- let /*vec3*/ _s2b = vec3.step(env.swizzle3(_s2a, 1, 2, 0), _s2a);
19
- let /*vec3*/ _s2c = env.swizzle3(vec3.subnv(1, _s2b), 2, 0, 1);
20
- let /*vec3*/ _s2d = vec3.min(_s2b, _s2c);
21
- let /*vec3*/ _s2e = vec3.max(_s2b, _s2c);
22
- let /*vec3*/ _s2f = vec3.addvn(vec3.sub(_s2a, _s2d), 0.16666666666666666);
23
- let /*vec3*/ _s2g = vec3.addvn(vec3.sub(_s2a, _s2e), 0.3333333333333333);
24
- let /*vec3*/ _s2h = vec3.subvn(_s2a, 0.5);
25
- _s29 = vec3.modn(_s29, 289);
26
- let /*vec4*/ _s2i = permute4(
27
- vec4.add(
28
- permute4(
29
- vec4.add(
30
- permute4(vec4.addnv(_s29[2], [0, _s2d[2], _s2e[2], 1])),
31
- vec4.addnv(_s29[1], [0, _s2d[1], _s2e[1], 1])
32
- )
33
- ),
34
- vec4.addnv(_s29[0], [0, _s2d[0], _s2e[0], 1])
35
- )
36
- );
37
- let /*vec4*/ _s2j = vec4.sub(
38
- _s2i,
39
- vec4.mulnv(
40
- 49,
41
- vec4.floor(
42
- vec4.mulvn(vec4.mulvn(_s2i, 0.142857142857), 0.142857142857)
43
- )
44
- )
45
- );
46
- let /*vec4*/ _s2k = vec4.floor(vec4.mulvn(_s2j, 0.142857142857));
47
- let /*vec4*/ _s2l = vec4.addvn(
48
- vec4.mulvn(_s2k, 0.285714285714),
49
- -0.9285714285715
50
- );
51
- let /*vec4*/ _s2m = vec4.addvn(
52
- vec4.mulvn(
53
- vec4.floor(vec4.sub(_s2j, vec4.mulvn(_s2k, 7))),
54
- 0.285714285714
55
- ),
56
- -0.9285714285715
57
- );
58
- let /*vec4*/ _s2n = vec4.sub(vec4.subnv(1, vec4.abs(_s2l)), vec4.abs(_s2m));
59
- let /*vec4*/ _s2o = vec4.sub1(vec4.step(_s2n, env.vec4n(0)));
60
- let /*vec4*/ _s2p = env.vec4vv(
61
- env.swizzle2(_s2l, 0, 1),
62
- env.swizzle2(_s2m, 0, 1)
63
- );
64
- let /*vec4*/ _s2q = env.vec4vv(
65
- env.swizzle2(_s2l, 2, 3),
66
- env.swizzle2(_s2m, 2, 3)
67
- );
68
- let /*vec4*/ _s2r = vec4.add(
69
- env.swizzle4(_s2p, 0, 2, 1, 3),
70
- vec4.mul(
71
- env.swizzle4(
72
- vec4.addvn(vec4.mulvn(vec4.floor(_s2p), 2), 1),
73
- 0,
74
- 2,
75
- 1,
76
- 3
77
- ),
78
- env.swizzle4(_s2o, 0, 0, 1, 1)
79
- )
80
- );
81
- let /*vec4*/ _s2s = vec4.add(
82
- env.swizzle4(_s2q, 0, 2, 1, 3),
83
- vec4.mul(
84
- env.swizzle4(
85
- vec4.addvn(vec4.mulvn(vec4.floor(_s2q), 2), 1),
86
- 0,
87
- 2,
88
- 1,
89
- 3
90
- ),
91
- env.swizzle4(_s2o, 2, 2, 3, 3)
92
- )
93
- );
94
- let /*vec3*/ _s2t = env.vec3vn(env.swizzle2(_s2r, 0, 1), _s2n[0]);
95
- let /*vec3*/ _s2u = env.vec3vn(env.swizzle2(_s2r, 2, 3), _s2n[1]);
96
- let /*vec3*/ _s2v = env.vec3vn(env.swizzle2(_s2s, 0, 1), _s2n[2]);
97
- let /*vec3*/ _s2w = env.vec3vn(env.swizzle2(_s2s, 2, 3), _s2n[3]);
98
- let /*vec4*/ _s2x = vec4.subnv(
99
- 1.79284291400159,
100
- vec4.mulvn(
101
- [
102
- vec3.dot(_s2t, _s2t),
103
- vec3.dot(_s2u, _s2u),
104
- vec3.dot(_s2v, _s2v),
105
- vec3.dot(_s2w, _s2w)
106
- ],
107
- 0.85373472095314
108
- )
109
- );
110
- _s2t = vec3.mulvn(_s2t, _s2x[0]);
111
- _s2u = vec3.mulvn(_s2u, _s2x[1]);
112
- _s2v = vec3.mulvn(_s2v, _s2x[2]);
113
- _s2w = vec3.mulvn(_s2w, _s2x[3]);
114
- let /*vec4*/ _s2y = vec4.max(
115
- env.vec4n(0),
116
- vec4.subnv(0.6, [
117
- vec3.dot(_s2a, _s2a),
118
- vec3.dot(_s2f, _s2f),
119
- vec3.dot(_s2g, _s2g),
120
- vec3.dot(_s2h, _s2h)
121
- ])
122
- );
123
- _s2y = vec4.mul(_s2y, _s2y);
124
- return (
125
- 42 *
126
- vec4.dot(vec4.mul(_s2y, _s2y), [
127
- vec3.dot(_s2t, _s2a),
128
- vec3.dot(_s2u, _s2f),
129
- vec3.dot(_s2v, _s2g),
130
- vec3.dot(_s2w, _s2h)
131
- ])
132
- );
133
- }
134
- /**
135
- * @param _s72 vec3
136
- * @param _s73 vec3
137
- * @param _s74 float
138
- */
139
- function additive(_s72, _s73, _s74) {
140
- let /*float*/ _s75 = 0;
141
- let /*float*/ _s76 = 0.5;
142
- for (let /*float*/ _s77 = 0; _s77 < 4; _s77++) {
143
- _s75 = _s75 + _s76 * snoise3(vec3.add(_s72, vec3.mulnv(_s77, _s73)));
144
- _s76 = _s76 * _s74;
145
- _s72 = vec3.mulvn(_s72, 2);
146
- }
147
- return _s75;
148
- }
149
- /**
150
- * @param _s51 vec2
151
- * @param _s52 vec2
152
- */
153
- function aspectCorrectedUV(_s51, _s52) {
154
- let /*vec2*/ _s53 = vec2.subvn(vec2.mulvn(vec2.div(_s51, _s52), 2), 1);
155
- _s53[0] = _s53[0] * (_s52[0] / _s52[1]);
156
- return _s53;
157
- }
158
- /**
159
- * @param _s6y vec2
160
- * @param _s6z vec2
161
- * @param _s70 float
162
- */
163
- function mainImage(_s6y, _s6z, _s70) {
164
- let /*vec2*/ _s71 = aspectCorrectedUV(_s6y, _s6z);
165
- let /*float*/ _s78 = additive(env.vec3vn(_s71, _s70), env.vec3n(2), 0.5);
166
- return env.vec4vn(env.vec3n(_s78 * 0.5 + 0.5), 1);
167
- }
168
-
169
- /*
170
- vec4 permute4(in vec4 _s27) {
171
- return mod((_s27 * ((_s27 * 34.0) + 1.0)), 289.0);
172
- }
173
- float snoise3(in vec3 _s28) {
174
- vec3 _s29 = floor((_s28 + dot(_s28, vec3(0.3333333333333333))));
175
- vec3 _s2a = ((_s28 - _s29) + dot(_s29, vec3(0.16666666666666666)));
176
- vec3 _s2b = step(_s2a.yzx, _s2a);
177
- vec3 _s2c = (1.0 - _s2b).zxy;
178
- vec3 _s2d = min(_s2b, _s2c);
179
- vec3 _s2e = max(_s2b, _s2c);
180
- vec3 _s2f = ((_s2a - _s2d) + 0.16666666666666666);
181
- vec3 _s2g = ((_s2a - _s2e) + 0.3333333333333333);
182
- vec3 _s2h = (_s2a - 0.5);
183
- _s29 = mod(_s29, 289.0);
184
- vec4 _s2i = permute4((permute4((permute4((_s29.z + vec4(0.0, _s2d.z, _s2e.z, 1.0))) + (_s29.y + vec4(0.0, _s2d.y, _s2e.y, 1.0)))) + (_s29.x + vec4(0.0, _s2d.x, _s2e.x, 1.0))));
185
- vec4 _s2j = (_s2i - (49.0 * floor(((_s2i * 0.142857142857) * 0.142857142857))));
186
- vec4 _s2k = floor((_s2j * 0.142857142857));
187
- vec4 _s2l = ((_s2k * 0.285714285714) + -0.9285714285715);
188
- vec4 _s2m = ((floor((_s2j - (_s2k * 7.0))) * 0.285714285714) + -0.9285714285715);
189
- vec4 _s2n = ((1.0 - abs(_s2l)) - abs(_s2m));
190
- vec4 _s2o = (-step(_s2n, vec4(0.0)));
191
- vec4 _s2p = vec4(_s2l.xy, _s2m.xy);
192
- vec4 _s2q = vec4(_s2l.zw, _s2m.zw);
193
- vec4 _s2r = (_s2p.xzyw + (((floor(_s2p) * 2.0) + 1.0).xzyw * _s2o.xxyy));
194
- vec4 _s2s = (_s2q.xzyw + (((floor(_s2q) * 2.0) + 1.0).xzyw * _s2o.zzww));
195
- vec3 _s2t = vec3(_s2r.xy, _s2n.x);
196
- vec3 _s2u = vec3(_s2r.zw, _s2n.y);
197
- vec3 _s2v = vec3(_s2s.xy, _s2n.z);
198
- vec3 _s2w = vec3(_s2s.zw, _s2n.w);
199
- vec4 _s2x = (1.79284291400159 - (vec4(dot(_s2t, _s2t), dot(_s2u, _s2u), dot(_s2v, _s2v), dot(_s2w, _s2w)) * 0.85373472095314));
200
- _s2t = (_s2t * _s2x.x);
201
- _s2u = (_s2u * _s2x.y);
202
- _s2v = (_s2v * _s2x.z);
203
- _s2w = (_s2w * _s2x.w);
204
- vec4 _s2y = max(vec4(0.0), (0.6 - vec4(dot(_s2a, _s2a), dot(_s2f, _s2f), dot(_s2g, _s2g), dot(_s2h, _s2h))));
205
- _s2y = (_s2y * _s2y);
206
- return (42.0 * dot((_s2y * _s2y), vec4(dot(_s2t, _s2a), dot(_s2u, _s2f), dot(_s2v, _s2g), dot(_s2w, _s2h))));
207
- }
208
- float additive(in vec3 _s72, in vec3 _s73, in float _s74) {
209
- float _s75 = 0.0;
210
- float _s76 = 0.5;
211
- for(float _s77 = 0.0; (_s77 < 4.0); (_s77++)) {
212
- _s75 = (_s75 + (_s76 * snoise3((_s72 + (_s77 * _s73)))));
213
- _s76 = (_s76 * _s74);
214
- _s72 = (_s72 * 2.0);
215
- }
216
- return _s75;
217
- }
218
- vec2 aspectCorrectedUV(in vec2 _s51, in vec2 _s52) {
219
- vec2 _s53 = (((_s51 / _s52) * 2.0) - 1.0);
220
- _s53.x = (_s53.x * (_s52.x / _s52.y));
221
- return _s53;
222
- }
223
- vec4 mainImage(in vec2 _s6y, in vec2 _s6z, in float _s70) {
224
- vec2 _s71 = aspectCorrectedUV(_s6y, _s6z);
225
- float _s78 = additive(vec3(_s71, _s70), vec3(2.0), 0.5);
226
- return vec4(vec3(((_s78 * 0.5) + 0.5)), 1.0);
227
- }
228
- src.f10117fe.js:34085 #version 100
229
- #ifdef GL_FRAGMENT_PRECISION_HIGH
230
- precision highp int;
231
- precision highp float;
232
- #else
233
- precision mediump int;
234
- precision mediump float;
235
- #endif
236
- #ifndef PI
237
- #define PI 3.141592653589793
238
- #endif
239
- #ifndef TAU
240
- #define TAU 6.283185307179586
241
- #endif
242
- #ifndef HALF_PI
243
- #define HALF_PI 1.570796326794896
244
- #endif
245
-
246
- uniform vec2 resolution;
247
- uniform float time;
248
- attribute vec2 position;
249
- void main() {
250
- gl_Position = vec4(position, 0.0, 1.0);
251
- }
252
- */