@luma.gl/shadertools 9.3.0-alpha.4 → 9.3.0-alpha.8

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 (157) hide show
  1. package/dist/dist.dev.js +4657 -523
  2. package/dist/dist.min.js +1952 -301
  3. package/dist/index.cjs +2804 -406
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +10 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +4 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/preprocessor/preprocessor.d.ts.map +1 -1
  10. package/dist/lib/preprocessor/preprocessor.js +35 -8
  11. package/dist/lib/preprocessor/preprocessor.js.map +1 -1
  12. package/dist/lib/shader-assembler.d.ts +10 -0
  13. package/dist/lib/shader-assembler.d.ts.map +1 -1
  14. package/dist/lib/shader-assembler.js +20 -3
  15. package/dist/lib/shader-assembler.js.map +1 -1
  16. package/dist/lib/shader-assembly/assemble-shaders.d.ts +23 -2
  17. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  18. package/dist/lib/shader-assembly/assemble-shaders.js +211 -11
  19. package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
  20. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts +37 -0
  21. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts.map +1 -0
  22. package/dist/lib/shader-assembly/wgsl-binding-debug.js +140 -0
  23. package/dist/lib/shader-assembly/wgsl-binding-debug.js.map +1 -0
  24. package/dist/lib/shader-generator/glsl/generate-glsl.js +3 -0
  25. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -1
  26. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -1
  27. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +3 -0
  28. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -1
  29. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts +22 -0
  30. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts.map +1 -0
  31. package/dist/lib/shader-module/shader-module-uniform-layout.js +112 -0
  32. package/dist/lib/shader-module/shader-module-uniform-layout.js.map +1 -0
  33. package/dist/lib/shader-module/shader-module.d.ts +12 -6
  34. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  35. package/dist/lib/shader-module/shader-module.js.map +1 -1
  36. package/dist/lib/utils/uniform-types.d.ts +11 -7
  37. package/dist/lib/utils/uniform-types.d.ts.map +1 -1
  38. package/dist/modules/engine/picking/picking.d.ts +3 -0
  39. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  40. package/dist/modules/engine/picking/picking.js +3 -0
  41. package/dist/modules/engine/picking/picking.js.map +1 -1
  42. package/dist/modules/engine/skin/skin.d.ts +30 -0
  43. package/dist/modules/engine/skin/skin.d.ts.map +1 -0
  44. package/dist/modules/engine/skin/skin.js +86 -0
  45. package/dist/modules/engine/skin/skin.js.map +1 -0
  46. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -0
  47. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  48. package/dist/modules/lighting/gouraud-material/gouraud-material.js +3 -0
  49. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  50. package/dist/modules/lighting/ibl/ibl.d.ts +26 -0
  51. package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
  52. package/dist/modules/lighting/ibl/ibl.js +33 -0
  53. package/dist/modules/lighting/ibl/ibl.js.map +1 -0
  54. package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
  55. package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
  56. package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
  57. package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
  58. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
  59. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
  60. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
  61. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
  62. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
  63. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
  64. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
  65. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
  66. package/dist/modules/lighting/lights/lighting-glsl.d.ts +1 -1
  67. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -1
  68. package/dist/modules/lighting/lights/lighting-glsl.js +43 -37
  69. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -1
  70. package/dist/modules/lighting/lights/lighting-wgsl.d.ts +1 -1
  71. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -1
  72. package/dist/modules/lighting/lights/lighting-wgsl.js +46 -18
  73. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -1
  74. package/dist/modules/lighting/lights/lighting.d.ts +104 -62
  75. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  76. package/dist/modules/lighting/lights/lighting.js +107 -68
  77. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  78. package/dist/modules/lighting/no-material/dirlight.d.ts +7 -2
  79. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  80. package/dist/modules/lighting/no-material/dirlight.js +3 -1
  81. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  82. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
  83. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
  84. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +524 -28
  85. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -1
  86. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +2 -2
  87. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
  88. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +784 -101
  89. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -1
  90. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +110 -45
  91. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  92. package/dist/modules/lighting/pbr-material/pbr-material.js +85 -9
  93. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  94. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  95. package/dist/modules/lighting/pbr-material/pbr-projection.js +13 -1
  96. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  97. package/dist/modules/lighting/phong-material/phong-material.d.ts +1 -0
  98. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  99. package/dist/modules/lighting/phong-material/phong-material.js +4 -0
  100. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  101. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  102. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  103. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +15 -4
  104. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  105. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +1 -40
  106. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -1
  107. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +71 -76
  108. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -1
  109. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  110. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  111. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +41 -10
  112. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -1
  113. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +2 -0
  114. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
  115. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +212 -0
  116. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
  117. package/dist/modules/math/fp64/fp64.d.ts +1 -0
  118. package/dist/modules/math/fp64/fp64.d.ts.map +1 -1
  119. package/dist/modules/math/fp64/fp64.js +8 -2
  120. package/dist/modules/math/fp64/fp64.js.map +1 -1
  121. package/dist/modules/math/random/random.d.ts +1 -1
  122. package/dist/modules/math/random/random.d.ts.map +1 -1
  123. package/dist/modules/math/random/random.js +2 -3
  124. package/dist/modules/math/random/random.js.map +1 -1
  125. package/package.json +3 -3
  126. package/src/index.ts +20 -2
  127. package/src/lib/preprocessor/preprocessor.ts +44 -8
  128. package/src/lib/shader-assembler.ts +25 -3
  129. package/src/lib/shader-assembly/assemble-shaders.ts +377 -12
  130. package/src/lib/shader-assembly/wgsl-binding-debug.ts +216 -0
  131. package/src/lib/shader-generator/glsl/generate-glsl.ts +7 -1
  132. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +6 -0
  133. package/src/lib/shader-module/shader-module-uniform-layout.ts +194 -0
  134. package/src/lib/shader-module/shader-module.ts +17 -7
  135. package/src/lib/utils/uniform-types.ts +24 -9
  136. package/src/modules/engine/picking/picking.ts +3 -0
  137. package/src/modules/engine/skin/skin.ts +114 -0
  138. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  139. package/src/modules/lighting/ibl/ibl.ts +44 -0
  140. package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
  141. package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
  142. package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
  143. package/src/modules/lighting/lights/lighting-glsl.ts +43 -37
  144. package/src/modules/lighting/lights/lighting-wgsl.ts +46 -18
  145. package/src/modules/lighting/lights/lighting.ts +198 -99
  146. package/src/modules/lighting/no-material/dirlight.ts +3 -1
  147. package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +524 -28
  148. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +784 -101
  149. package/src/modules/lighting/pbr-material/pbr-material.ts +111 -18
  150. package/src/modules/lighting/pbr-material/pbr-projection.ts +14 -1
  151. package/src/modules/lighting/phong-material/phong-material.ts +5 -0
  152. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +15 -4
  153. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +71 -77
  154. package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +41 -10
  155. package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +212 -0
  156. package/src/modules/math/fp64/fp64.ts +9 -3
  157. package/src/modules/math/random/random.ts +2 -3
@@ -0,0 +1,212 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export const fp64arithmeticWGSL = /* wgsl */ `\
6
+ struct Fp64ArithmeticUniforms {
7
+ ONE: f32,
8
+ SPLIT: f32,
9
+ };
10
+
11
+ @group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
12
+
13
+ fn fp64_nan(seed: f32) -> f32 {
14
+ let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
15
+ return bitcast<f32>(nanBits);
16
+ }
17
+
18
+ fn fp64_runtime_zero() -> f32 {
19
+ return fp64arithmetic.ONE * 0.0;
20
+ }
21
+
22
+ fn prevent_fp64_optimization(value: f32) -> f32 {
23
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
24
+ return value + fp64_runtime_zero();
25
+ #else
26
+ return value;
27
+ #endif
28
+ }
29
+
30
+ fn split(a: f32) -> vec2f {
31
+ let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
32
+ let t = prevent_fp64_optimization(a * splitValue);
33
+ let temp = prevent_fp64_optimization(t - a);
34
+ let aHi = prevent_fp64_optimization(t - temp);
35
+ let aLo = prevent_fp64_optimization(a - aHi);
36
+ return vec2f(aHi, aLo);
37
+ }
38
+
39
+ fn split2(a: vec2f) -> vec2f {
40
+ var b = split(a.x);
41
+ b.y = b.y + a.y;
42
+ return b;
43
+ }
44
+
45
+ fn quickTwoSum(a: f32, b: f32) -> vec2f {
46
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
47
+ let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);
48
+ let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);
49
+ #else
50
+ let sum = prevent_fp64_optimization(a + b);
51
+ let err = prevent_fp64_optimization(b - (sum - a));
52
+ #endif
53
+ return vec2f(sum, err);
54
+ }
55
+
56
+ fn twoSum(a: f32, b: f32) -> vec2f {
57
+ let s = prevent_fp64_optimization(a + b);
58
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
59
+ let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
60
+ let err =
61
+ prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
62
+ fp64arithmetic.ONE *
63
+ fp64arithmetic.ONE *
64
+ fp64arithmetic.ONE) +
65
+ prevent_fp64_optimization(b - v);
66
+ #else
67
+ let v = prevent_fp64_optimization(s - a);
68
+ let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);
69
+ #endif
70
+ return vec2f(s, err);
71
+ }
72
+
73
+ fn twoSub(a: f32, b: f32) -> vec2f {
74
+ let s = prevent_fp64_optimization(a - b);
75
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
76
+ let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
77
+ let err =
78
+ prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
79
+ fp64arithmetic.ONE *
80
+ fp64arithmetic.ONE *
81
+ fp64arithmetic.ONE) -
82
+ prevent_fp64_optimization(b + v);
83
+ #else
84
+ let v = prevent_fp64_optimization(s - a);
85
+ let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);
86
+ #endif
87
+ return vec2f(s, err);
88
+ }
89
+
90
+ fn twoSqr(a: f32) -> vec2f {
91
+ let prod = prevent_fp64_optimization(a * a);
92
+ let aFp64 = split(a);
93
+ let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);
94
+ let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);
95
+ let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);
96
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
97
+ let err =
98
+ (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +
99
+ crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +
100
+ lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
101
+ #else
102
+ let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);
103
+ #endif
104
+ return vec2f(prod, err);
105
+ }
106
+
107
+ fn twoProd(a: f32, b: f32) -> vec2f {
108
+ let prod = prevent_fp64_optimization(a * b);
109
+ let aFp64 = split(a);
110
+ let bFp64 = split(b);
111
+ let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);
112
+ let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);
113
+ let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);
114
+ let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);
115
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
116
+ let err1 = (highProduct - prod) * fp64arithmetic.ONE;
117
+ let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;
118
+ let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
119
+ let err4 =
120
+ lowProduct *
121
+ fp64arithmetic.ONE *
122
+ fp64arithmetic.ONE *
123
+ fp64arithmetic.ONE *
124
+ fp64arithmetic.ONE;
125
+ #else
126
+ let err1 = highProduct - prod;
127
+ let err2 = crossProduct1;
128
+ let err3 = crossProduct2;
129
+ let err4 = lowProduct;
130
+ #endif
131
+ let err12InputA = prevent_fp64_optimization(err1);
132
+ let err12InputB = prevent_fp64_optimization(err2);
133
+ let err12 = prevent_fp64_optimization(err12InputA + err12InputB);
134
+ let err123InputA = prevent_fp64_optimization(err12);
135
+ let err123InputB = prevent_fp64_optimization(err3);
136
+ let err123 = prevent_fp64_optimization(err123InputA + err123InputB);
137
+ let err1234InputA = prevent_fp64_optimization(err123);
138
+ let err1234InputB = prevent_fp64_optimization(err4);
139
+ let err = prevent_fp64_optimization(err1234InputA + err1234InputB);
140
+ return vec2f(prod, err);
141
+ }
142
+
143
+ fn sum_fp64(a: vec2f, b: vec2f) -> vec2f {
144
+ var s = twoSum(a.x, b.x);
145
+ let t = twoSum(a.y, b.y);
146
+ s.y = prevent_fp64_optimization(s.y + t.x);
147
+ s = quickTwoSum(s.x, s.y);
148
+ s.y = prevent_fp64_optimization(s.y + t.y);
149
+ s = quickTwoSum(s.x, s.y);
150
+ return s;
151
+ }
152
+
153
+ fn sub_fp64(a: vec2f, b: vec2f) -> vec2f {
154
+ var s = twoSub(a.x, b.x);
155
+ let t = twoSub(a.y, b.y);
156
+ s.y = prevent_fp64_optimization(s.y + t.x);
157
+ s = quickTwoSum(s.x, s.y);
158
+ s.y = prevent_fp64_optimization(s.y + t.y);
159
+ s = quickTwoSum(s.x, s.y);
160
+ return s;
161
+ }
162
+
163
+ fn mul_fp64(a: vec2f, b: vec2f) -> vec2f {
164
+ var prod = twoProd(a.x, b.x);
165
+ let crossProduct1 = prevent_fp64_optimization(a.x * b.y);
166
+ prod.y = prevent_fp64_optimization(prod.y + crossProduct1);
167
+ #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
168
+ prod = split2(prod);
169
+ #endif
170
+ prod = quickTwoSum(prod.x, prod.y);
171
+ let crossProduct2 = prevent_fp64_optimization(a.y * b.x);
172
+ prod.y = prevent_fp64_optimization(prod.y + crossProduct2);
173
+ #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
174
+ prod = split2(prod);
175
+ #endif
176
+ prod = quickTwoSum(prod.x, prod.y);
177
+ return prod;
178
+ }
179
+
180
+ fn div_fp64(a: vec2f, b: vec2f) -> vec2f {
181
+ let xn = prevent_fp64_optimization(1.0 / b.x);
182
+ let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));
183
+ let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);
184
+ let prod = twoProd(xn, diff);
185
+ return sum_fp64(yn, prod);
186
+ }
187
+
188
+ fn sqrt_fp64(a: vec2f) -> vec2f {
189
+ if (a.x == 0.0 && a.y == 0.0) {
190
+ return vec2f(0.0, 0.0);
191
+ }
192
+ if (a.x < 0.0) {
193
+ let nanValue = fp64_nan(a.x);
194
+ return vec2f(nanValue, nanValue);
195
+ }
196
+
197
+ let x = prevent_fp64_optimization(1.0 / sqrt(a.x));
198
+ let yn = prevent_fp64_optimization(a.x * x);
199
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
200
+ let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;
201
+ #else
202
+ let ynSqr = twoSqr(yn);
203
+ #endif
204
+ let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);
205
+ let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);
206
+ #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
207
+ return sum_fp64(split(yn), prod);
208
+ #else
209
+ return sum_fp64(vec2f(yn, 0.0), prod);
210
+ #endif
211
+ }
212
+ `;
@@ -6,10 +6,11 @@ import {ShaderModule} from '../../../lib/shader-module/shader-module';
6
6
 
7
7
  import {fp64ify, fp64LowPart, fp64ifyMatrix4} from '../../../modules/math/fp64/fp64-utils';
8
8
  import {fp64arithmeticShader} from './fp64-arithmetic-glsl';
9
+ import {fp64arithmeticWGSL} from './fp64-arithmetic-wgsl';
9
10
  import {fp64functionShader} from './fp64-functions-glsl';
10
11
 
11
12
  type FP64Props = {};
12
- type FP64Uniforms = {ONE: number};
13
+ type FP64Uniforms = {ONE: number; SPLIT: number};
13
14
  type FP64Bindings = {};
14
15
 
15
16
  type FP64Utilities = {
@@ -20,7 +21,10 @@ type FP64Utilities = {
20
21
 
21
22
  const defaultUniforms: FP64Uniforms = {
22
23
  // Used in LUMA_FP64_CODE_ELIMINATION_WORKAROUND
23
- ONE: 1.0
24
+ ONE: 1.0,
25
+ // Runtime split factor for Dekker splitting. Keeping this as a uniform helps
26
+ // prevent aggressive constant folding in shader compilers.
27
+ SPLIT: 4097.0
24
28
  };
25
29
 
26
30
  /**
@@ -28,9 +32,11 @@ const defaultUniforms: FP64Uniforms = {
28
32
  */
29
33
  export const fp64arithmetic: ShaderModule<FP64Props, FP64Uniforms, FP64Bindings> & FP64Utilities = {
30
34
  name: 'fp64arithmetic',
35
+ source: fp64arithmeticWGSL,
36
+ fs: fp64arithmeticShader,
31
37
  vs: fp64arithmeticShader,
32
38
  defaultUniforms,
33
- uniformTypes: {ONE: 'f32'},
39
+ uniformTypes: {ONE: 'f32', SPLIT: 'f32'},
34
40
 
35
41
  // Additional Functions
36
42
  fp64ify,
@@ -5,9 +5,8 @@
5
5
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
6
6
 
7
7
  const source = /* wgsl */ `\
8
- fn random(scale: vec3f, seed: float) -> f32 {
9
- /* use the fragment position for a different seed per-pixel */
10
- return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
8
+ fn random(scale: vec3f, seed: f32) -> f32 {
9
+ return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);
11
10
  }
12
11
  `;
13
12