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/dist/pbr.js ADDED
@@ -0,0 +1,1179 @@
1
+ import { f32 as e, struct as t, vec3f as n } from "typegpu/data";
2
+ import { clamp as r, dot as i, max as a, mix as o, normalize as s, pow as c, reflect as l, sqrt as u } from "typegpu/std";
3
+ //#region src/appearances/pbr/material.ts
4
+ var d = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t, n) {
5
+ "use gpu";
6
+ return f({
7
+ baseColor: o(e.baseColor, t.baseColor, n),
8
+ metallic: o(e.metallic, t.metallic, n),
9
+ roughness: o(e.roughness, t.roughness, n),
10
+ emission: o(e.emission, t.emission, n)
11
+ });
12
+ }), {
13
+ v: 2,
14
+ name: "mixPbrMaterials",
15
+ ast: {
16
+ params: [
17
+ {
18
+ type: "i",
19
+ name: "a"
20
+ },
21
+ {
22
+ type: "i",
23
+ name: "b"
24
+ },
25
+ {
26
+ type: "i",
27
+ name: "amount"
28
+ }
29
+ ],
30
+ body: [0, [[10, [
31
+ 6,
32
+ "PbrMaterial",
33
+ [[104, {
34
+ baseColor: [
35
+ 6,
36
+ "mix",
37
+ [
38
+ [
39
+ 7,
40
+ "a",
41
+ "baseColor"
42
+ ],
43
+ [
44
+ 7,
45
+ "b",
46
+ "baseColor"
47
+ ],
48
+ "amount"
49
+ ]
50
+ ],
51
+ metallic: [
52
+ 6,
53
+ "mix",
54
+ [
55
+ [
56
+ 7,
57
+ "a",
58
+ "metallic"
59
+ ],
60
+ [
61
+ 7,
62
+ "b",
63
+ "metallic"
64
+ ],
65
+ "amount"
66
+ ]
67
+ ],
68
+ roughness: [
69
+ 6,
70
+ "mix",
71
+ [
72
+ [
73
+ 7,
74
+ "a",
75
+ "roughness"
76
+ ],
77
+ [
78
+ 7,
79
+ "b",
80
+ "roughness"
81
+ ],
82
+ "amount"
83
+ ]
84
+ ],
85
+ emission: [
86
+ 6,
87
+ "mix",
88
+ [
89
+ [
90
+ 7,
91
+ "a",
92
+ "emission"
93
+ ],
94
+ [
95
+ 7,
96
+ "b",
97
+ "emission"
98
+ ],
99
+ "amount"
100
+ ]
101
+ ]
102
+ }]]
103
+ ]]]]
104
+ },
105
+ externals: {
106
+ PbrMaterial: () => f,
107
+ mix: () => o
108
+ }
109
+ }) && e.f)({}), f = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(t({
110
+ baseColor: n,
111
+ metallic: e,
112
+ roughness: e,
113
+ emission: n
114
+ }), "PbrMaterial"), p = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t, a, o, c, l, u) {
115
+ "use gpu";
116
+ let d = r(i(e, a), 0, 1);
117
+ if (o === 0 || d === 0) return n(0);
118
+ let f = s(__tsover_add(t, a)), p = r(i(e, f), 0, 1), h = r(i(t, f), 0, 1), g = m(o, d, p, u, _(h, l)), v = _(h, n(.04)), y = __tsover_div(__tsover_mul(__tsover_sub(1, v), c), Math.PI);
119
+ return __tsover_mul(d, __tsover_add(y, g));
120
+ }), {
121
+ v: 2,
122
+ name: "evaluateDirectLightResponse",
123
+ ast: {
124
+ params: [
125
+ {
126
+ type: "i",
127
+ name: "normal"
128
+ },
129
+ {
130
+ type: "i",
131
+ name: "viewDirection"
132
+ },
133
+ {
134
+ type: "i",
135
+ name: "lightDirection"
136
+ },
137
+ {
138
+ type: "i",
139
+ name: "normalDotView"
140
+ },
141
+ {
142
+ type: "i",
143
+ name: "diffuseColor"
144
+ },
145
+ {
146
+ type: "i",
147
+ name: "specularF0"
148
+ },
149
+ {
150
+ type: "i",
151
+ name: "alpha"
152
+ }
153
+ ],
154
+ body: [0, [
155
+ [
156
+ 13,
157
+ "normalDotLight",
158
+ [
159
+ 6,
160
+ "clamp",
161
+ [
162
+ [
163
+ 6,
164
+ "dot",
165
+ ["normal", "lightDirection"]
166
+ ],
167
+ [5, "0"],
168
+ [5, "1"]
169
+ ]
170
+ ]
171
+ ],
172
+ [
173
+ 11,
174
+ [
175
+ 3,
176
+ [
177
+ 1,
178
+ "normalDotView",
179
+ "===",
180
+ [5, "0"]
181
+ ],
182
+ "||",
183
+ [
184
+ 1,
185
+ "normalDotLight",
186
+ "===",
187
+ [5, "0"]
188
+ ]
189
+ ],
190
+ [10, [
191
+ 6,
192
+ "vec3f",
193
+ [[5, "0"]]
194
+ ]]
195
+ ],
196
+ [
197
+ 13,
198
+ "halfwayDirection",
199
+ [
200
+ 6,
201
+ "normalize",
202
+ [[
203
+ 1,
204
+ "viewDirection",
205
+ "+",
206
+ "lightDirection"
207
+ ]]
208
+ ]
209
+ ],
210
+ [
211
+ 13,
212
+ "normalDotHalf",
213
+ [
214
+ 6,
215
+ "clamp",
216
+ [
217
+ [
218
+ 6,
219
+ "dot",
220
+ ["normal", "halfwayDirection"]
221
+ ],
222
+ [5, "0"],
223
+ [5, "1"]
224
+ ]
225
+ ]
226
+ ],
227
+ [
228
+ 13,
229
+ "viewDotHalf",
230
+ [
231
+ 6,
232
+ "clamp",
233
+ [
234
+ [
235
+ 6,
236
+ "dot",
237
+ ["viewDirection", "halfwayDirection"]
238
+ ],
239
+ [5, "0"],
240
+ [5, "1"]
241
+ ]
242
+ ]
243
+ ],
244
+ [
245
+ 13,
246
+ "fresnel",
247
+ [
248
+ 6,
249
+ "fresnelSchlick",
250
+ ["viewDotHalf", "specularF0"]
251
+ ]
252
+ ],
253
+ [
254
+ 13,
255
+ "specular",
256
+ [
257
+ 6,
258
+ "calculateSpecularResponse",
259
+ [
260
+ "normalDotView",
261
+ "normalDotLight",
262
+ "normalDotHalf",
263
+ "alpha",
264
+ "fresnel"
265
+ ]
266
+ ]
267
+ ],
268
+ [
269
+ 13,
270
+ "dielectricFresnel",
271
+ [
272
+ 6,
273
+ "fresnelSchlick",
274
+ ["viewDotHalf", [
275
+ 6,
276
+ "vec3f",
277
+ [[5, "0.04"]]
278
+ ]]
279
+ ]
280
+ ],
281
+ [
282
+ 13,
283
+ "diffuse",
284
+ [
285
+ 1,
286
+ [
287
+ 1,
288
+ [
289
+ 1,
290
+ [5, "1"],
291
+ "-",
292
+ "dielectricFresnel"
293
+ ],
294
+ "*",
295
+ "diffuseColor"
296
+ ],
297
+ "/",
298
+ "Math.PI"
299
+ ]
300
+ ],
301
+ [10, [
302
+ 1,
303
+ "normalDotLight",
304
+ "*",
305
+ [
306
+ 1,
307
+ "diffuse",
308
+ "+",
309
+ "specular"
310
+ ]
311
+ ]]
312
+ ]]
313
+ },
314
+ externals: {
315
+ clamp: () => r,
316
+ dot: () => i,
317
+ vec3f: () => n,
318
+ normalize: () => s,
319
+ fresnelSchlick: () => _,
320
+ calculateSpecularResponse: () => m,
321
+ "Math.PI": () => Math.PI
322
+ }
323
+ }) && e.f)({}), m = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t, n, r, i) {
324
+ "use gpu";
325
+ let a = g(n, r), o = h(e, t, r);
326
+ return __tsover_mul(__tsover_mul(a, o), i);
327
+ }), {
328
+ v: 2,
329
+ name: "calculateSpecularResponse",
330
+ ast: {
331
+ params: [
332
+ {
333
+ type: "i",
334
+ name: "normalDotView"
335
+ },
336
+ {
337
+ type: "i",
338
+ name: "normalDotLight"
339
+ },
340
+ {
341
+ type: "i",
342
+ name: "normalDotHalf"
343
+ },
344
+ {
345
+ type: "i",
346
+ name: "alpha"
347
+ },
348
+ {
349
+ type: "i",
350
+ name: "fresnel"
351
+ }
352
+ ],
353
+ body: [0, [
354
+ [
355
+ 13,
356
+ "distribution",
357
+ [
358
+ 6,
359
+ "distributionGGX",
360
+ ["normalDotHalf", "alpha"]
361
+ ]
362
+ ],
363
+ [
364
+ 13,
365
+ "visibility",
366
+ [
367
+ 6,
368
+ "visibilitySmithGGX",
369
+ [
370
+ "normalDotView",
371
+ "normalDotLight",
372
+ "alpha"
373
+ ]
374
+ ]
375
+ ],
376
+ [10, [
377
+ 1,
378
+ [
379
+ 1,
380
+ "distribution",
381
+ "*",
382
+ "visibility"
383
+ ],
384
+ "*",
385
+ "fresnel"
386
+ ]]
387
+ ]]
388
+ },
389
+ externals: {
390
+ distributionGGX: () => g,
391
+ visibilitySmithGGX: () => h
392
+ }
393
+ }) && e.f)({}), h = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t, n) {
394
+ "use gpu";
395
+ let r = __tsover_mul(n, n), i = __tsover_mul(t, u(__tsover_add(__tsover_mul(__tsover_mul(e, e), __tsover_sub(1, r)), r))), a = __tsover_mul(e, u(__tsover_add(__tsover_mul(__tsover_mul(t, t), __tsover_sub(1, r)), r)));
396
+ return __tsover_div(.5, __tsover_add(i, a));
397
+ }), {
398
+ v: 2,
399
+ name: "visibilitySmithGGX",
400
+ ast: {
401
+ params: [
402
+ {
403
+ type: "i",
404
+ name: "normalDotView"
405
+ },
406
+ {
407
+ type: "i",
408
+ name: "normalDotLight"
409
+ },
410
+ {
411
+ type: "i",
412
+ name: "alpha"
413
+ }
414
+ ],
415
+ body: [0, [
416
+ [
417
+ 13,
418
+ "alphaSquared",
419
+ [
420
+ 1,
421
+ "alpha",
422
+ "*",
423
+ "alpha"
424
+ ]
425
+ ],
426
+ [
427
+ 13,
428
+ "viewTerm",
429
+ [
430
+ 1,
431
+ "normalDotLight",
432
+ "*",
433
+ [
434
+ 6,
435
+ "sqrt",
436
+ [[
437
+ 1,
438
+ [
439
+ 1,
440
+ [
441
+ 1,
442
+ "normalDotView",
443
+ "*",
444
+ "normalDotView"
445
+ ],
446
+ "*",
447
+ [
448
+ 1,
449
+ [5, "1"],
450
+ "-",
451
+ "alphaSquared"
452
+ ]
453
+ ],
454
+ "+",
455
+ "alphaSquared"
456
+ ]]
457
+ ]
458
+ ]
459
+ ],
460
+ [
461
+ 13,
462
+ "lightTerm",
463
+ [
464
+ 1,
465
+ "normalDotView",
466
+ "*",
467
+ [
468
+ 6,
469
+ "sqrt",
470
+ [[
471
+ 1,
472
+ [
473
+ 1,
474
+ [
475
+ 1,
476
+ "normalDotLight",
477
+ "*",
478
+ "normalDotLight"
479
+ ],
480
+ "*",
481
+ [
482
+ 1,
483
+ [5, "1"],
484
+ "-",
485
+ "alphaSquared"
486
+ ]
487
+ ],
488
+ "+",
489
+ "alphaSquared"
490
+ ]]
491
+ ]
492
+ ]
493
+ ],
494
+ [10, [
495
+ 1,
496
+ [5, "0.5"],
497
+ "/",
498
+ [
499
+ 1,
500
+ "viewTerm",
501
+ "+",
502
+ "lightTerm"
503
+ ]
504
+ ]]
505
+ ]]
506
+ },
507
+ externals: { sqrt: () => u }
508
+ }) && e.f)({}), g = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t) {
509
+ "use gpu";
510
+ let n = __tsover_mul(t, t), r = __tsover_add(__tsover_mul(__tsover_mul(e, e), __tsover_sub(n, 1)), 1);
511
+ return __tsover_div(n, __tsover_mul(__tsover_mul(Math.PI, r), r));
512
+ }), {
513
+ v: 2,
514
+ name: "distributionGGX",
515
+ ast: {
516
+ params: [{
517
+ type: "i",
518
+ name: "normalDotHalf"
519
+ }, {
520
+ type: "i",
521
+ name: "alpha"
522
+ }],
523
+ body: [0, [
524
+ [
525
+ 13,
526
+ "alphaSquared",
527
+ [
528
+ 1,
529
+ "alpha",
530
+ "*",
531
+ "alpha"
532
+ ]
533
+ ],
534
+ [
535
+ 13,
536
+ "denominator",
537
+ [
538
+ 1,
539
+ [
540
+ 1,
541
+ [
542
+ 1,
543
+ "normalDotHalf",
544
+ "*",
545
+ "normalDotHalf"
546
+ ],
547
+ "*",
548
+ [
549
+ 1,
550
+ "alphaSquared",
551
+ "-",
552
+ [5, "1"]
553
+ ]
554
+ ],
555
+ "+",
556
+ [5, "1"]
557
+ ]
558
+ ],
559
+ [10, [
560
+ 1,
561
+ "alphaSquared",
562
+ "/",
563
+ [
564
+ 1,
565
+ [
566
+ 1,
567
+ "Math.PI",
568
+ "*",
569
+ "denominator"
570
+ ],
571
+ "*",
572
+ "denominator"
573
+ ]
574
+ ]]
575
+ ]]
576
+ },
577
+ externals: { "Math.PI": () => Math.PI }
578
+ }) && e.f)({}), _ = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t) {
579
+ "use gpu";
580
+ return __tsover_add(t, __tsover_mul(__tsover_sub(1, t), c(__tsover_sub(1, e), 5)));
581
+ }), {
582
+ v: 2,
583
+ name: "fresnelSchlick",
584
+ ast: {
585
+ params: [{
586
+ type: "i",
587
+ name: "cosTheta"
588
+ }, {
589
+ type: "i",
590
+ name: "specularF0"
591
+ }],
592
+ body: [0, [[10, [
593
+ 1,
594
+ "specularF0",
595
+ "+",
596
+ [
597
+ 1,
598
+ [
599
+ 1,
600
+ [5, "1"],
601
+ "-",
602
+ "specularF0"
603
+ ],
604
+ "*",
605
+ [
606
+ 6,
607
+ "pow",
608
+ [[
609
+ 1,
610
+ [5, "1"],
611
+ "-",
612
+ "cosTheta"
613
+ ], [5, "5"]]
614
+ ]
615
+ ]
616
+ ]]]]
617
+ },
618
+ externals: { pow: () => c }
619
+ }) && e.f)({}), v = /*#__PURE__*/ (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(t({
620
+ position: n,
621
+ normal: n,
622
+ material: f
623
+ }), "PbrSurfaceSample");
624
+ function y({ lighting: e, environment: t }) {
625
+ let c = /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, n, r, o) {
626
+ "use gpu";
627
+ let s = t(l(__tsover_mul(-1, e), n), o), c = _(a(i(n, e), 0), r);
628
+ return __tsover_mul(s, c);
629
+ }), {
630
+ v: 2,
631
+ name: "calculateReflection",
632
+ ast: {
633
+ params: [
634
+ {
635
+ type: "i",
636
+ name: "viewDirection"
637
+ },
638
+ {
639
+ type: "i",
640
+ name: "normal"
641
+ },
642
+ {
643
+ type: "i",
644
+ name: "specularF0"
645
+ },
646
+ {
647
+ type: "i",
648
+ name: "roughness"
649
+ }
650
+ ],
651
+ body: [0, [
652
+ [
653
+ 13,
654
+ "reflectionDirection",
655
+ [
656
+ 6,
657
+ "reflect",
658
+ [[
659
+ 1,
660
+ [
661
+ 4,
662
+ "-",
663
+ [5, "1"]
664
+ ],
665
+ "*",
666
+ "viewDirection"
667
+ ], "normal"]
668
+ ]
669
+ ],
670
+ [
671
+ 13,
672
+ "environmentColor",
673
+ [
674
+ 6,
675
+ "environment",
676
+ ["reflectionDirection", "roughness"]
677
+ ]
678
+ ],
679
+ [
680
+ 13,
681
+ "facing",
682
+ [
683
+ 6,
684
+ "max",
685
+ [[
686
+ 6,
687
+ "dot",
688
+ ["normal", "viewDirection"]
689
+ ], [5, "0"]]
690
+ ]
691
+ ],
692
+ [
693
+ 13,
694
+ "fresnel",
695
+ [
696
+ 6,
697
+ "fresnelSchlick",
698
+ ["facing", "specularF0"]
699
+ ]
700
+ ],
701
+ [10, [
702
+ 1,
703
+ "environmentColor",
704
+ "*",
705
+ "fresnel"
706
+ ]]
707
+ ]]
708
+ },
709
+ externals: {
710
+ reflect: () => l,
711
+ environment: () => t,
712
+ max: () => a,
713
+ dot: () => i,
714
+ fresnelSchlick: () => _
715
+ }
716
+ }) && e.f)({}), u = /*#__PURE__*/ ((t) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(t.f = (function(t, n, o, c) {
717
+ "use gpu";
718
+ let l = __tsover_mul(o.baseColor, __tsover_sub(1, o.metallic)), u = __tsover_mul(e().ambient, l), d = e().directionalLights, f = r(i(n, t), 0, 1);
719
+ if (f === 0) return u;
720
+ let m = a(__tsover_mul(o.roughness, o.roughness), .001);
721
+ for (let e of d) {
722
+ if (e.intensity === 0) continue;
723
+ let r = p(n, t, __tsover_mul(-1, s(e.direction)), f, l, c, m);
724
+ u = __tsover_add(u, __tsover_mul(__tsover_mul(e.color, e.intensity), r));
725
+ }
726
+ return u;
727
+ }), {
728
+ v: 2,
729
+ name: "calculateDirectLighting",
730
+ ast: {
731
+ params: [
732
+ {
733
+ type: "i",
734
+ name: "viewDirection"
735
+ },
736
+ {
737
+ type: "i",
738
+ name: "normal"
739
+ },
740
+ {
741
+ type: "i",
742
+ name: "material"
743
+ },
744
+ {
745
+ type: "i",
746
+ name: "specularF0"
747
+ }
748
+ ],
749
+ body: [0, [
750
+ [
751
+ 13,
752
+ "diffuseColor",
753
+ [
754
+ 1,
755
+ [
756
+ 7,
757
+ "material",
758
+ "baseColor"
759
+ ],
760
+ "*",
761
+ [
762
+ 1,
763
+ [5, "1"],
764
+ "-",
765
+ [
766
+ 7,
767
+ "material",
768
+ "metallic"
769
+ ]
770
+ ]
771
+ ]
772
+ ],
773
+ [
774
+ 12,
775
+ "accumulatedLight",
776
+ [
777
+ 1,
778
+ [
779
+ 7,
780
+ [
781
+ 6,
782
+ "lighting",
783
+ []
784
+ ],
785
+ "ambient"
786
+ ],
787
+ "*",
788
+ "diffuseColor"
789
+ ]
790
+ ],
791
+ [
792
+ 13,
793
+ "directionalLights",
794
+ [
795
+ 7,
796
+ [
797
+ 6,
798
+ "lighting",
799
+ []
800
+ ],
801
+ "directionalLights"
802
+ ]
803
+ ],
804
+ [
805
+ 13,
806
+ "normalDotView",
807
+ [
808
+ 6,
809
+ "clamp",
810
+ [
811
+ [
812
+ 6,
813
+ "dot",
814
+ ["normal", "viewDirection"]
815
+ ],
816
+ [5, "0"],
817
+ [5, "1"]
818
+ ]
819
+ ]
820
+ ],
821
+ [
822
+ 11,
823
+ [
824
+ 1,
825
+ "normalDotView",
826
+ "===",
827
+ [5, "0"]
828
+ ],
829
+ [10, "accumulatedLight"]
830
+ ],
831
+ [
832
+ 13,
833
+ "minimumAlpha",
834
+ [5, "0.001"]
835
+ ],
836
+ [
837
+ 13,
838
+ "alpha",
839
+ [
840
+ 6,
841
+ "max",
842
+ [[
843
+ 1,
844
+ [
845
+ 7,
846
+ "material",
847
+ "roughness"
848
+ ],
849
+ "*",
850
+ [
851
+ 7,
852
+ "material",
853
+ "roughness"
854
+ ]
855
+ ], "minimumAlpha"]
856
+ ]
857
+ ],
858
+ [
859
+ 18,
860
+ [13, "light"],
861
+ "directionalLights",
862
+ [0, [
863
+ [
864
+ 11,
865
+ [
866
+ 1,
867
+ [
868
+ 7,
869
+ "light",
870
+ "intensity"
871
+ ],
872
+ "===",
873
+ [5, "0"]
874
+ ],
875
+ [16]
876
+ ],
877
+ [
878
+ 13,
879
+ "lightDirection",
880
+ [
881
+ 1,
882
+ [
883
+ 4,
884
+ "-",
885
+ [5, "1"]
886
+ ],
887
+ "*",
888
+ [
889
+ 6,
890
+ "normalize",
891
+ [[
892
+ 7,
893
+ "light",
894
+ "direction"
895
+ ]]
896
+ ]
897
+ ]
898
+ ],
899
+ [
900
+ 13,
901
+ "response",
902
+ [
903
+ 6,
904
+ "evaluateDirectLightResponse",
905
+ [
906
+ "normal",
907
+ "viewDirection",
908
+ "lightDirection",
909
+ "normalDotView",
910
+ "diffuseColor",
911
+ "specularF0",
912
+ "alpha"
913
+ ]
914
+ ]
915
+ ],
916
+ [
917
+ 2,
918
+ "accumulatedLight",
919
+ "+=",
920
+ [
921
+ 1,
922
+ [
923
+ 1,
924
+ [
925
+ 7,
926
+ "light",
927
+ "color"
928
+ ],
929
+ "*",
930
+ [
931
+ 7,
932
+ "light",
933
+ "intensity"
934
+ ]
935
+ ],
936
+ "*",
937
+ "response"
938
+ ]
939
+ ]
940
+ ]]
941
+ ],
942
+ [10, "accumulatedLight"]
943
+ ]]
944
+ },
945
+ externals: {
946
+ lighting: () => e,
947
+ clamp: () => r,
948
+ dot: () => i,
949
+ max: () => a,
950
+ normalize: () => s,
951
+ evaluateDirectLightResponse: () => p
952
+ }
953
+ }) && t.f)({});
954
+ return /*#__PURE__*/ ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (function(e, t) {
955
+ "use gpu";
956
+ let r = t.material, i = s(__tsover_sub(e, t.position)), a = n(.04), l = o(a, r.baseColor, r.metallic), d = u(i, t.normal, r, l), f = c(i, t.normal, l, r.roughness);
957
+ return __tsover_add(__tsover_add(d, r.emission), f);
958
+ }), {
959
+ v: 2,
960
+ name: "shadeSurface",
961
+ ast: {
962
+ params: [{
963
+ type: "i",
964
+ name: "cameraPosition"
965
+ }, {
966
+ type: "i",
967
+ name: "sample"
968
+ }],
969
+ body: [0, [
970
+ [
971
+ 13,
972
+ "material",
973
+ [
974
+ 7,
975
+ "sample",
976
+ "material"
977
+ ]
978
+ ],
979
+ [
980
+ 13,
981
+ "viewDirection",
982
+ [
983
+ 6,
984
+ "normalize",
985
+ [[
986
+ 1,
987
+ "cameraPosition",
988
+ "-",
989
+ [
990
+ 7,
991
+ "sample",
992
+ "position"
993
+ ]
994
+ ]]
995
+ ]
996
+ ],
997
+ [
998
+ 13,
999
+ "dielectricF0",
1000
+ [
1001
+ 6,
1002
+ "vec3f",
1003
+ [[5, "0.04"]]
1004
+ ]
1005
+ ],
1006
+ [
1007
+ 13,
1008
+ "specularF0",
1009
+ [
1010
+ 6,
1011
+ "mix",
1012
+ [
1013
+ "dielectricF0",
1014
+ [
1015
+ 7,
1016
+ "material",
1017
+ "baseColor"
1018
+ ],
1019
+ [
1020
+ 7,
1021
+ "material",
1022
+ "metallic"
1023
+ ]
1024
+ ]
1025
+ ]
1026
+ ],
1027
+ [
1028
+ 13,
1029
+ "directLighting",
1030
+ [
1031
+ 6,
1032
+ "calculateDirectLighting",
1033
+ [
1034
+ "viewDirection",
1035
+ [
1036
+ 7,
1037
+ "sample",
1038
+ "normal"
1039
+ ],
1040
+ "material",
1041
+ "specularF0"
1042
+ ]
1043
+ ]
1044
+ ],
1045
+ [
1046
+ 13,
1047
+ "reflection",
1048
+ [
1049
+ 6,
1050
+ "calculateReflection",
1051
+ [
1052
+ "viewDirection",
1053
+ [
1054
+ 7,
1055
+ "sample",
1056
+ "normal"
1057
+ ],
1058
+ "specularF0",
1059
+ [
1060
+ 7,
1061
+ "material",
1062
+ "roughness"
1063
+ ]
1064
+ ]
1065
+ ]
1066
+ ],
1067
+ [10, [
1068
+ 1,
1069
+ [
1070
+ 1,
1071
+ "directLighting",
1072
+ "+",
1073
+ [
1074
+ 7,
1075
+ "material",
1076
+ "emission"
1077
+ ]
1078
+ ],
1079
+ "+",
1080
+ "reflection"
1081
+ ]]
1082
+ ]]
1083
+ },
1084
+ externals: {
1085
+ normalize: () => s,
1086
+ vec3f: () => n,
1087
+ mix: () => o,
1088
+ calculateDirectLighting: () => u,
1089
+ calculateReflection: () => c
1090
+ }
1091
+ }) && e.f)({});
1092
+ }
1093
+ function b({ material: e, lighting: t, environment: r }) {
1094
+ let i = y({
1095
+ lighting: t,
1096
+ environment: r
1097
+ });
1098
+ return /*#__PURE__*/ ((t) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(t.f = (function(t) {
1099
+ "use gpu";
1100
+ let r = e(t);
1101
+ return t.isHit ? i(t.rayOrigin, v({
1102
+ position: t.position,
1103
+ normal: t.normal,
1104
+ material: r
1105
+ })) : n(0);
1106
+ }), {
1107
+ v: 2,
1108
+ name: "pbrAppearance",
1109
+ ast: {
1110
+ params: [{
1111
+ type: "i",
1112
+ name: "result"
1113
+ }],
1114
+ body: [0, [
1115
+ [
1116
+ 13,
1117
+ "materialSample",
1118
+ [
1119
+ 6,
1120
+ "material",
1121
+ ["result"]
1122
+ ]
1123
+ ],
1124
+ [
1125
+ 11,
1126
+ [
1127
+ 4,
1128
+ "!",
1129
+ [
1130
+ 7,
1131
+ "result",
1132
+ "isHit"
1133
+ ]
1134
+ ],
1135
+ [10, [
1136
+ 6,
1137
+ "vec3f",
1138
+ [[5, "0"]]
1139
+ ]]
1140
+ ],
1141
+ [10, [
1142
+ 6,
1143
+ "shadeSurface",
1144
+ [[
1145
+ 7,
1146
+ "result",
1147
+ "rayOrigin"
1148
+ ], [
1149
+ 6,
1150
+ "PbrSurfaceSample",
1151
+ [[104, {
1152
+ position: [
1153
+ 7,
1154
+ "result",
1155
+ "position"
1156
+ ],
1157
+ normal: [
1158
+ 7,
1159
+ "result",
1160
+ "normal"
1161
+ ],
1162
+ material: "materialSample"
1163
+ }]]
1164
+ ]]
1165
+ ]]
1166
+ ]]
1167
+ },
1168
+ externals: {
1169
+ material: () => e,
1170
+ vec3f: () => n,
1171
+ shadeSurface: () => i,
1172
+ PbrSurfaceSample: () => v
1173
+ }
1174
+ }) && t.f)({});
1175
+ }
1176
+ //#endregion
1177
+ export { f as PbrMaterial, b as createPbrAppearance, d as mixPbrMaterials };
1178
+
1179
+ //# sourceMappingURL=pbr.js.map