instantshader 0.2.0 → 0.3.0
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/dist/index.js +37 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -192,6 +192,7 @@ float grain(vec2 uv, float time) {
|
|
|
192
192
|
//#region src/shaders/flow.ts
|
|
193
193
|
const FRAGMENT$1 = `
|
|
194
194
|
uniform float u_scale;
|
|
195
|
+
uniform float u_curl;
|
|
195
196
|
uniform float u_drift;
|
|
196
197
|
uniform float u_openness;
|
|
197
198
|
uniform float u_grain;
|
|
@@ -236,11 +237,22 @@ void main() {
|
|
|
236
237
|
// composition reorganized every ~3 seconds, measured as more pixel change
|
|
237
238
|
// over 3.5s than the beam prototype showed over 7.5s.
|
|
238
239
|
//
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
|
|
240
|
+
// Curl field frequency, relative to the fbm's. Below 1.0 the currents are
|
|
241
|
+
// LARGER than the colour masses they carry, which is the look: sampled at
|
|
242
|
+
// the same frequency each mass sits inside its own little eddy, the
|
|
243
|
+
// advection only roughens mass edges, and the result is indistinguishable
|
|
244
|
+
// from a plain warped fbm.
|
|
245
|
+
//
|
|
246
|
+
// u_curl replaces what was a hardcoded 0.55, and its default is 1.05
|
|
247
|
+
// because the potential is pnoise now. Classic Perlin's lattice is a unit
|
|
248
|
+
// grid while simplex's skewed cells are roughly 0.7 units, so the same
|
|
249
|
+
// input scale yields visibly coarser features -- fewer closed eddies. 1.05
|
|
250
|
+
// was matched by eye against a reference render of the pre-pnoise look.
|
|
251
|
+
//
|
|
252
|
+
// The visible frame spans curlScale units of noise, so the tile has to be
|
|
253
|
+
// at least twice that or the field repeats inside a single frame, which
|
|
254
|
+
// looks like wallpaper; ceil keeps it integral, which pnoise requires.
|
|
255
|
+
float curlScale = u_scale * u_curl;
|
|
244
256
|
float tile = max(2.0, ceil(curlScale * 2.0));
|
|
245
257
|
|
|
246
258
|
// Straight-line travel through a tiling field: the direction never changes,
|
|
@@ -264,18 +276,18 @@ void main() {
|
|
|
264
276
|
// the NUMBER of steps that turns advection into rotation: one step is a
|
|
265
277
|
// plain directional shove, and at two the point still travels an almost
|
|
266
278
|
// straight chord. The third is where it curves enough to close visible
|
|
267
|
-
// eddies, which is the whole point of the look.
|
|
268
|
-
// 0.08 to 0.055 to keep the total travel about where it was.
|
|
279
|
+
// eddies, which is the whole point of the look.
|
|
269
280
|
//
|
|
270
|
-
//
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
//
|
|
281
|
+
// Step gain 0.19, up from the 0.055 that was tuned against a simplex
|
|
282
|
+
// potential. pnoise carries shallower gradients, so the old gain advected
|
|
283
|
+
// the point far too little and the eddies stopped closing -- the frame went
|
|
284
|
+
// to soft diagonal bands. The gain absorbs that difference rather than the
|
|
285
|
+
// default of u_drift, which stays at 0.5 in its published 0-1 range so the
|
|
286
|
+
// knob means the same thing it always did.
|
|
275
287
|
vec2 advected = uv;
|
|
276
|
-
advected += curl(advected * curlScale + u_seed + drift, tile) * u_drift * 0.
|
|
277
|
-
advected += curl(advected * curlScale + u_seed + drift, tile) * u_drift * 0.
|
|
278
|
-
advected += curl(advected * curlScale + u_seed + drift, tile) * u_drift * 0.
|
|
288
|
+
advected += curl(advected * curlScale + u_seed + drift, tile) * u_drift * 0.19;
|
|
289
|
+
advected += curl(advected * curlScale + u_seed + drift, tile) * u_drift * 0.19;
|
|
290
|
+
advected += curl(advected * curlScale + u_seed + drift, tile) * u_drift * 0.19;
|
|
279
291
|
|
|
280
292
|
float t = fbm2(advected * u_scale + u_seed);
|
|
281
293
|
|
|
@@ -325,6 +337,14 @@ const flow = {
|
|
|
325
337
|
step: .05,
|
|
326
338
|
default: 1.7
|
|
327
339
|
},
|
|
340
|
+
{
|
|
341
|
+
key: "curl",
|
|
342
|
+
label: "Curl",
|
|
343
|
+
min: .3,
|
|
344
|
+
max: 1.6,
|
|
345
|
+
step: .05,
|
|
346
|
+
default: 1.05
|
|
347
|
+
},
|
|
328
348
|
{
|
|
329
349
|
key: "drift",
|
|
330
350
|
label: "Drift",
|
|
@@ -353,7 +373,8 @@ const flow = {
|
|
|
353
373
|
randomParams(rand) {
|
|
354
374
|
return {
|
|
355
375
|
scale: .6 + rand() * 2,
|
|
356
|
-
|
|
376
|
+
curl: .6 + rand() * .7000000000000001,
|
|
377
|
+
drift: .25 + rand() * .75,
|
|
357
378
|
openness: rand() * 1,
|
|
358
379
|
grain: .08
|
|
359
380
|
};
|