react-native-webrtc-kaleidoscope 2.6.1 → 2.7.1

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.
Files changed (34) hide show
  1. package/android/src/main/java/com/simiancraft/kaleidoscope/gpu/ShadersGenerated.kt +205 -31
  2. package/catalog/composites/nebula/nebula.thumb.webp +0 -0
  3. package/catalog/shaders/data-mesh/data-mesh.form.tsx +53 -0
  4. package/catalog/shaders/data-mesh/data-mesh.frag +205 -0
  5. package/catalog/shaders/data-mesh/data-mesh.ts +225 -0
  6. package/catalog/shaders/index.ts +4 -0
  7. package/catalog/shaders/nebula/nebula.frag +11 -3
  8. package/catalog/shaders/outrun-grid/outrun-grid.frag +40 -36
  9. package/catalog/shaders/outrun-grid/outrun-grid.ts +2 -2
  10. package/dist/catalog/composites/nebula/nebula.thumb.webp +0 -0
  11. package/dist/catalog/shaders/data-mesh/data-mesh.d.ts +50 -0
  12. package/dist/catalog/shaders/data-mesh/data-mesh.d.ts.map +1 -0
  13. package/dist/catalog/shaders/data-mesh/data-mesh.form.d.ts +3 -0
  14. package/dist/catalog/shaders/data-mesh/data-mesh.form.d.ts.map +1 -0
  15. package/dist/catalog/shaders/data-mesh/data-mesh.form.js +15 -0
  16. package/dist/catalog/shaders/data-mesh/data-mesh.form.js.map +1 -0
  17. package/dist/catalog/shaders/data-mesh/data-mesh.js +179 -0
  18. package/dist/catalog/shaders/data-mesh/data-mesh.js.map +1 -0
  19. package/dist/catalog/shaders/index.d.ts +4 -0
  20. package/dist/catalog/shaders/index.d.ts.map +1 -1
  21. package/dist/catalog/shaders/index.js +3 -1
  22. package/dist/catalog/shaders/index.js.map +1 -1
  23. package/dist/catalog/shaders/outrun-grid/outrun-grid.js +2 -2
  24. package/dist/catalog/shaders/outrun-grid/outrun-grid.js.map +1 -1
  25. package/dist/web-driver/shaders.generated.d.ts +3 -2
  26. package/dist/web-driver/shaders.generated.d.ts.map +1 -1
  27. package/dist/web-driver/shaders.generated.js +205 -32
  28. package/dist/web-driver/shaders.generated.js.map +1 -1
  29. package/ios/KaleidoscopeModule/shaders/GENERATIVE.txt +1 -0
  30. package/ios/KaleidoscopeModule/shaders/SHADERS.txt +1 -0
  31. package/ios/KaleidoscopeModule/shaders/data-mesh.metalsrc +99 -0
  32. package/ios/KaleidoscopeModule/shaders/nebula.metalsrc +56 -51
  33. package/ios/KaleidoscopeModule/shaders/outrun-grid.metalsrc +12 -14
  34. package/package.json +8 -1
@@ -2,7 +2,7 @@
2
2
  // @generated by scripts/build-shaders.ts from shaders/. DO NOT EDIT.
3
3
  // Run `bun run build:shaders` to regenerate.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.SHADER_SOURCES = exports.CORPORATE_BLOBS_FRAG_SRC = exports.LIGHT_BEAMS_AND_MOTES_FRAG_SRC = exports.ANAMORPHIC_LENSFLARE_FRAG_SRC = exports.SIMIANLIGHTS_FRAG_SRC = exports.FIREFLIES_FRAG_SRC = exports.GODRAYS_FRAG_SRC = exports.NEBULA_FRAG_SRC = exports.CLOUDS_FRAG_SRC = exports.OUTRUN_GRID_FRAG_SRC = exports.AURORA_SILK_FRAG_SRC = exports.HALFTONE_WAVES_FRAG_SRC = exports.NEO_MEMPHIS_FRAG_SRC = exports.KALEIDOSCOPE_FRAG_SRC = exports.PLASMA_FRAG_SRC = exports.COMPOSITE_MASKED_FRAG_SRC = exports.COMPOSITE_SUBJECT_FRAG_SRC = exports.COMPOSITE_IMAGE_FRAG_SRC = exports.COMPOSITE_BLUR_FRAG_SRC = exports.COMPOSITE_CAMERA_FRAG_SRC = exports.PASSTHROUGH_VERT_SRC = void 0;
5
+ exports.SHADER_SOURCES = exports.DATA_MESH_FRAG_SRC = exports.CORPORATE_BLOBS_FRAG_SRC = exports.LIGHT_BEAMS_AND_MOTES_FRAG_SRC = exports.ANAMORPHIC_LENSFLARE_FRAG_SRC = exports.SIMIANLIGHTS_FRAG_SRC = exports.FIREFLIES_FRAG_SRC = exports.GODRAYS_FRAG_SRC = exports.NEBULA_FRAG_SRC = exports.CLOUDS_FRAG_SRC = exports.OUTRUN_GRID_FRAG_SRC = exports.AURORA_SILK_FRAG_SRC = exports.HALFTONE_WAVES_FRAG_SRC = exports.NEO_MEMPHIS_FRAG_SRC = exports.KALEIDOSCOPE_FRAG_SRC = exports.PLASMA_FRAG_SRC = exports.COMPOSITE_MASKED_FRAG_SRC = exports.COMPOSITE_SUBJECT_FRAG_SRC = exports.COMPOSITE_IMAGE_FRAG_SRC = exports.COMPOSITE_BLUR_FRAG_SRC = exports.COMPOSITE_CAMERA_FRAG_SRC = exports.PASSTHROUGH_VERT_SRC = void 0;
6
6
  exports.PASSTHROUGH_VERT_SRC = `#version 300 es
7
7
  precision highp float;
8
8
  out highp vec2 vUv;
@@ -537,34 +537,38 @@ void main() {
537
537
 
538
538
  col = mix(col, sunCol, sunBody);
539
539
  } else {
540
- // --- FLOOR --- perspective grid. Guard the divide; shade only below horizon.
541
- float depth = 1.0 / max(h - fy, 1.5e-3); // large near the horizon
542
- float depthMin = 1.0 / h; // depth at the very front (fy = 0)
543
-
544
- // Grid coordinates: x widens with depth (perspective); uGridDensity sets the
545
- // cell count; the scroll is in cell units so its rate is density-independent.
546
- vec2 g = vec2(fx * depth, depth) * uGridDensity;
547
- g.y += uTime * uSpeed * 2.0;
548
- vec2 cell = abs(fract(g) - 0.5); // 0 on a line .. 0.5 mid-cell, per axis
549
-
550
- // Per-axis, depth-scaled line half-width: the rungs (g.y) compress toward the
551
- // horizon as depth^2 and the verticals (g.x) ~linearly, so widening each axis'
552
- // line band at its own compression rate holds the on-screen line width roughly
553
- // constant. Far lines fuse into a band instead of a sub-pixel sheet that
554
- // shimmers as it scrolls; near lines stay crisp. Written 1 - smoothstep(0, w, .)
555
- // (NOT the reversed-edge smoothstep(w, 0, .), which is undefined on GLSL ES /
556
- // Metal) and derivative-free, so it is portable and mobile-precision safe.
557
- vec2 w = max(vec2(depth, depth * depth * 0.2) * uGridDensity * 0.0013, vec2(1e-4));
558
- vec2 core = 1.0 - smoothstep(vec2(0.0), w, cell);
559
- vec2 halo = (1.0 - smoothstep(vec2(0.0), w * 6.0, cell)) * (0.5 * uGridGlow);
560
- float gridVal = clamp(core.x + core.y + halo.x + halo.y, 0.0, 1.5);
561
-
562
- // Distance fog: fade the grid out toward the horizon for the converging look.
563
- float fog = clamp(1.0 - (depth - depthMin) / (depthMin * 10.0), 0.0, 1.0);
564
- fog *= fog;
565
-
566
- vec3 floorBase = mix(vec3(0.0), uSkyHorizon * 0.16, fog * 0.6);
567
- col = floorBase + uGridColor * gridVal * fog * calm;
540
+ // --- FLOOR --- perspective grid, a faithful port of a known-good community
541
+ // outrun grid (prior versions read as a too-dense, flickering sheet). Work in
542
+ // the reference's centered frame: cx is full-width centered x, dy is the
543
+ // centered distance BELOW the horizon. The additive offset caps the depth at
544
+ // the horizon, and putting big cells in the near field (low min depth) is what
545
+ // keeps the line spacing above a pixel, so it neither sheets nor shimmers.
546
+ float cx = 2.0 * fx; // = (2*vUv.x - 1) * aspect
547
+ float dy = 2.0 * (h - fy); // centered distance below the horizon (> 0)
548
+
549
+ // Cell count: uGridDensity 4 -> numerator 1.0 (sparse, big near cells). x
550
+ // widens with depth (the 0.7 factor); scroll is a slow drift toward the viewer.
551
+ float num = uGridDensity * 0.25;
552
+ float depth = num / (dy + 0.05);
553
+ vec2 g = vec2(cx * depth * 0.7, depth);
554
+ g.y += uTime * uSpeed * 0.3;
555
+ vec2 e = abs(fract(g) - 0.5);
556
+
557
+ // PIXEL-CALIBRATED line width: each line core is a fixed ~px wide in SCREEN
558
+ // PIXELS (via uResolution), the same at every depth and every resolution. The
559
+ // old depth^2*const width was constant in theory but landed sub-pixel, so
560
+ // discrete sampling rendered some rungs thick and others thin -> the uneven
561
+ // rungs that read as flicker. Solving sz so screen thickness == px: the rungs
562
+ // (g.y, compression ~depth^2/num) need sz.y = depth^2 * pf / num; the verticals
563
+ // (g.x) need sz.x = depth * 0.7 * pf. uGridGlow sets px (0.5 -> 2 px).
564
+ float pf = (uGridGlow * 4.0) / uResolution.y;
565
+ vec2 sz = vec2(depth * 0.7 * pf, depth * depth * pf / num);
566
+ vec2 lines = 1.0 - smoothstep(vec2(0.0), sz, e);
567
+ lines += (1.0 - smoothstep(vec2(0.0), sz * 4.0, e)) * 0.5;
568
+ float gridVal = clamp(lines.x + lines.y, 0.0, 1.0);
569
+
570
+ vec3 floorBase = uSkyHorizon * 0.06;
571
+ col = mix(floorBase, uGridColor, gridVal * calm);
568
572
  }
569
573
 
570
574
  // Glowing horizon seam where floor meets sky.
@@ -710,9 +714,11 @@ const float MIN_DIVIDE = 64.0;
710
714
  const float MAX_DIVIDE = 0.01;
711
715
  // Number of stacked starfield layers. Compile-time constant so the layer
712
716
  // loop has a fixed integer bound (cross-compile-safe; no float loop counter).
713
- // 8 (was 12) for low-end-mobile cost (issue #39); the work is linear in the
714
- // count and dimByDensity rebalances per-star brightness automatically.
715
- const int STARFIELD_LAYERS_COUNT = 8;
717
+ // 7 (was 8 #74, was 12 #39) for cost; the work is linear in the count and
718
+ // dimByDensity rebalances per-star brightness automatically. 7 keeps the dense
719
+ // look essentially intact (6 was visibly sparser at some animation phases);
720
+ // paired with the empty-cell early-out below it lands ~34% under the old 8.
721
+ const int STARFIELD_LAYERS_COUNT = 7;
716
722
 
717
723
  mat2 Rotate(float angle) {
718
724
  float s = sin(angle);
@@ -780,6 +786,12 @@ vec3 StarFieldLayer(vec2 uv, float rotAngle) {
780
786
  float size = fract(randomN * 1356.33);
781
787
  float flareSwitch = smoothstep(0.9, 1.0, size);
782
788
  float star = Star(randomPosition, flareSwitch, rotAngle, randomN);
789
+ // The per-cell color below is multiplied by \`star\` at the end, so for any
790
+ // cell whose star is 0 (Star() returns exactly 0 for d >= 1.0, i.e. the
791
+ // empty-sky majority of the 8x9 = 72 cells/pixel) the whole term is 0.
792
+ // Skipping the sin(vec3) color work for those cells is output-identical and
793
+ // is the bulk of the win (issue #74).
794
+ if (star <= 0.0) continue;
783
795
 
784
796
  // fract trick: random colors
785
797
  float randomStarColorSeed = fract(randomN * 2150.0) * (3.0 * PI) * deltaTimeTwinkle;
@@ -1643,6 +1655,166 @@ void main() {
1643
1655
  oColor = vec4(blobCol * uColor, blobAlpha);
1644
1656
  }
1645
1657
  `;
1658
+ exports.DATA_MESH_FRAG_SRC = `#version 300 es
1659
+ precision highp float;
1660
+
1661
+ uniform float uTime; // seconds, monotonically increasing; range [0, inf)
1662
+ uniform vec2 uResolution; // framebuffer size in pixels; both components > 0
1663
+ uniform vec3 uBgTop; // background gradient color at the top of frame
1664
+ uniform vec3 uBgBottom; // background gradient color at the bottom of frame
1665
+ uniform vec3 uLineColor; // mid wireframe-line tint (the trough/body color)
1666
+ uniform vec3 uCrestColor; // crest highlight color (brightest along the peaks)
1667
+ uniform vec3 uHazeColor; // atmospheric haze tint on the far rows
1668
+ uniform vec3 uAccentColor; // the one restrained accent (e.g. enterprise red)
1669
+ uniform float uWaveScale; // wave-field spatial frequency; lower = looser, broader hills
1670
+ uniform float uWaveAmp; // vertical wave displacement amount (near rows)
1671
+ uniform float uWaveSpeed; // animation rate; 0 freezes the surface
1672
+ uniform float uGridX; // column-grid density across the surface; keep loose
1673
+ uniform float uHorizon; // horizon height in uv.y units (rows converge toward it)
1674
+ uniform float uFarScale; // perspective scale of the farthest row, 0.05..0.5 (>0)
1675
+ uniform float uSlant; // diagonal tilt; raises the right side for corner composition
1676
+ uniform float uLineWidth; // wireframe line half-width (smaller = finer, sharper)
1677
+ uniform float uNodeMix; // 0..1 emphasis of glowing intersection nodes (dot reading)
1678
+ uniform float uStrutMix; // 0..1 emphasis of vertical struts (wireframe reading)
1679
+ uniform float uGlow; // overall additive mesh-glow / bloom strength
1680
+ uniform float uHaze; // atmospheric far-haze strength
1681
+ uniform float uParticles; // floating-particle intensity; 0 disables the field
1682
+ uniform float uAccent; // lone accent-mote intensity; 0 disables it
1683
+ uniform float uCalm; // 0..1 eases the additive glow at frame center (face zone)
1684
+
1685
+ in highp vec2 vUv;
1686
+ out vec4 oColor;
1687
+
1688
+ // ROWS / PARTICLES must stay compile-time constants (GLSL ES loop bounds). ROWS is
1689
+ // kept modest on purpose (loose mesh); perspective bunching toward the horizon
1690
+ // makes it read as far more lines than it costs.
1691
+ #define ROWS 18
1692
+ #define PARTICLES 10
1693
+ #define WAVE_DEPTH_SPAN 4.5 // world-depth the eased row range maps across
1694
+ #define COL_SHARP 48.0 // column-stripe sharpness in cell-phase units
1695
+ #define Y_NEAR (-0.62) // nearest row baseline (just below the bottom edge)
1696
+
1697
+ // Cheap stable hash for the particle field (highp; the 43758.5453 multiplier
1698
+ // bands under mediump, same note as clouds/nebula).
1699
+ float hash11(float n) {
1700
+ return fract(sin(n * 12.9898) * 43758.5453123);
1701
+ }
1702
+
1703
+ // The shared surface. x is perspective world-x, z is eased world-depth, t is time.
1704
+ // A small sum of sines whose x/z cross terms produce the hills, valleys, and
1705
+ // saddles; bounded to roughly [-1.6, 1.6].
1706
+ float waveField(float x, float z, float t) {
1707
+ float h = 0.0;
1708
+ h += sin(x * 1.00 + z * 0.55 + t) * 0.60;
1709
+ h += sin(x * 0.55 - z * 0.95 - t * 0.70) * 0.45;
1710
+ h += sin((x + z) * 0.45 + t * 0.40 + 1.7) * 0.40; // diagonal ridges -> saddles
1711
+ h += sin(x * 1.70 - z * 0.30 + t * 1.20) * 0.16; // fine ripple
1712
+ return h;
1713
+ }
1714
+
1715
+ void main() {
1716
+ vec2 fragCoord = vUv * uResolution;
1717
+ vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y; // centered, aspect-correct
1718
+
1719
+ // Background: smooth vertical gradient, no texture. g = 0 bottom .. 1 top.
1720
+ float g = clamp(uv.y + 0.5, 0.0, 1.0);
1721
+ vec3 col = mix(uBgBottom, uBgTop, g);
1722
+
1723
+ // Ease additive glow near the frame center (the subject's face sits there).
1724
+ float calm = 1.0 - uCalm * (1.0 - smoothstep(0.18, 0.62, length(uv)));
1725
+
1726
+ float t = uTime * uWaveSpeed;
1727
+ float horizon = clamp(uHorizon, -0.2, 0.45);
1728
+
1729
+ // Line-glow widths from the half-width. The core line keeps the one exp() (its
1730
+ // sharp gaussian is the wireframe signature); the bloom halo and the vertical
1731
+ // strut use rational falloffs (1/(1+k·dy^2)) instead of more exp() calls, which
1732
+ // are ~8x-weighted transcendentals on the hot per-row path. The node reuses the
1733
+ // core exp directly. Net: 2 exp/row (core + column), down from 5.
1734
+ float coreSharp = 1.0 / max(uLineWidth * uLineWidth, 1e-5);
1735
+ float haloK = coreSharp * 0.14; // rational-bloom width (matches the old halo half-width)
1736
+ float strutK = coreSharp * 0.14; // rational vertical-bridge width
1737
+
1738
+ vec3 mesh = vec3(0.0);
1739
+ vec3 haze = vec3(0.0);
1740
+
1741
+ for (int i = 0; i < ROWS; i++) {
1742
+ float rowT = float(i) / float(ROWS - 1); // 0 near .. 1 far
1743
+ float om = 1.0 - rowT;
1744
+ float f = 1.0 - om * om; // eased depth: rows bunch toward horizon
1745
+ float persp = mix(1.0, uFarScale, f);
1746
+ persp = max(persp, uFarScale); // guard the divide (uFarScale > 0)
1747
+
1748
+ // Row baseline in screen-y, with a diagonal tilt for corner composition.
1749
+ float baseY = mix(Y_NEAR, horizon, f) + uv.x * uSlant * persp;
1750
+
1751
+ // Early-out: skip the sines for any row that cannot reach this pixel. Margin
1752
+ // covers the max wave displacement plus the strut's vertical bridge.
1753
+ float reach = persp * uWaveAmp * 1.7 + uLineWidth * 3.0 + 0.06;
1754
+ if (abs(uv.y - baseY) > reach) continue;
1755
+
1756
+ float worldX = uv.x / persp;
1757
+ float h = waveField(worldX * uWaveScale, f * WAVE_DEPTH_SPAN, t);
1758
+ float surfY = baseY + persp * uWaveAmp * h;
1759
+ float dy = uv.y - surfY;
1760
+
1761
+ // Crest factor: peaks of the field glow white, troughs stay the line tint.
1762
+ float crest = smoothstep(0.2, 1.4, h);
1763
+
1764
+ // Horizontal ribbon: sharp gaussian core (the line) + rational bloom halo.
1765
+ float dy2 = dy * dy;
1766
+ float core = exp(-dy2 * coreSharp);
1767
+ float ribbon = core + 0.22 / (1.0 + dy2 * haloK);
1768
+
1769
+ // Column grid: one bright stripe per cell of worldX. cph = 0 at the stripe.
1770
+ float cph = fract(worldX * uGridX) - 0.5;
1771
+ float colLine = exp(-cph * cph * COL_SHARP);
1772
+
1773
+ // Vertical strut (rational falloff in y so it bridges toward neighbors, gated
1774
+ // by the column) and the intersection node (core line x column -> a glowing
1775
+ // dot; reuses the core exp, no extra transcendental).
1776
+ float strut = colLine / (1.0 + dy2 * strutK);
1777
+ float node = core * colLine;
1778
+
1779
+ // Atmospheric fade: far rows dim and tint toward the haze color.
1780
+ float fade = om * om; // 1 near .. 0 far
1781
+ float lit = ribbon + uStrutMix * strut + uNodeMix * node * 2.0;
1782
+ vec3 lineCol = mix(uLineColor, uCrestColor, crest);
1783
+
1784
+ // Crest-dominant brightness: troughs stay dim, peaks carry the illumination.
1785
+ mesh += lineCol * lit * fade * (0.35 + 1.0 * crest);
1786
+ haze += uHazeColor * ribbon * (1.0 - fade) * crest;
1787
+ }
1788
+
1789
+ col += mesh * uGlow * calm;
1790
+ col += haze * uHaze * calm;
1791
+
1792
+ // Sparse floating particles; index 0 is the lone accent mote (independent of
1793
+ // uParticles so an accent can show with the particle field off).
1794
+ if (uParticles > 0.0 || uAccent > 0.0) {
1795
+ vec3 motes = vec3(0.0);
1796
+ for (int p = 0; p < PARTICLES; p++) {
1797
+ float fp = float(p);
1798
+ vec2 seed = vec2(hash11(fp * 1.7 + 0.3), hash11(fp * 3.1 + 1.9));
1799
+ vec2 ppos = (seed * 2.0 - 1.0) * vec2(0.92, 0.46);
1800
+ ppos.x += sin(uTime * 0.07 + fp * 2.3) * 0.03;
1801
+ ppos.y += cos(uTime * 0.05 + fp * 1.7) * 0.03;
1802
+ float twinkle = 0.5 + 0.5 * sin(uTime * (0.6 + hash11(fp * 5.0)) + fp * 4.0);
1803
+ float pd = length(uv - ppos);
1804
+ float glint = exp(-pd * pd * 2300.0) * twinkle;
1805
+ vec3 pcol = (p == 0) ? uAccentColor * uAccent : uCrestColor * uParticles;
1806
+ motes += pcol * glint;
1807
+ }
1808
+ col += motes * calm;
1809
+ }
1810
+
1811
+ // Soft highlight rolloff: fold the additive foreground pile-up into clean white
1812
+ // crests instead of a clipped slab; leaves the dark gradient essentially intact.
1813
+ col = vec3(1.0) - exp(-col);
1814
+
1815
+ oColor = vec4(col, 1.0);
1816
+ }
1817
+ `;
1646
1818
  // Generative background shaders, by name. The generic shader processor and the
1647
1819
  // dispatch iterate this; adding a generative .frag adds an entry here.
1648
1820
  exports.SHADER_SOURCES = {
@@ -1660,5 +1832,6 @@ exports.SHADER_SOURCES = {
1660
1832
  'anamorphic-lensflare': exports.ANAMORPHIC_LENSFLARE_FRAG_SRC,
1661
1833
  'light-beams-and-motes': exports.LIGHT_BEAMS_AND_MOTES_FRAG_SRC,
1662
1834
  'corporate-blobs': exports.CORPORATE_BLOBS_FRAG_SRC,
1835
+ 'data-mesh': exports.DATA_MESH_FRAG_SRC,
1663
1836
  };
1664
1837
  //# sourceMappingURL=shaders.generated.js.map