luxscura 0.1.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/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/aabb.d.ts +9 -0
- package/dist/appearances/glossy/appearance.d.ts +16 -0
- package/dist/appearances/glossy/index.d.ts +2 -0
- package/dist/appearances/glossy/material.d.ts +20 -0
- package/dist/appearances/matte.d.ts +16 -0
- package/dist/appearances/pbr/appearance.d.ts +42 -0
- package/dist/appearances/pbr/index.d.ts +2 -0
- package/dist/appearances/pbr/material.d.ts +27 -0
- package/dist/cube-vertices.d.ts +1 -0
- package/dist/glossy.js +336 -0
- package/dist/glossy.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1393 -0
- package/dist/index.js.map +1 -0
- package/dist/lighting.d.ts +44 -0
- package/dist/matte.js +182 -0
- package/dist/matte.js.map +1 -0
- package/dist/pbr.js +1179 -0
- package/dist/pbr.js.map +1 -0
- package/dist/program.d.ts +128 -0
- package/dist/renderer.d.ts +64 -0
- package/package.json +68 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1393 @@
|
|
|
1
|
+
import { arrayOf as e, bool as t, builtin as n, f32 as r, interpolate as i, mat4x4f as a, struct as o, u32 as s, vec2f as c, vec3b as l, vec3f as u, vec4f as d } from "typegpu/data";
|
|
2
|
+
import { discard as f, length as p, min as m, normalize as h, select as g } from "typegpu/std";
|
|
3
|
+
import { tgpu as _ } from "typegpu";
|
|
4
|
+
//#region src/aabb.ts
|
|
5
|
+
var v = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t, n, i) {
|
|
6
|
+
"use gpu";
|
|
7
|
+
return t > 0 ? __tsover_div(__tsover_sub(i, e), t) : t < 0 ? __tsover_div(__tsover_sub(n, e), t) : r(1e9);
|
|
8
|
+
}), {
|
|
9
|
+
v: 2,
|
|
10
|
+
name: "axisExitDistance",
|
|
11
|
+
ast: {
|
|
12
|
+
params: [
|
|
13
|
+
{
|
|
14
|
+
type: "i",
|
|
15
|
+
name: "position"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "i",
|
|
19
|
+
name: "direction"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: "i",
|
|
23
|
+
name: "minimum"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "i",
|
|
27
|
+
name: "maximum"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
body: [0, [
|
|
31
|
+
[
|
|
32
|
+
11,
|
|
33
|
+
[
|
|
34
|
+
1,
|
|
35
|
+
"direction",
|
|
36
|
+
">",
|
|
37
|
+
[5, "0"]
|
|
38
|
+
],
|
|
39
|
+
[10, [
|
|
40
|
+
1,
|
|
41
|
+
[
|
|
42
|
+
1,
|
|
43
|
+
"maximum",
|
|
44
|
+
"-",
|
|
45
|
+
"position"
|
|
46
|
+
],
|
|
47
|
+
"/",
|
|
48
|
+
"direction"
|
|
49
|
+
]]
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
11,
|
|
53
|
+
[
|
|
54
|
+
1,
|
|
55
|
+
"direction",
|
|
56
|
+
"<",
|
|
57
|
+
[5, "0"]
|
|
58
|
+
],
|
|
59
|
+
[10, [
|
|
60
|
+
1,
|
|
61
|
+
[
|
|
62
|
+
1,
|
|
63
|
+
"minimum",
|
|
64
|
+
"-",
|
|
65
|
+
"position"
|
|
66
|
+
],
|
|
67
|
+
"/",
|
|
68
|
+
"direction"
|
|
69
|
+
]]
|
|
70
|
+
],
|
|
71
|
+
[10, [
|
|
72
|
+
6,
|
|
73
|
+
"f32",
|
|
74
|
+
[[5, "1000000000"]]
|
|
75
|
+
]]
|
|
76
|
+
]]
|
|
77
|
+
},
|
|
78
|
+
externals: { f32: () => r }
|
|
79
|
+
}) && e.f)({}), y = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t, n) {
|
|
80
|
+
"use gpu";
|
|
81
|
+
return m(v(t.x, n.x, e.min.x, e.max.x), m(v(t.y, n.y, e.min.y, e.max.y), v(t.z, n.z, e.min.z, e.max.z)));
|
|
82
|
+
}), {
|
|
83
|
+
v: 2,
|
|
84
|
+
name: "aabbExitDistance",
|
|
85
|
+
ast: {
|
|
86
|
+
params: [
|
|
87
|
+
{
|
|
88
|
+
type: "i",
|
|
89
|
+
name: "aabb"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: "i",
|
|
93
|
+
name: "point"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: "i",
|
|
97
|
+
name: "direction"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
body: [0, [[10, [
|
|
101
|
+
6,
|
|
102
|
+
"min",
|
|
103
|
+
[[
|
|
104
|
+
6,
|
|
105
|
+
"axisExitDistance",
|
|
106
|
+
[
|
|
107
|
+
[
|
|
108
|
+
7,
|
|
109
|
+
"point",
|
|
110
|
+
"x"
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
7,
|
|
114
|
+
"direction",
|
|
115
|
+
"x"
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
7,
|
|
119
|
+
[
|
|
120
|
+
7,
|
|
121
|
+
"aabb",
|
|
122
|
+
"min"
|
|
123
|
+
],
|
|
124
|
+
"x"
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
7,
|
|
128
|
+
[
|
|
129
|
+
7,
|
|
130
|
+
"aabb",
|
|
131
|
+
"max"
|
|
132
|
+
],
|
|
133
|
+
"x"
|
|
134
|
+
]
|
|
135
|
+
]
|
|
136
|
+
], [
|
|
137
|
+
6,
|
|
138
|
+
"min",
|
|
139
|
+
[[
|
|
140
|
+
6,
|
|
141
|
+
"axisExitDistance",
|
|
142
|
+
[
|
|
143
|
+
[
|
|
144
|
+
7,
|
|
145
|
+
"point",
|
|
146
|
+
"y"
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
7,
|
|
150
|
+
"direction",
|
|
151
|
+
"y"
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
7,
|
|
155
|
+
[
|
|
156
|
+
7,
|
|
157
|
+
"aabb",
|
|
158
|
+
"min"
|
|
159
|
+
],
|
|
160
|
+
"y"
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
7,
|
|
164
|
+
[
|
|
165
|
+
7,
|
|
166
|
+
"aabb",
|
|
167
|
+
"max"
|
|
168
|
+
],
|
|
169
|
+
"y"
|
|
170
|
+
]
|
|
171
|
+
]
|
|
172
|
+
], [
|
|
173
|
+
6,
|
|
174
|
+
"axisExitDistance",
|
|
175
|
+
[
|
|
176
|
+
[
|
|
177
|
+
7,
|
|
178
|
+
"point",
|
|
179
|
+
"z"
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
7,
|
|
183
|
+
"direction",
|
|
184
|
+
"z"
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
7,
|
|
188
|
+
[
|
|
189
|
+
7,
|
|
190
|
+
"aabb",
|
|
191
|
+
"min"
|
|
192
|
+
],
|
|
193
|
+
"z"
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
7,
|
|
197
|
+
[
|
|
198
|
+
7,
|
|
199
|
+
"aabb",
|
|
200
|
+
"max"
|
|
201
|
+
],
|
|
202
|
+
"z"
|
|
203
|
+
]
|
|
204
|
+
]
|
|
205
|
+
]]
|
|
206
|
+
]]
|
|
207
|
+
]]]]
|
|
208
|
+
},
|
|
209
|
+
externals: {
|
|
210
|
+
min: () => m,
|
|
211
|
+
axisExitDistance: () => v
|
|
212
|
+
}
|
|
213
|
+
}) && e.f)({}), b = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t) {
|
|
214
|
+
"use gpu";
|
|
215
|
+
return g(e.min, e.max, l(t.x > 0, t.y > 0, t.z > 0));
|
|
216
|
+
}), {
|
|
217
|
+
v: 2,
|
|
218
|
+
name: "aabbPoint",
|
|
219
|
+
ast: {
|
|
220
|
+
params: [{
|
|
221
|
+
type: "i",
|
|
222
|
+
name: "aabb"
|
|
223
|
+
}, {
|
|
224
|
+
type: "i",
|
|
225
|
+
name: "corner"
|
|
226
|
+
}],
|
|
227
|
+
body: [0, [[10, [
|
|
228
|
+
6,
|
|
229
|
+
"select",
|
|
230
|
+
[
|
|
231
|
+
[
|
|
232
|
+
7,
|
|
233
|
+
"aabb",
|
|
234
|
+
"min"
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
7,
|
|
238
|
+
"aabb",
|
|
239
|
+
"max"
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
6,
|
|
243
|
+
"vec3b",
|
|
244
|
+
[
|
|
245
|
+
[
|
|
246
|
+
1,
|
|
247
|
+
[
|
|
248
|
+
7,
|
|
249
|
+
"corner",
|
|
250
|
+
"x"
|
|
251
|
+
],
|
|
252
|
+
">",
|
|
253
|
+
[5, "0"]
|
|
254
|
+
],
|
|
255
|
+
[
|
|
256
|
+
1,
|
|
257
|
+
[
|
|
258
|
+
7,
|
|
259
|
+
"corner",
|
|
260
|
+
"y"
|
|
261
|
+
],
|
|
262
|
+
">",
|
|
263
|
+
[5, "0"]
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
1,
|
|
267
|
+
[
|
|
268
|
+
7,
|
|
269
|
+
"corner",
|
|
270
|
+
"z"
|
|
271
|
+
],
|
|
272
|
+
">",
|
|
273
|
+
[5, "0"]
|
|
274
|
+
]
|
|
275
|
+
]
|
|
276
|
+
]
|
|
277
|
+
]
|
|
278
|
+
]]]]
|
|
279
|
+
},
|
|
280
|
+
externals: {
|
|
281
|
+
select: () => g,
|
|
282
|
+
vec3b: () => l
|
|
283
|
+
}
|
|
284
|
+
}) && e.f)({}), x = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(o({
|
|
285
|
+
min: u,
|
|
286
|
+
max: u
|
|
287
|
+
}), "AABB"), S = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(o({
|
|
288
|
+
direction: u,
|
|
289
|
+
color: u,
|
|
290
|
+
intensity: r
|
|
291
|
+
}), "RaymarchDirectionalLight"), C = [S({
|
|
292
|
+
direction: u(0, -1, 0),
|
|
293
|
+
color: u(0),
|
|
294
|
+
intensity: 0
|
|
295
|
+
})];
|
|
296
|
+
function w(t) {
|
|
297
|
+
if (!Number.isInteger(t) || t < 1) throw RangeError("Lighting capacity must be a positive integer.");
|
|
298
|
+
return o({
|
|
299
|
+
ambient: u,
|
|
300
|
+
directionalLights: e(S, t)
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function T(e) {
|
|
304
|
+
let t = e.directionalLights.length > 0 ? e.directionalLights : C, n = w(t.length);
|
|
305
|
+
return /*#__PURE__*/ ((r) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(r.f = (function() {
|
|
306
|
+
"use gpu";
|
|
307
|
+
return n({
|
|
308
|
+
ambient: e.ambient,
|
|
309
|
+
directionalLights: t
|
|
310
|
+
});
|
|
311
|
+
}), {
|
|
312
|
+
v: 2,
|
|
313
|
+
name: "raymarchLighting",
|
|
314
|
+
ast: {
|
|
315
|
+
params: [],
|
|
316
|
+
body: [0, [[10, [
|
|
317
|
+
6,
|
|
318
|
+
"RaymarchConstantLighting",
|
|
319
|
+
[[104, {
|
|
320
|
+
ambient: "lighting.ambient",
|
|
321
|
+
directionalLights: "directionalLights"
|
|
322
|
+
}]]
|
|
323
|
+
]]]]
|
|
324
|
+
},
|
|
325
|
+
externals: {
|
|
326
|
+
RaymarchConstantLighting: () => n,
|
|
327
|
+
"lighting.ambient": () => e.ambient,
|
|
328
|
+
directionalLights: () => t
|
|
329
|
+
}
|
|
330
|
+
}) && r.f)({});
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/program.ts
|
|
334
|
+
var E = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(o({
|
|
335
|
+
viewProjectionMatrix: a,
|
|
336
|
+
position: u
|
|
337
|
+
}), "RaymarchCamera"), D = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(o({
|
|
338
|
+
isHit: t,
|
|
339
|
+
position: u,
|
|
340
|
+
normal: u,
|
|
341
|
+
rayOrigin: u,
|
|
342
|
+
rayDirection: u,
|
|
343
|
+
rayDistance: r,
|
|
344
|
+
stepCount: s,
|
|
345
|
+
projectedDepth: r,
|
|
346
|
+
fragmentCoord: c,
|
|
347
|
+
instanceIndex: s,
|
|
348
|
+
bounds: x
|
|
349
|
+
}), "RaymarchResult"), O = "raymarchProgramDefinition";
|
|
350
|
+
function k(e, t, n) {
|
|
351
|
+
let r = n?.data[O] ?? {
|
|
352
|
+
version: 0,
|
|
353
|
+
options: e,
|
|
354
|
+
create: t
|
|
355
|
+
};
|
|
356
|
+
return r.version += 1, r.options = e, r.create = t, n && (n.data[O] = r), r;
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/cube-vertices.ts
|
|
360
|
+
var A = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(_.const(e(u, 36), [
|
|
361
|
+
u(0, 0, 1),
|
|
362
|
+
u(1, 0, 1),
|
|
363
|
+
u(1, 1, 1),
|
|
364
|
+
u(1, 1, 1),
|
|
365
|
+
u(0, 1, 1),
|
|
366
|
+
u(0, 0, 1),
|
|
367
|
+
u(1, 0, 0),
|
|
368
|
+
u(0, 0, 0),
|
|
369
|
+
u(0, 1, 0),
|
|
370
|
+
u(0, 1, 0),
|
|
371
|
+
u(1, 1, 0),
|
|
372
|
+
u(1, 0, 0),
|
|
373
|
+
u(0, 1, 1),
|
|
374
|
+
u(1, 1, 1),
|
|
375
|
+
u(1, 1, 0),
|
|
376
|
+
u(1, 1, 0),
|
|
377
|
+
u(0, 1, 0),
|
|
378
|
+
u(0, 1, 1),
|
|
379
|
+
u(0, 0, 0),
|
|
380
|
+
u(1, 0, 0),
|
|
381
|
+
u(1, 0, 1),
|
|
382
|
+
u(1, 0, 1),
|
|
383
|
+
u(0, 0, 1),
|
|
384
|
+
u(0, 0, 0),
|
|
385
|
+
u(1, 0, 1),
|
|
386
|
+
u(1, 0, 0),
|
|
387
|
+
u(1, 1, 0),
|
|
388
|
+
u(1, 1, 0),
|
|
389
|
+
u(1, 1, 1),
|
|
390
|
+
u(1, 0, 1),
|
|
391
|
+
u(0, 0, 0),
|
|
392
|
+
u(0, 0, 1),
|
|
393
|
+
u(0, 1, 1),
|
|
394
|
+
u(0, 1, 1),
|
|
395
|
+
u(0, 1, 0),
|
|
396
|
+
u(0, 0, 0)
|
|
397
|
+
]), "cubeVertices"), j = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(o({
|
|
398
|
+
isHit: t,
|
|
399
|
+
pos: u,
|
|
400
|
+
depth: r,
|
|
401
|
+
rayDirection: u,
|
|
402
|
+
rayDistance: r,
|
|
403
|
+
stepCount: s
|
|
404
|
+
}), "RayHit");
|
|
405
|
+
function M({ sdSurface: e, maxSteps: t, maxDistance: n, epsilon: i, marchBeyondBounds: a }) {
|
|
406
|
+
return /*#__PURE__*/ ((o) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(o.f = (function(o, c, l, u) {
|
|
407
|
+
"use gpu";
|
|
408
|
+
let f = __tsover_sub(c.xyz, o.position), g = p(f), _ = h(f), v = r(0), b = __tsover_add(o.position, __tsover_mul(_, g)), x = s(0), S = y(l, b, _);
|
|
409
|
+
a ? S = r(n ?? 0) : n !== void 0 && (S = m(S, n));
|
|
410
|
+
for (let n = 0; n < t && !(v > S); n++) {
|
|
411
|
+
x = __tsover_add(x, 1), b = __tsover_add(o.position, __tsover_mul(_, __tsover_add(g, v)));
|
|
412
|
+
let t = e(b, u, l);
|
|
413
|
+
if (t < i) {
|
|
414
|
+
let e = __tsover_mul(o.viewProjectionMatrix, d(b, 1));
|
|
415
|
+
return j({
|
|
416
|
+
isHit: !0,
|
|
417
|
+
pos: b,
|
|
418
|
+
depth: __tsover_div(e.z, e.w),
|
|
419
|
+
rayDirection: _,
|
|
420
|
+
rayDistance: __tsover_add(g, v),
|
|
421
|
+
stepCount: x
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
v = __tsover_add(v, t);
|
|
425
|
+
}
|
|
426
|
+
return j({
|
|
427
|
+
isHit: !1,
|
|
428
|
+
pos: b,
|
|
429
|
+
depth: 1,
|
|
430
|
+
rayDirection: _,
|
|
431
|
+
rayDistance: p(__tsover_sub(b, o.position)),
|
|
432
|
+
stepCount: x
|
|
433
|
+
});
|
|
434
|
+
}), {
|
|
435
|
+
v: 2,
|
|
436
|
+
name: "raymarch",
|
|
437
|
+
ast: {
|
|
438
|
+
params: [
|
|
439
|
+
{
|
|
440
|
+
type: "i",
|
|
441
|
+
name: "camera"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
type: "i",
|
|
445
|
+
name: "worldPosition"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
type: "i",
|
|
449
|
+
name: "aabb"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
type: "i",
|
|
453
|
+
name: "instanceIndex"
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
body: [0, [
|
|
457
|
+
[
|
|
458
|
+
13,
|
|
459
|
+
"triangleDifference",
|
|
460
|
+
[
|
|
461
|
+
1,
|
|
462
|
+
[
|
|
463
|
+
7,
|
|
464
|
+
"worldPosition",
|
|
465
|
+
"xyz"
|
|
466
|
+
],
|
|
467
|
+
"-",
|
|
468
|
+
[
|
|
469
|
+
7,
|
|
470
|
+
"camera",
|
|
471
|
+
"position"
|
|
472
|
+
]
|
|
473
|
+
]
|
|
474
|
+
],
|
|
475
|
+
[
|
|
476
|
+
13,
|
|
477
|
+
"triangleDistance",
|
|
478
|
+
[
|
|
479
|
+
6,
|
|
480
|
+
"length",
|
|
481
|
+
["triangleDifference"]
|
|
482
|
+
]
|
|
483
|
+
],
|
|
484
|
+
[
|
|
485
|
+
13,
|
|
486
|
+
"rayDirection",
|
|
487
|
+
[
|
|
488
|
+
6,
|
|
489
|
+
"normalize",
|
|
490
|
+
["triangleDifference"]
|
|
491
|
+
]
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
12,
|
|
495
|
+
"marchedDistance",
|
|
496
|
+
[
|
|
497
|
+
6,
|
|
498
|
+
"f32",
|
|
499
|
+
[[5, "0"]]
|
|
500
|
+
]
|
|
501
|
+
],
|
|
502
|
+
[
|
|
503
|
+
12,
|
|
504
|
+
"point",
|
|
505
|
+
[
|
|
506
|
+
1,
|
|
507
|
+
[
|
|
508
|
+
7,
|
|
509
|
+
"camera",
|
|
510
|
+
"position"
|
|
511
|
+
],
|
|
512
|
+
"+",
|
|
513
|
+
[
|
|
514
|
+
1,
|
|
515
|
+
"rayDirection",
|
|
516
|
+
"*",
|
|
517
|
+
"triangleDistance"
|
|
518
|
+
]
|
|
519
|
+
]
|
|
520
|
+
],
|
|
521
|
+
[
|
|
522
|
+
12,
|
|
523
|
+
"stepCount",
|
|
524
|
+
[
|
|
525
|
+
6,
|
|
526
|
+
"u32",
|
|
527
|
+
[[5, "0"]]
|
|
528
|
+
]
|
|
529
|
+
],
|
|
530
|
+
[
|
|
531
|
+
12,
|
|
532
|
+
"marchLimit",
|
|
533
|
+
[
|
|
534
|
+
6,
|
|
535
|
+
"aabbExitDistance",
|
|
536
|
+
[
|
|
537
|
+
"aabb",
|
|
538
|
+
"point",
|
|
539
|
+
"rayDirection"
|
|
540
|
+
]
|
|
541
|
+
]
|
|
542
|
+
],
|
|
543
|
+
[
|
|
544
|
+
11,
|
|
545
|
+
"marchBeyondBounds",
|
|
546
|
+
[0, [[
|
|
547
|
+
2,
|
|
548
|
+
"marchLimit",
|
|
549
|
+
"=",
|
|
550
|
+
[
|
|
551
|
+
6,
|
|
552
|
+
"f32",
|
|
553
|
+
[[
|
|
554
|
+
3,
|
|
555
|
+
"maxDistance",
|
|
556
|
+
"??",
|
|
557
|
+
[5, "0"]
|
|
558
|
+
]]
|
|
559
|
+
]
|
|
560
|
+
]]],
|
|
561
|
+
[
|
|
562
|
+
11,
|
|
563
|
+
[
|
|
564
|
+
1,
|
|
565
|
+
"maxDistance",
|
|
566
|
+
"!==",
|
|
567
|
+
"undefined"
|
|
568
|
+
],
|
|
569
|
+
[0, [[
|
|
570
|
+
2,
|
|
571
|
+
"marchLimit",
|
|
572
|
+
"=",
|
|
573
|
+
[
|
|
574
|
+
6,
|
|
575
|
+
"min",
|
|
576
|
+
["marchLimit", "maxDistance"]
|
|
577
|
+
]
|
|
578
|
+
]]]
|
|
579
|
+
]
|
|
580
|
+
],
|
|
581
|
+
[
|
|
582
|
+
14,
|
|
583
|
+
[
|
|
584
|
+
12,
|
|
585
|
+
"stepIndex",
|
|
586
|
+
[5, "0"]
|
|
587
|
+
],
|
|
588
|
+
[
|
|
589
|
+
1,
|
|
590
|
+
"stepIndex",
|
|
591
|
+
"<",
|
|
592
|
+
"maxSteps"
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
102,
|
|
596
|
+
"++",
|
|
597
|
+
"stepIndex"
|
|
598
|
+
],
|
|
599
|
+
[0, [
|
|
600
|
+
[
|
|
601
|
+
11,
|
|
602
|
+
[
|
|
603
|
+
1,
|
|
604
|
+
"marchedDistance",
|
|
605
|
+
">",
|
|
606
|
+
"marchLimit"
|
|
607
|
+
],
|
|
608
|
+
[17]
|
|
609
|
+
],
|
|
610
|
+
[
|
|
611
|
+
2,
|
|
612
|
+
"stepCount",
|
|
613
|
+
"+=",
|
|
614
|
+
[5, "1"]
|
|
615
|
+
],
|
|
616
|
+
[
|
|
617
|
+
2,
|
|
618
|
+
"point",
|
|
619
|
+
"=",
|
|
620
|
+
[
|
|
621
|
+
1,
|
|
622
|
+
[
|
|
623
|
+
7,
|
|
624
|
+
"camera",
|
|
625
|
+
"position"
|
|
626
|
+
],
|
|
627
|
+
"+",
|
|
628
|
+
[
|
|
629
|
+
1,
|
|
630
|
+
"rayDirection",
|
|
631
|
+
"*",
|
|
632
|
+
[
|
|
633
|
+
1,
|
|
634
|
+
"triangleDistance",
|
|
635
|
+
"+",
|
|
636
|
+
"marchedDistance"
|
|
637
|
+
]
|
|
638
|
+
]
|
|
639
|
+
]
|
|
640
|
+
],
|
|
641
|
+
[
|
|
642
|
+
13,
|
|
643
|
+
"distance",
|
|
644
|
+
[
|
|
645
|
+
6,
|
|
646
|
+
"sdSurface",
|
|
647
|
+
[
|
|
648
|
+
"point",
|
|
649
|
+
"instanceIndex",
|
|
650
|
+
"aabb"
|
|
651
|
+
]
|
|
652
|
+
]
|
|
653
|
+
],
|
|
654
|
+
[
|
|
655
|
+
11,
|
|
656
|
+
[
|
|
657
|
+
1,
|
|
658
|
+
"distance",
|
|
659
|
+
"<",
|
|
660
|
+
"epsilon"
|
|
661
|
+
],
|
|
662
|
+
[0, [[
|
|
663
|
+
13,
|
|
664
|
+
"hitClipPosition",
|
|
665
|
+
[
|
|
666
|
+
1,
|
|
667
|
+
[
|
|
668
|
+
7,
|
|
669
|
+
"camera",
|
|
670
|
+
"viewProjectionMatrix"
|
|
671
|
+
],
|
|
672
|
+
"*",
|
|
673
|
+
[
|
|
674
|
+
6,
|
|
675
|
+
"vec4f",
|
|
676
|
+
["point", [5, "1"]]
|
|
677
|
+
]
|
|
678
|
+
]
|
|
679
|
+
], [10, [
|
|
680
|
+
6,
|
|
681
|
+
"RayHit",
|
|
682
|
+
[[104, {
|
|
683
|
+
isHit: !0,
|
|
684
|
+
pos: "point",
|
|
685
|
+
depth: [
|
|
686
|
+
1,
|
|
687
|
+
[
|
|
688
|
+
7,
|
|
689
|
+
"hitClipPosition",
|
|
690
|
+
"z"
|
|
691
|
+
],
|
|
692
|
+
"/",
|
|
693
|
+
[
|
|
694
|
+
7,
|
|
695
|
+
"hitClipPosition",
|
|
696
|
+
"w"
|
|
697
|
+
]
|
|
698
|
+
],
|
|
699
|
+
rayDirection: "rayDirection",
|
|
700
|
+
rayDistance: [
|
|
701
|
+
1,
|
|
702
|
+
"triangleDistance",
|
|
703
|
+
"+",
|
|
704
|
+
"marchedDistance"
|
|
705
|
+
],
|
|
706
|
+
stepCount: "stepCount"
|
|
707
|
+
}]]
|
|
708
|
+
]]]]
|
|
709
|
+
],
|
|
710
|
+
[
|
|
711
|
+
2,
|
|
712
|
+
"marchedDistance",
|
|
713
|
+
"+=",
|
|
714
|
+
"distance"
|
|
715
|
+
]
|
|
716
|
+
]]
|
|
717
|
+
],
|
|
718
|
+
[10, [
|
|
719
|
+
6,
|
|
720
|
+
"RayHit",
|
|
721
|
+
[[104, {
|
|
722
|
+
isHit: !1,
|
|
723
|
+
pos: "point",
|
|
724
|
+
depth: [5, "1"],
|
|
725
|
+
rayDirection: "rayDirection",
|
|
726
|
+
rayDistance: [
|
|
727
|
+
6,
|
|
728
|
+
"length",
|
|
729
|
+
[[
|
|
730
|
+
1,
|
|
731
|
+
"point",
|
|
732
|
+
"-",
|
|
733
|
+
[
|
|
734
|
+
7,
|
|
735
|
+
"camera",
|
|
736
|
+
"position"
|
|
737
|
+
]
|
|
738
|
+
]]
|
|
739
|
+
],
|
|
740
|
+
stepCount: "stepCount"
|
|
741
|
+
}]]
|
|
742
|
+
]]
|
|
743
|
+
]]
|
|
744
|
+
},
|
|
745
|
+
externals: {
|
|
746
|
+
length: () => p,
|
|
747
|
+
normalize: () => h,
|
|
748
|
+
f32: () => r,
|
|
749
|
+
u32: () => s,
|
|
750
|
+
aabbExitDistance: () => y,
|
|
751
|
+
marchBeyondBounds: () => a,
|
|
752
|
+
maxDistance: () => n,
|
|
753
|
+
undefined: () => void 0,
|
|
754
|
+
min: () => m,
|
|
755
|
+
maxSteps: () => t,
|
|
756
|
+
sdSurface: () => e,
|
|
757
|
+
epsilon: () => i,
|
|
758
|
+
vec4f: () => d,
|
|
759
|
+
RayHit: () => j
|
|
760
|
+
}
|
|
761
|
+
}) && o.f)({});
|
|
762
|
+
}
|
|
763
|
+
function N({ sdSurface: e, epsilonNormal: t }) {
|
|
764
|
+
return /*#__PURE__*/ ((n) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(n.f = (function(n, r, i) {
|
|
765
|
+
"use gpu";
|
|
766
|
+
let a = c(1, -1);
|
|
767
|
+
return h(__tsover_add(__tsover_mul(a.xyy, e(__tsover_add(n, __tsover_mul(a.xyy, t)), i, r)), __tsover_add(__tsover_mul(a.yyx, e(__tsover_add(n, __tsover_mul(a.yyx, t)), i, r)), __tsover_add(__tsover_mul(a.yxy, e(__tsover_add(n, __tsover_mul(a.yxy, t)), i, r)), __tsover_mul(a.xxx, e(__tsover_add(n, __tsover_mul(a.xxx, t)), i, r))))));
|
|
768
|
+
}), {
|
|
769
|
+
v: 2,
|
|
770
|
+
name: "calculateNormal",
|
|
771
|
+
ast: {
|
|
772
|
+
params: [
|
|
773
|
+
{
|
|
774
|
+
type: "i",
|
|
775
|
+
name: "point"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
type: "i",
|
|
779
|
+
name: "aabb"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
type: "i",
|
|
783
|
+
name: "instanceIndex"
|
|
784
|
+
}
|
|
785
|
+
],
|
|
786
|
+
body: [0, [[
|
|
787
|
+
13,
|
|
788
|
+
"k",
|
|
789
|
+
[
|
|
790
|
+
6,
|
|
791
|
+
"vec2f",
|
|
792
|
+
[[5, "1"], [
|
|
793
|
+
4,
|
|
794
|
+
"-",
|
|
795
|
+
[5, "1"]
|
|
796
|
+
]]
|
|
797
|
+
]
|
|
798
|
+
], [10, [
|
|
799
|
+
6,
|
|
800
|
+
"normalize",
|
|
801
|
+
[[
|
|
802
|
+
1,
|
|
803
|
+
[
|
|
804
|
+
1,
|
|
805
|
+
[
|
|
806
|
+
7,
|
|
807
|
+
"k",
|
|
808
|
+
"xyy"
|
|
809
|
+
],
|
|
810
|
+
"*",
|
|
811
|
+
[
|
|
812
|
+
6,
|
|
813
|
+
"sdSurface",
|
|
814
|
+
[
|
|
815
|
+
[
|
|
816
|
+
1,
|
|
817
|
+
"point",
|
|
818
|
+
"+",
|
|
819
|
+
[
|
|
820
|
+
1,
|
|
821
|
+
[
|
|
822
|
+
7,
|
|
823
|
+
"k",
|
|
824
|
+
"xyy"
|
|
825
|
+
],
|
|
826
|
+
"*",
|
|
827
|
+
"epsilonNormal"
|
|
828
|
+
]
|
|
829
|
+
],
|
|
830
|
+
"instanceIndex",
|
|
831
|
+
"aabb"
|
|
832
|
+
]
|
|
833
|
+
]
|
|
834
|
+
],
|
|
835
|
+
"+",
|
|
836
|
+
[
|
|
837
|
+
1,
|
|
838
|
+
[
|
|
839
|
+
1,
|
|
840
|
+
[
|
|
841
|
+
7,
|
|
842
|
+
"k",
|
|
843
|
+
"yyx"
|
|
844
|
+
],
|
|
845
|
+
"*",
|
|
846
|
+
[
|
|
847
|
+
6,
|
|
848
|
+
"sdSurface",
|
|
849
|
+
[
|
|
850
|
+
[
|
|
851
|
+
1,
|
|
852
|
+
"point",
|
|
853
|
+
"+",
|
|
854
|
+
[
|
|
855
|
+
1,
|
|
856
|
+
[
|
|
857
|
+
7,
|
|
858
|
+
"k",
|
|
859
|
+
"yyx"
|
|
860
|
+
],
|
|
861
|
+
"*",
|
|
862
|
+
"epsilonNormal"
|
|
863
|
+
]
|
|
864
|
+
],
|
|
865
|
+
"instanceIndex",
|
|
866
|
+
"aabb"
|
|
867
|
+
]
|
|
868
|
+
]
|
|
869
|
+
],
|
|
870
|
+
"+",
|
|
871
|
+
[
|
|
872
|
+
1,
|
|
873
|
+
[
|
|
874
|
+
1,
|
|
875
|
+
[
|
|
876
|
+
7,
|
|
877
|
+
"k",
|
|
878
|
+
"yxy"
|
|
879
|
+
],
|
|
880
|
+
"*",
|
|
881
|
+
[
|
|
882
|
+
6,
|
|
883
|
+
"sdSurface",
|
|
884
|
+
[
|
|
885
|
+
[
|
|
886
|
+
1,
|
|
887
|
+
"point",
|
|
888
|
+
"+",
|
|
889
|
+
[
|
|
890
|
+
1,
|
|
891
|
+
[
|
|
892
|
+
7,
|
|
893
|
+
"k",
|
|
894
|
+
"yxy"
|
|
895
|
+
],
|
|
896
|
+
"*",
|
|
897
|
+
"epsilonNormal"
|
|
898
|
+
]
|
|
899
|
+
],
|
|
900
|
+
"instanceIndex",
|
|
901
|
+
"aabb"
|
|
902
|
+
]
|
|
903
|
+
]
|
|
904
|
+
],
|
|
905
|
+
"+",
|
|
906
|
+
[
|
|
907
|
+
1,
|
|
908
|
+
[
|
|
909
|
+
7,
|
|
910
|
+
"k",
|
|
911
|
+
"xxx"
|
|
912
|
+
],
|
|
913
|
+
"*",
|
|
914
|
+
[
|
|
915
|
+
6,
|
|
916
|
+
"sdSurface",
|
|
917
|
+
[
|
|
918
|
+
[
|
|
919
|
+
1,
|
|
920
|
+
"point",
|
|
921
|
+
"+",
|
|
922
|
+
[
|
|
923
|
+
1,
|
|
924
|
+
[
|
|
925
|
+
7,
|
|
926
|
+
"k",
|
|
927
|
+
"xxx"
|
|
928
|
+
],
|
|
929
|
+
"*",
|
|
930
|
+
"epsilonNormal"
|
|
931
|
+
]
|
|
932
|
+
],
|
|
933
|
+
"instanceIndex",
|
|
934
|
+
"aabb"
|
|
935
|
+
]
|
|
936
|
+
]
|
|
937
|
+
]
|
|
938
|
+
]
|
|
939
|
+
]
|
|
940
|
+
]]
|
|
941
|
+
]]]]
|
|
942
|
+
},
|
|
943
|
+
externals: {
|
|
944
|
+
vec2f: () => c,
|
|
945
|
+
normalize: () => h,
|
|
946
|
+
sdSurface: () => e,
|
|
947
|
+
epsilonNormal: () => t
|
|
948
|
+
}
|
|
949
|
+
}) && n.f)({});
|
|
950
|
+
}
|
|
951
|
+
function P({ root: e, options: t, camera: r, appearance: a, surface: o, preparePipeline: c = (e) => e, renderTarget: l }) {
|
|
952
|
+
let p = o.isRayVisible ?? /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
|
|
953
|
+
"use gpu";
|
|
954
|
+
return !0;
|
|
955
|
+
}), {
|
|
956
|
+
v: 2,
|
|
957
|
+
name: void 0,
|
|
958
|
+
ast: {
|
|
959
|
+
params: [],
|
|
960
|
+
body: [0, [[10, !0]]]
|
|
961
|
+
},
|
|
962
|
+
externals: {}
|
|
963
|
+
}) && e.f)({}), m = N({
|
|
964
|
+
sdSurface: o.sd,
|
|
965
|
+
epsilonNormal: t.epsilonNormal ?? t.epsilon
|
|
966
|
+
}), h = M({
|
|
967
|
+
sdSurface: o.sd,
|
|
968
|
+
epsilon: t.epsilon,
|
|
969
|
+
maxSteps: t.maxSteps ?? 100,
|
|
970
|
+
maxDistance: t.maxDistance,
|
|
971
|
+
marchBeyondBounds: t.marchBeyondBounds ?? !1
|
|
972
|
+
}), g = c(e.createRenderPipeline({
|
|
973
|
+
multisample: { count: l?.sampleCount },
|
|
974
|
+
depthStencil: {
|
|
975
|
+
format: l?.depthStencilFormat ?? "depth24plus",
|
|
976
|
+
depthWriteEnabled: t.depthWriteEnabled ?? !0,
|
|
977
|
+
depthCompare: t.depthCompare ?? "less"
|
|
978
|
+
},
|
|
979
|
+
primitive: {
|
|
980
|
+
topology: "triangle-list",
|
|
981
|
+
cullMode: "back"
|
|
982
|
+
},
|
|
983
|
+
targets: { color: {
|
|
984
|
+
format: l?.colorFormat,
|
|
985
|
+
blend: {
|
|
986
|
+
color: {
|
|
987
|
+
srcFactor: "src-alpha",
|
|
988
|
+
dstFactor: "one-minus-src-alpha",
|
|
989
|
+
operation: "add"
|
|
990
|
+
},
|
|
991
|
+
alpha: {
|
|
992
|
+
srcFactor: "one",
|
|
993
|
+
dstFactor: "one-minus-src-alpha",
|
|
994
|
+
operation: "add"
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
} },
|
|
998
|
+
vertex: /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(_.vertexFn({
|
|
999
|
+
in: {
|
|
1000
|
+
vertexIdx: n.vertexIndex,
|
|
1001
|
+
instanceIdx: n.instanceIndex
|
|
1002
|
+
},
|
|
1003
|
+
out: {
|
|
1004
|
+
position: n.position,
|
|
1005
|
+
worldPos: u,
|
|
1006
|
+
instanceIdx: i("flat, either", s)
|
|
1007
|
+
}
|
|
1008
|
+
})(/*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (({ vertexIdx: e, instanceIdx: t }) => {
|
|
1009
|
+
"use gpu";
|
|
1010
|
+
let n = o.bounds(t), i = A.$[e], a = b(n, i);
|
|
1011
|
+
return {
|
|
1012
|
+
position: __tsover_mul(r().viewProjectionMatrix, d(a, 1)),
|
|
1013
|
+
worldPos: a,
|
|
1014
|
+
instanceIdx: t
|
|
1015
|
+
};
|
|
1016
|
+
}), {
|
|
1017
|
+
v: 2,
|
|
1018
|
+
name: void 0,
|
|
1019
|
+
ast: {
|
|
1020
|
+
params: [{
|
|
1021
|
+
type: "d",
|
|
1022
|
+
props: [{
|
|
1023
|
+
name: "vertexIdx",
|
|
1024
|
+
alias: "vertexIdx"
|
|
1025
|
+
}, {
|
|
1026
|
+
name: "instanceIdx",
|
|
1027
|
+
alias: "instanceIdx"
|
|
1028
|
+
}]
|
|
1029
|
+
}],
|
|
1030
|
+
body: [0, [
|
|
1031
|
+
[
|
|
1032
|
+
13,
|
|
1033
|
+
"aabb",
|
|
1034
|
+
[
|
|
1035
|
+
6,
|
|
1036
|
+
"surface.bounds",
|
|
1037
|
+
["instanceIdx"]
|
|
1038
|
+
]
|
|
1039
|
+
],
|
|
1040
|
+
[
|
|
1041
|
+
13,
|
|
1042
|
+
"localPos",
|
|
1043
|
+
[
|
|
1044
|
+
8,
|
|
1045
|
+
[
|
|
1046
|
+
7,
|
|
1047
|
+
"cubeVertices",
|
|
1048
|
+
"$"
|
|
1049
|
+
],
|
|
1050
|
+
"vertexIdx"
|
|
1051
|
+
]
|
|
1052
|
+
],
|
|
1053
|
+
[
|
|
1054
|
+
13,
|
|
1055
|
+
"worldPos",
|
|
1056
|
+
[
|
|
1057
|
+
6,
|
|
1058
|
+
"aabbPoint",
|
|
1059
|
+
["aabb", "localPos"]
|
|
1060
|
+
]
|
|
1061
|
+
],
|
|
1062
|
+
[
|
|
1063
|
+
13,
|
|
1064
|
+
"position",
|
|
1065
|
+
[
|
|
1066
|
+
1,
|
|
1067
|
+
[
|
|
1068
|
+
7,
|
|
1069
|
+
[
|
|
1070
|
+
6,
|
|
1071
|
+
"camera",
|
|
1072
|
+
[]
|
|
1073
|
+
],
|
|
1074
|
+
"viewProjectionMatrix"
|
|
1075
|
+
],
|
|
1076
|
+
"*",
|
|
1077
|
+
[
|
|
1078
|
+
6,
|
|
1079
|
+
"vec4f",
|
|
1080
|
+
["worldPos", [5, "1"]]
|
|
1081
|
+
]
|
|
1082
|
+
]
|
|
1083
|
+
],
|
|
1084
|
+
[10, [104, {
|
|
1085
|
+
position: "position",
|
|
1086
|
+
worldPos: "worldPos",
|
|
1087
|
+
instanceIdx: "instanceIdx"
|
|
1088
|
+
}]]
|
|
1089
|
+
]]
|
|
1090
|
+
},
|
|
1091
|
+
externals: {
|
|
1092
|
+
"surface.bounds": () => o.bounds,
|
|
1093
|
+
cubeVertices: () => A,
|
|
1094
|
+
aabbPoint: () => b,
|
|
1095
|
+
camera: () => r,
|
|
1096
|
+
vec4f: () => d
|
|
1097
|
+
}
|
|
1098
|
+
}) && e.f)({})), "vertex"),
|
|
1099
|
+
fragment: /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (({ $position: e, worldPos: t, instanceIdx: n }) => {
|
|
1100
|
+
"use gpu";
|
|
1101
|
+
let i = o.bounds(n);
|
|
1102
|
+
o.init !== void 0 && o.init(n), p(t.xyz, n, i) || f();
|
|
1103
|
+
let s = r(), c = h(s, t.xyz, i, n), l = __tsover_mul(-1, c.rayDirection);
|
|
1104
|
+
c.isHit && (l = m(c.pos, i, n));
|
|
1105
|
+
let u = a(D({
|
|
1106
|
+
isHit: c.isHit,
|
|
1107
|
+
position: c.pos,
|
|
1108
|
+
normal: l,
|
|
1109
|
+
rayOrigin: s.position,
|
|
1110
|
+
rayDirection: c.rayDirection,
|
|
1111
|
+
rayDistance: c.rayDistance,
|
|
1112
|
+
stepCount: c.stepCount,
|
|
1113
|
+
projectedDepth: c.depth,
|
|
1114
|
+
fragmentCoord: e.xy,
|
|
1115
|
+
instanceIndex: n,
|
|
1116
|
+
bounds: i
|
|
1117
|
+
}));
|
|
1118
|
+
return c.isHit ? {
|
|
1119
|
+
color: d(u, 1),
|
|
1120
|
+
$fragDepth: c.depth
|
|
1121
|
+
} : {
|
|
1122
|
+
color: d(),
|
|
1123
|
+
$fragDepth: 1
|
|
1124
|
+
};
|
|
1125
|
+
}), {
|
|
1126
|
+
v: 2,
|
|
1127
|
+
name: "fragment",
|
|
1128
|
+
ast: {
|
|
1129
|
+
params: [{
|
|
1130
|
+
type: "d",
|
|
1131
|
+
props: [
|
|
1132
|
+
{
|
|
1133
|
+
name: "$position",
|
|
1134
|
+
alias: "$position"
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: "worldPos",
|
|
1138
|
+
alias: "worldPos"
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
name: "instanceIdx",
|
|
1142
|
+
alias: "instanceIdx"
|
|
1143
|
+
}
|
|
1144
|
+
]
|
|
1145
|
+
}],
|
|
1146
|
+
body: [0, [
|
|
1147
|
+
[
|
|
1148
|
+
13,
|
|
1149
|
+
"aabb",
|
|
1150
|
+
[
|
|
1151
|
+
6,
|
|
1152
|
+
"surface.bounds",
|
|
1153
|
+
["instanceIdx"]
|
|
1154
|
+
]
|
|
1155
|
+
],
|
|
1156
|
+
[
|
|
1157
|
+
11,
|
|
1158
|
+
[
|
|
1159
|
+
1,
|
|
1160
|
+
"surface.init",
|
|
1161
|
+
"!==",
|
|
1162
|
+
"undefined"
|
|
1163
|
+
],
|
|
1164
|
+
[
|
|
1165
|
+
6,
|
|
1166
|
+
"surface.init",
|
|
1167
|
+
["instanceIdx"]
|
|
1168
|
+
]
|
|
1169
|
+
],
|
|
1170
|
+
[
|
|
1171
|
+
11,
|
|
1172
|
+
[
|
|
1173
|
+
4,
|
|
1174
|
+
"!",
|
|
1175
|
+
[
|
|
1176
|
+
6,
|
|
1177
|
+
"isRayVisible",
|
|
1178
|
+
[
|
|
1179
|
+
[
|
|
1180
|
+
7,
|
|
1181
|
+
"worldPos",
|
|
1182
|
+
"xyz"
|
|
1183
|
+
],
|
|
1184
|
+
"instanceIdx",
|
|
1185
|
+
"aabb"
|
|
1186
|
+
]
|
|
1187
|
+
]
|
|
1188
|
+
],
|
|
1189
|
+
[
|
|
1190
|
+
6,
|
|
1191
|
+
"discard",
|
|
1192
|
+
[]
|
|
1193
|
+
]
|
|
1194
|
+
],
|
|
1195
|
+
[
|
|
1196
|
+
13,
|
|
1197
|
+
"activeCamera",
|
|
1198
|
+
[
|
|
1199
|
+
6,
|
|
1200
|
+
"camera",
|
|
1201
|
+
[]
|
|
1202
|
+
]
|
|
1203
|
+
],
|
|
1204
|
+
[
|
|
1205
|
+
13,
|
|
1206
|
+
"hit",
|
|
1207
|
+
[
|
|
1208
|
+
6,
|
|
1209
|
+
"raymarch",
|
|
1210
|
+
[
|
|
1211
|
+
"activeCamera",
|
|
1212
|
+
[
|
|
1213
|
+
7,
|
|
1214
|
+
"worldPos",
|
|
1215
|
+
"xyz"
|
|
1216
|
+
],
|
|
1217
|
+
"aabb",
|
|
1218
|
+
"instanceIdx"
|
|
1219
|
+
]
|
|
1220
|
+
]
|
|
1221
|
+
],
|
|
1222
|
+
[
|
|
1223
|
+
12,
|
|
1224
|
+
"normal",
|
|
1225
|
+
[
|
|
1226
|
+
1,
|
|
1227
|
+
[
|
|
1228
|
+
4,
|
|
1229
|
+
"-",
|
|
1230
|
+
[5, "1"]
|
|
1231
|
+
],
|
|
1232
|
+
"*",
|
|
1233
|
+
[
|
|
1234
|
+
7,
|
|
1235
|
+
"hit",
|
|
1236
|
+
"rayDirection"
|
|
1237
|
+
]
|
|
1238
|
+
]
|
|
1239
|
+
],
|
|
1240
|
+
[
|
|
1241
|
+
11,
|
|
1242
|
+
[
|
|
1243
|
+
7,
|
|
1244
|
+
"hit",
|
|
1245
|
+
"isHit"
|
|
1246
|
+
],
|
|
1247
|
+
[0, [[
|
|
1248
|
+
2,
|
|
1249
|
+
"normal",
|
|
1250
|
+
"=",
|
|
1251
|
+
[
|
|
1252
|
+
6,
|
|
1253
|
+
"calculateNormal",
|
|
1254
|
+
[
|
|
1255
|
+
[
|
|
1256
|
+
7,
|
|
1257
|
+
"hit",
|
|
1258
|
+
"pos"
|
|
1259
|
+
],
|
|
1260
|
+
"aabb",
|
|
1261
|
+
"instanceIdx"
|
|
1262
|
+
]
|
|
1263
|
+
]
|
|
1264
|
+
]]]
|
|
1265
|
+
],
|
|
1266
|
+
[
|
|
1267
|
+
13,
|
|
1268
|
+
"color",
|
|
1269
|
+
[
|
|
1270
|
+
6,
|
|
1271
|
+
"appearance",
|
|
1272
|
+
[[
|
|
1273
|
+
6,
|
|
1274
|
+
"RaymarchResult",
|
|
1275
|
+
[[104, {
|
|
1276
|
+
isHit: [
|
|
1277
|
+
7,
|
|
1278
|
+
"hit",
|
|
1279
|
+
"isHit"
|
|
1280
|
+
],
|
|
1281
|
+
position: [
|
|
1282
|
+
7,
|
|
1283
|
+
"hit",
|
|
1284
|
+
"pos"
|
|
1285
|
+
],
|
|
1286
|
+
normal: "normal",
|
|
1287
|
+
rayOrigin: [
|
|
1288
|
+
7,
|
|
1289
|
+
"activeCamera",
|
|
1290
|
+
"position"
|
|
1291
|
+
],
|
|
1292
|
+
rayDirection: [
|
|
1293
|
+
7,
|
|
1294
|
+
"hit",
|
|
1295
|
+
"rayDirection"
|
|
1296
|
+
],
|
|
1297
|
+
rayDistance: [
|
|
1298
|
+
7,
|
|
1299
|
+
"hit",
|
|
1300
|
+
"rayDistance"
|
|
1301
|
+
],
|
|
1302
|
+
stepCount: [
|
|
1303
|
+
7,
|
|
1304
|
+
"hit",
|
|
1305
|
+
"stepCount"
|
|
1306
|
+
],
|
|
1307
|
+
projectedDepth: [
|
|
1308
|
+
7,
|
|
1309
|
+
"hit",
|
|
1310
|
+
"depth"
|
|
1311
|
+
],
|
|
1312
|
+
fragmentCoord: [
|
|
1313
|
+
7,
|
|
1314
|
+
"$position",
|
|
1315
|
+
"xy"
|
|
1316
|
+
],
|
|
1317
|
+
instanceIndex: "instanceIdx",
|
|
1318
|
+
bounds: "aabb"
|
|
1319
|
+
}]]
|
|
1320
|
+
]]
|
|
1321
|
+
]
|
|
1322
|
+
],
|
|
1323
|
+
[
|
|
1324
|
+
11,
|
|
1325
|
+
[
|
|
1326
|
+
7,
|
|
1327
|
+
"hit",
|
|
1328
|
+
"isHit"
|
|
1329
|
+
],
|
|
1330
|
+
[0, [[10, [104, {
|
|
1331
|
+
color: [
|
|
1332
|
+
6,
|
|
1333
|
+
"vec4f",
|
|
1334
|
+
["color", [5, "1"]]
|
|
1335
|
+
],
|
|
1336
|
+
$fragDepth: [
|
|
1337
|
+
7,
|
|
1338
|
+
"hit",
|
|
1339
|
+
"depth"
|
|
1340
|
+
]
|
|
1341
|
+
}]]]]
|
|
1342
|
+
],
|
|
1343
|
+
[10, [104, {
|
|
1344
|
+
color: [
|
|
1345
|
+
6,
|
|
1346
|
+
"vec4f",
|
|
1347
|
+
[]
|
|
1348
|
+
],
|
|
1349
|
+
$fragDepth: [5, "1"]
|
|
1350
|
+
}]]
|
|
1351
|
+
]]
|
|
1352
|
+
},
|
|
1353
|
+
externals: {
|
|
1354
|
+
"surface.bounds": () => o.bounds,
|
|
1355
|
+
"surface.init": () => o.init,
|
|
1356
|
+
undefined: () => void 0,
|
|
1357
|
+
isRayVisible: () => p,
|
|
1358
|
+
discard: () => f,
|
|
1359
|
+
camera: () => r,
|
|
1360
|
+
raymarch: () => h,
|
|
1361
|
+
calculateNormal: () => m,
|
|
1362
|
+
appearance: () => a,
|
|
1363
|
+
RaymarchResult: () => D,
|
|
1364
|
+
vec4f: () => d
|
|
1365
|
+
}
|
|
1366
|
+
}) && e.f)({})
|
|
1367
|
+
}));
|
|
1368
|
+
return function({ colorAttachment: e, depthStencilAttachment: t, instances: n = 1 }) {
|
|
1369
|
+
g.withColorAttachment({ color: e }).withDepthStencilAttachment(t).draw(A.$.length, n);
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
function F({ root: e, program: t, context: n = void 0, renderTarget: r, prepare: i = (e) => e, preparePipeline: a }) {
|
|
1373
|
+
function o() {
|
|
1374
|
+
let { camera: o, surface: s, appearance: c } = i(t.create(n));
|
|
1375
|
+
return P({
|
|
1376
|
+
root: e,
|
|
1377
|
+
options: t.options,
|
|
1378
|
+
surface: s,
|
|
1379
|
+
camera: o,
|
|
1380
|
+
appearance: c,
|
|
1381
|
+
preparePipeline: a,
|
|
1382
|
+
renderTarget: r
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
let s = t.version, c = o();
|
|
1386
|
+
return function(e) {
|
|
1387
|
+
s !== t.version && (c = o(), s = t.version), c(e);
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
//#endregion
|
|
1391
|
+
export { x as AABB, E as RaymarchCamera, S as RaymarchDirectionalLight, D as RaymarchResult, T as createRaymarchConstantLighting, k as createRaymarchProgram, F as createRaymarchRenderer };
|
|
1392
|
+
|
|
1393
|
+
//# sourceMappingURL=index.js.map
|