@luma.gl/shadertools 9.1.9 → 9.2.0-alpha.2

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 (170) hide show
  1. package/dist/dist.dev.js +1614 -3716
  2. package/dist/dist.min.js +278 -484
  3. package/dist/index.cjs +366 -804
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +0 -6
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -10
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/shader-assembly/assemble-shaders.d.ts +6 -4
  10. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  11. package/dist/lib/shader-assembly/assemble-shaders.js +14 -9
  12. package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
  13. package/dist/lib/shader-assembly/platform-info.d.ts +1 -1
  14. package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -1
  15. package/dist/lib/shader-module/shader-module.d.ts +1 -1
  16. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  17. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +1 -1
  18. package/dist/lib/wgsl/get-shader-layout-wgsl.js +3 -1
  19. package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +1 -1
  20. package/dist/modules/engine/project/project.d.ts.map +1 -1
  21. package/dist/modules/engine/project/project.js +4 -2
  22. package/dist/modules/engine/project/project.js.map +1 -1
  23. package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
  24. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  25. package/dist/modules/lighting/lights/{lighting-uniforms-glsl.d.ts → lighting-glsl.d.ts} +1 -1
  26. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -0
  27. package/dist/modules/lighting/lights/{lighting-uniforms-glsl.js → lighting-glsl.js} +1 -1
  28. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -0
  29. package/dist/modules/lighting/lights/{lighting-uniforms-wgsl.d.ts → lighting-wgsl.d.ts} +1 -1
  30. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -0
  31. package/dist/modules/lighting/lights/{lighting-uniforms-wgsl.js → lighting-wgsl.js} +1 -1
  32. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -0
  33. package/dist/modules/lighting/lights/lighting.d.ts +1 -3
  34. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  35. package/dist/modules/lighting/lights/lighting.js +4 -4
  36. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  37. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  38. package/dist/modules/lighting/no-material/dirlight.js +1 -2
  39. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  40. package/dist/modules/lighting/pbr-material/{pbr-fragment-glsl.d.ts → pbr-material-glsl.d.ts} +2 -1
  41. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -0
  42. package/dist/modules/lighting/pbr-material/{pbr-fragment-glsl.js → pbr-material-glsl.js} +36 -1
  43. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -0
  44. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +3 -0
  45. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -0
  46. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +487 -0
  47. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -0
  48. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +11 -4
  49. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  50. package/dist/modules/lighting/pbr-material/pbr-material.js +12 -12
  51. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  52. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  53. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  54. package/dist/modules/lighting/phong-material/phong-material.js +1 -1
  55. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  56. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -1
  57. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  58. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +2 -0
  59. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  60. package/dist/modules/math/random/random.d.ts +1 -0
  61. package/dist/modules/math/random/random.d.ts.map +1 -1
  62. package/dist/modules/math/random/random.js +7 -0
  63. package/dist/modules/math/random/random.js.map +1 -1
  64. package/package.json +3 -3
  65. package/src/index.ts +0 -17
  66. package/src/lib/shader-assembly/assemble-shaders.ts +12 -11
  67. package/src/lib/shader-assembly/platform-info.ts +1 -1
  68. package/src/lib/shader-module/shader-module.ts +1 -1
  69. package/src/lib/wgsl/get-shader-layout-wgsl.ts +7 -5
  70. package/src/modules/engine/project/project.ts +8 -5
  71. package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
  72. package/src/modules/lighting/lights/lighting.ts +4 -4
  73. package/src/modules/lighting/no-material/dirlight.ts +2 -3
  74. package/src/modules/lighting/pbr-material/{pbr-fragment-glsl.ts → pbr-material-glsl.ts} +36 -1
  75. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +490 -0
  76. package/src/modules/lighting/pbr-material/pbr-material.ts +12 -12
  77. package/src/modules/lighting/pbr-material/pbr-projection.ts +0 -2
  78. package/src/modules/lighting/phong-material/phong-material.ts +1 -1
  79. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -0
  80. package/src/modules/math/random/random.ts +8 -0
  81. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +0 -1
  82. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js.map +0 -1
  83. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts.map +0 -1
  84. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js.map +0 -1
  85. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +0 -1
  86. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js.map +0 -1
  87. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +0 -2
  88. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +0 -1
  89. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +0 -67
  90. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js.map +0 -1
  91. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +0 -2
  92. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +0 -1
  93. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +0 -39
  94. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js.map +0 -1
  95. package/dist/modules/module-injectors.d.ts +0 -3
  96. package/dist/modules/module-injectors.d.ts.map +0 -1
  97. package/dist/modules/module-injectors.js +0 -31
  98. package/dist/modules/module-injectors.js.map +0 -1
  99. package/dist/modules-webgl1/geometry/geometry.d.ts +0 -9
  100. package/dist/modules-webgl1/geometry/geometry.d.ts.map +0 -1
  101. package/dist/modules-webgl1/geometry/geometry.js +0 -39
  102. package/dist/modules-webgl1/geometry/geometry.js.map +0 -1
  103. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts +0 -10
  104. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +0 -1
  105. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +0 -38
  106. package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +0 -1
  107. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +0 -2
  108. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +0 -1
  109. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +0 -40
  110. package/dist/modules-webgl1/lighting/lights/lights-glsl.js.map +0 -1
  111. package/dist/modules-webgl1/lighting/lights/lights.d.ts +0 -38
  112. package/dist/modules-webgl1/lighting/lights/lights.d.ts.map +0 -1
  113. package/dist/modules-webgl1/lighting/lights/lights.js +0 -93
  114. package/dist/modules-webgl1/lighting/lights/lights.js.map +0 -1
  115. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +0 -2
  116. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +0 -1
  117. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +0 -393
  118. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js.map +0 -1
  119. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +0 -2
  120. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +0 -1
  121. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +0 -43
  122. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js.map +0 -1
  123. package/dist/modules-webgl1/lighting/pbr/pbr.d.ts +0 -23
  124. package/dist/modules-webgl1/lighting/pbr/pbr.d.ts.map +0 -1
  125. package/dist/modules-webgl1/lighting/pbr/pbr.js +0 -21
  126. package/dist/modules-webgl1/lighting/pbr/pbr.js.map +0 -1
  127. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +0 -2
  128. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +0 -1
  129. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +0 -79
  130. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js.map +0 -1
  131. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts +0 -45
  132. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts.map +0 -1
  133. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +0 -44
  134. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +0 -1
  135. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +0 -2
  136. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +0 -1
  137. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +0 -171
  138. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js.map +0 -1
  139. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +0 -2
  140. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +0 -1
  141. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +0 -675
  142. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js.map +0 -1
  143. package/dist/modules-webgl1/math/fp64/fp64.d.ts +0 -35
  144. package/dist/modules-webgl1/math/fp64/fp64.d.ts.map +0 -1
  145. package/dist/modules-webgl1/math/fp64/fp64.js +0 -38
  146. package/dist/modules-webgl1/math/fp64/fp64.js.map +0 -1
  147. package/dist/modules-webgl1/project/project.d.ts +0 -20
  148. package/dist/modules-webgl1/project/project.d.ts.map +0 -1
  149. package/dist/modules-webgl1/project/project.js +0 -114
  150. package/dist/modules-webgl1/project/project.js.map +0 -1
  151. package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +0 -67
  152. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +0 -39
  153. package/src/modules/module-injectors.ts +0 -32
  154. package/src/modules-webgl1/geometry/geometry.ts +0 -41
  155. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +0 -50
  156. package/src/modules-webgl1/lighting/lights/lights-glsl.ts +0 -40
  157. package/src/modules-webgl1/lighting/lights/lights.ts +0 -143
  158. package/src/modules-webgl1/lighting/pbr/README.md +0 -12
  159. package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +0 -396
  160. package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +0 -43
  161. package/src/modules-webgl1/lighting/pbr/pbr.ts +0 -23
  162. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +0 -79
  163. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts +0 -64
  164. package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +0 -171
  165. package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +0 -675
  166. package/src/modules-webgl1/math/fp64/fp64.ts +0 -44
  167. package/src/modules-webgl1/project/README.md +0 -52
  168. package/src/modules-webgl1/project/project.ts +0 -135
  169. /package/src/modules/lighting/lights/{lighting-uniforms-glsl.ts → lighting-glsl.ts} +0 -0
  170. /package/src/modules/lighting/lights/{lighting-uniforms-wgsl.ts → lighting-wgsl.ts} +0 -0
package/dist/index.cjs CHANGED
@@ -34,7 +34,6 @@ __export(dist_exports, {
34
34
  combineInjects: () => combineInjects,
35
35
  convertToVec4: () => convertToVec4,
36
36
  dirlight: () => dirlight,
37
- dirlight1: () => dirlight2,
38
37
  fp32: () => fp32,
39
38
  fp64: () => fp64,
40
39
  fp64LowPart: () => fp64LowPart,
@@ -43,7 +42,6 @@ __export(dist_exports, {
43
42
  fp64ifyMatrix4: () => fp64ifyMatrix4,
44
43
  fromHalfFloat: () => fromHalfFloat,
45
44
  generateShaderForModule: () => generateShaderForModule,
46
- geometry1: () => geometry,
47
45
  getPassthroughFS: () => getPassthroughFS,
48
46
  getQualifierDetails: () => getQualifierDetails,
49
47
  getShaderInfo: () => getShaderInfo,
@@ -51,19 +49,14 @@ __export(dist_exports, {
51
49
  getShaderModuleDependencies: () => getShaderModuleDependencies,
52
50
  getShaderModuleSource: () => getShaderModuleSource,
53
51
  getShaderModuleUniforms: () => getShaderModuleUniforms,
54
- gouraudLighting: () => gouraudLighting,
55
52
  gouraudMaterial: () => gouraudMaterial,
56
53
  initializeShaderModule: () => initializeShaderModule,
57
54
  initializeShaderModules: () => initializeShaderModules,
58
55
  lighting: () => lighting,
59
- lights1: () => lights,
60
- pbr: () => pbr,
61
56
  pbrMaterial: () => pbrMaterial,
62
- phongLighting: () => phongLighting,
63
57
  phongMaterial: () => phongMaterial,
64
58
  picking: () => picking,
65
59
  preprocess: () => preprocess,
66
- project1: () => project,
67
60
  random: () => random,
68
61
  toHalfFloat: () => toHalfFloat,
69
62
  typeToChannelCount: () => typeToChannelCount,
@@ -209,7 +202,7 @@ function getHookStage(hook) {
209
202
  throw new Error(type);
210
203
  }
211
204
  }
212
- function injectShader(source, stage, inject, injectStandardStubs = false) {
205
+ function injectShader(source3, stage, inject, injectStandardStubs = false) {
213
206
  const isVertex = stage === "vertex";
214
207
  for (const key in inject) {
215
208
  const fragmentData = inject[key];
@@ -223,43 +216,43 @@ function injectShader(source, stage, inject, injectStandardStubs = false) {
223
216
  switch (key) {
224
217
  case "vs:#decl":
225
218
  if (isVertex) {
226
- source = source.replace(DECLARATION_INJECT_MARKER, fragmentString);
219
+ source3 = source3.replace(DECLARATION_INJECT_MARKER, fragmentString);
227
220
  }
228
221
  break;
229
222
  case "vs:#main-start":
230
223
  if (isVertex) {
231
- source = source.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
224
+ source3 = source3.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
232
225
  }
233
226
  break;
234
227
  case "vs:#main-end":
235
228
  if (isVertex) {
236
- source = source.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
229
+ source3 = source3.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
237
230
  }
238
231
  break;
239
232
  case "fs:#decl":
240
233
  if (!isVertex) {
241
- source = source.replace(DECLARATION_INJECT_MARKER, fragmentString);
234
+ source3 = source3.replace(DECLARATION_INJECT_MARKER, fragmentString);
242
235
  }
243
236
  break;
244
237
  case "fs:#main-start":
245
238
  if (!isVertex) {
246
- source = source.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
239
+ source3 = source3.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
247
240
  }
248
241
  break;
249
242
  case "fs:#main-end":
250
243
  if (!isVertex) {
251
- source = source.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
244
+ source3 = source3.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
252
245
  }
253
246
  break;
254
247
  default:
255
- source = source.replace(key, (match) => match + fragmentString);
248
+ source3 = source3.replace(key, (match) => match + fragmentString);
256
249
  }
257
250
  }
258
- source = source.replace(DECLARATION_INJECT_MARKER, "");
251
+ source3 = source3.replace(DECLARATION_INJECT_MARKER, "");
259
252
  if (injectStandardStubs) {
260
- source = source.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
253
+ source3 = source3.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
261
254
  }
262
- return source;
255
+ return source3;
263
256
  }
264
257
  function combineInjects(injects) {
265
258
  const result = {};
@@ -439,19 +432,19 @@ function getPlatformShaderDefines(platformInfo) {
439
432
  }
440
433
 
441
434
  // dist/lib/shader-transpiler/transpile-glsl-shader.js
442
- function transpileGLSLShader(source, stage) {
435
+ function transpileGLSLShader(source3, stage) {
443
436
  var _a;
444
- const sourceGLSLVersion = Number(((_a = source.match(/^#version[ \t]+(\d+)/m)) == null ? void 0 : _a[1]) || 100);
437
+ const sourceGLSLVersion = Number(((_a = source3.match(/^#version[ \t]+(\d+)/m)) == null ? void 0 : _a[1]) || 100);
445
438
  if (sourceGLSLVersion !== 300) {
446
439
  throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");
447
440
  }
448
441
  switch (stage) {
449
442
  case "vertex":
450
- source = convertShader(source, ES300_VERTEX_REPLACEMENTS);
451
- return source;
443
+ source3 = convertShader(source3, ES300_VERTEX_REPLACEMENTS);
444
+ return source3;
452
445
  case "fragment":
453
- source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
454
- return source;
446
+ source3 = convertShader(source3, ES300_FRAGMENT_REPLACEMENTS);
447
+ return source3;
455
448
  default:
456
449
  throw new Error(stage);
457
450
  }
@@ -475,11 +468,11 @@ var ES300_FRAGMENT_REPLACEMENTS = [
475
468
  // `varying` keyword replaced with `in`
476
469
  [makeVariableTextRegExp("varying"), "in $1"]
477
470
  ];
478
- function convertShader(source, replacements) {
471
+ function convertShader(source3, replacements) {
479
472
  for (const [pattern, replacement] of replacements) {
480
- source = source.replace(pattern, replacement);
473
+ source3 = source3.replace(pattern, replacement);
481
474
  }
482
- return source;
475
+ return source3;
483
476
  }
484
477
  function makeVariableTextRegExp(qualifier) {
485
478
  return new RegExp(`\\b${qualifier}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`, "g");
@@ -541,11 +534,11 @@ function normalizeShaderHooks(hookFunctions) {
541
534
  }
542
535
 
543
536
  // dist/lib/glsl-utils/get-shader-info.js
544
- function getShaderInfo(source, defaultName) {
537
+ function getShaderInfo(source3, defaultName) {
545
538
  return {
546
- name: getShaderName(source, defaultName),
539
+ name: getShaderName(source3, defaultName),
547
540
  language: "glsl",
548
- version: getShaderVersion(source)
541
+ version: getShaderVersion(source3)
549
542
  };
550
543
  }
551
544
  function getShaderName(shader, defaultName = "unnamed") {
@@ -553,9 +546,9 @@ function getShaderName(shader, defaultName = "unnamed") {
553
546
  const match = SHADER_NAME_REGEXP.exec(shader);
554
547
  return match ? match[1] : defaultName;
555
548
  }
556
- function getShaderVersion(source) {
549
+ function getShaderVersion(source3) {
557
550
  let version = 100;
558
- const words = source.match(/[^\s]+/g);
551
+ const words = source3.match(/[^\s]+/g);
559
552
  if (words && words.length >= 2 && words[0] === "#version") {
560
553
  const parsedVersion = parseInt(words[1], 10);
561
554
  if (Number.isFinite(parsedVersion)) {
@@ -591,19 +584,19 @@ function assembleWGSLShader(options) {
591
584
  };
592
585
  }
593
586
  function assembleGLSLShaderPair(options) {
594
- const { vs: vs6, fs: fs8 } = options;
587
+ const { vs: vs3, fs: fs4 } = options;
595
588
  const modules = getShaderModuleDependencies(options.modules || []);
596
589
  return {
597
590
  vs: assembleShaderGLSL(options.platformInfo, {
598
591
  ...options,
599
- source: vs6,
592
+ source: vs3,
600
593
  stage: "vertex",
601
594
  modules
602
595
  }),
603
596
  fs: assembleShaderGLSL(options.platformInfo, {
604
597
  ...options,
605
598
  // @ts-expect-error
606
- source: fs8,
599
+ source: fs4,
607
600
  stage: "fragment",
608
601
  modules
609
602
  }),
@@ -614,7 +607,7 @@ function assembleShaderWGSL(platformInfo, options) {
614
607
  var _a;
615
608
  const {
616
609
  // id,
617
- source,
610
+ source: source3,
618
611
  stage,
619
612
  modules,
620
613
  // defines = {},
@@ -622,8 +615,8 @@ function assembleShaderWGSL(platformInfo, options) {
622
615
  inject = {},
623
616
  log: log3
624
617
  } = options;
625
- assert(typeof source === "string", "shader source must be a string");
626
- const coreSource = source;
618
+ assert(typeof source3 === "string", "shader source must be a string");
619
+ const coreSource = source3;
627
620
  let assembledSource = "";
628
621
  const hookFunctionMap = normalizeShaderHooks(hookFunctions);
629
622
  const hookInjections = {};
@@ -678,12 +671,12 @@ function assembleShaderWGSL(platformInfo, options) {
678
671
  }
679
672
  function assembleShaderGLSL(platformInfo, options) {
680
673
  var _a;
681
- const { id, source, stage, language = "glsl", modules, defines = {}, hookFunctions = [], inject = {}, prologue = true, log: log3 } = options;
682
- assert(typeof source === "string", "shader source must be a string");
683
- const sourceVersion = language === "glsl" ? getShaderInfo(source).version : -1;
674
+ const { source: source3, stage, language = "glsl", modules, defines = {}, hookFunctions = [], inject = {}, prologue = true, log: log3 } = options;
675
+ assert(typeof source3 === "string", "shader source must be a string");
676
+ const sourceVersion = language === "glsl" ? getShaderInfo(source3).version : -1;
684
677
  const targetVersion = platformInfo.shaderLanguageVersion;
685
678
  const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
686
- const sourceLines = source.split("\n");
679
+ const sourceLines = source3.split("\n");
687
680
  const coreSource = sourceLines.slice(1).join("\n");
688
681
  const allDefines = {};
689
682
  modules.forEach((module2) => {
@@ -698,7 +691,6 @@ function assembleShaderGLSL(platformInfo, options) {
698
691
  assembledSource = prologue ? `${sourceVersionDirective}
699
692
 
700
693
  // ----- PROLOGUE -------------------------
701
- ${getShaderNameDefine({ id, source, stage })}
702
694
  ${`#define SHADER_TYPE_${stage.toUpperCase()}`}
703
695
 
704
696
  ${getPlatformShaderDefines(platformInfo)}
@@ -767,7 +759,7 @@ ${getApplicationDefines(allDefines)}
767
759
  return assembledSource.trim();
768
760
  }
769
761
  function assembleGetUniforms(modules) {
770
- return function getUniforms8(opts) {
762
+ return function getUniforms4(opts) {
771
763
  var _a;
772
764
  const uniforms = {};
773
765
  for (const module2 of modules) {
@@ -777,12 +769,6 @@ function assembleGetUniforms(modules) {
777
769
  return uniforms;
778
770
  };
779
771
  }
780
- function getShaderNameDefine(options) {
781
- const { id, source, stage } = options;
782
- const injectShaderName = id && source.indexOf("SHADER_NAME") === -1;
783
- return injectShaderName ? `
784
- #define SHADER_NAME ${id}_${stage}` : "";
785
- }
786
772
  function getApplicationDefines(defines = {}) {
787
773
  let sourceText = "";
788
774
  for (const define in defines) {
@@ -813,24 +799,24 @@ function getShaderModuleSource(module2, stage) {
813
799
  throw new Error("Shader module must have a name");
814
800
  }
815
801
  const moduleName = module2.name.toUpperCase().replace(/[^0-9a-z]/gi, "_");
816
- let source = `// ----- MODULE ${module2.name} ---------------
802
+ let source3 = `// ----- MODULE ${module2.name} ---------------
817
803
 
818
804
  `;
819
805
  if (stage !== "wgsl") {
820
- source += `#define MODULE_${moduleName}
806
+ source3 += `#define MODULE_${moduleName}
821
807
  `;
822
808
  }
823
- source += `${moduleSource}
809
+ source3 += `${moduleSource}
824
810
  `;
825
- return source;
811
+ return source3;
826
812
  }
827
813
 
828
814
  // dist/lib/preprocessor/preprocessor.js
829
815
  var IFDEF_REGEXP = /^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/;
830
816
  var ENDIF_REGEXP = /^\s*\#\s*endif\s*$/;
831
- function preprocess(source, options) {
817
+ function preprocess(source3, options) {
832
818
  var _a;
833
- const lines = source.split("\n");
819
+ const lines = source3.split("\n");
834
820
  const output = [];
835
821
  let conditional = true;
836
822
  let currentDefine = null;
@@ -898,15 +884,15 @@ var _ShaderAssembler = class {
898
884
  assembleWGSLShader(props) {
899
885
  const modules = this._getModuleList(props.modules);
900
886
  const hookFunctions = this._hookFunctions;
901
- const { source, getUniforms: getUniforms8 } = assembleWGSLShader({
887
+ const { source: source3, getUniforms: getUniforms4 } = assembleWGSLShader({
902
888
  ...props,
903
889
  // @ts-expect-error
904
890
  source: props.source,
905
891
  modules,
906
892
  hookFunctions
907
893
  });
908
- const preprocessedSource = props.platformInfo.shaderLanguage === "wgsl" ? preprocess(source) : source;
909
- return { source: preprocessedSource, getUniforms: getUniforms8, modules };
894
+ const preprocessedSource = props.platformInfo.shaderLanguage === "wgsl" ? preprocess(source3) : source3;
895
+ return { source: preprocessedSource, getUniforms: getUniforms4, modules };
910
896
  }
911
897
  /**
912
898
  * Assemble a pair of shaders into a single shader program
@@ -1152,12 +1138,12 @@ function generateShaderForModule(module2, options) {
1152
1138
  // dist/lib/wgsl/get-shader-layout-wgsl.js
1153
1139
  var import_core = require("@luma.gl/core");
1154
1140
  var import_wgsl_reflect = require("wgsl_reflect");
1155
- function getShaderLayoutFromWGSL(source) {
1141
+ function getShaderLayoutFromWGSL(source3) {
1156
1142
  var _a;
1157
1143
  const shaderLayout = { attributes: [], bindings: [] };
1158
1144
  let parsedWGSL;
1159
1145
  try {
1160
- parsedWGSL = parseWGSL(source);
1146
+ parsedWGSL = parseWGSL(source3);
1161
1147
  } catch (error) {
1162
1148
  import_core.log.error(error.message)();
1163
1149
  return shaderLayout;
@@ -1211,11 +1197,11 @@ function getShaderLayoutFromWGSL(source) {
1211
1197
  return shaderLayout;
1212
1198
  }
1213
1199
  function getType(type) {
1214
- return type.format ? `${type.name}<${type.format.name}>` : type.name;
1200
+ return (type == null ? void 0 : type.format) ? `${type.name}<${type.format.name}>` : type.name;
1215
1201
  }
1216
- function parseWGSL(source) {
1202
+ function parseWGSL(source3) {
1217
1203
  try {
1218
- return new import_wgsl_reflect.WgslReflect(source);
1204
+ return new import_wgsl_reflect.WgslReflect(source3);
1219
1205
  } catch (error) {
1220
1206
  if (error instanceof Error) {
1221
1207
  throw error;
@@ -1340,6 +1326,14 @@ function fp64ifyMatrix4(matrix) {
1340
1326
  }
1341
1327
 
1342
1328
  // dist/modules/math/random/random.js
1329
+ var source = (
1330
+ /* wgsl */
1331
+ `fn random(scale: vec3f, seed: float) -> f32 {
1332
+ /* use the fragment position for a different seed per-pixel */
1333
+ return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
1334
+ }
1335
+ `
1336
+ );
1343
1337
  var fs = (
1344
1338
  /* glsl */
1345
1339
  `float random(vec3 scale, float seed) {
@@ -1350,6 +1344,7 @@ var fs = (
1350
1344
  );
1351
1345
  var random = {
1352
1346
  name: "random",
1347
+ source,
1353
1348
  fs
1354
1349
  };
1355
1350
 
@@ -2578,7 +2573,7 @@ function getUniforms(opts = {}, prevUniforms) {
2578
2573
  // dist/modules/lighting/lights/lighting.js
2579
2574
  var import_core3 = require("@luma.gl/core");
2580
2575
 
2581
- // dist/modules/lighting/lights/lighting-uniforms-glsl.js
2576
+ // dist/modules/lighting/lights/lighting-glsl.js
2582
2577
  var lightingUniformsGLSL = (
2583
2578
  /* glsl */
2584
2579
  `precision highp int;
@@ -2658,7 +2653,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
2658
2653
  `
2659
2654
  );
2660
2655
 
2661
- // dist/modules/lighting/lights/lighting-uniforms-wgsl.js
2656
+ // dist/modules/lighting/lights/lighting-wgsl.js
2662
2657
  var lightingUniformsWGSL = (
2663
2658
  /* wgsl */
2664
2659
  `// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
@@ -2716,7 +2711,7 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
2716
2711
  );
2717
2712
 
2718
2713
  // dist/modules/lighting/lights/lighting.js
2719
- var MAX_LIGHTS = 3;
2714
+ var MAX_LIGHTS = 5;
2720
2715
  var COLOR_FACTOR = 255;
2721
2716
  var LIGHT_TYPE;
2722
2717
  (function(LIGHT_TYPE2) {
@@ -2728,7 +2723,7 @@ var lighting = {
2728
2723
  uniforms: {},
2729
2724
  name: "lighting",
2730
2725
  defines: {
2731
- MAX_LIGHTS
2726
+ // MAX_LIGHTS
2732
2727
  },
2733
2728
  uniformTypes: {
2734
2729
  enabled: "i32",
@@ -2825,10 +2820,10 @@ function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLig
2825
2820
  lightSourceUniforms.pointLightCount = pointLights.length;
2826
2821
  return lightSourceUniforms;
2827
2822
  }
2828
- function extractLightTypes(lights2) {
2823
+ function extractLightTypes(lights) {
2829
2824
  var _a, _b;
2830
2825
  const lightSources = { pointLights: [], directionalLights: [] };
2831
- for (const light of lights2 || []) {
2826
+ for (const light of lights || []) {
2832
2827
  switch (light.type) {
2833
2828
  case "ambient":
2834
2829
  lightSources.ambientLight = light;
@@ -2929,7 +2924,7 @@ var dirlight = {
2929
2924
  function getUniforms3(opts = dirlight.defaultUniforms) {
2930
2925
  const uniforms = {};
2931
2926
  if (opts.lightDirection) {
2932
- uniforms.dirlight_uLightDirection = opts.lightDirection;
2927
+ uniforms.lightDirection = opts.lightDirection;
2933
2928
  }
2934
2929
  return uniforms;
2935
2930
  }
@@ -2947,7 +2942,9 @@ var PHONG_VS = (
2947
2942
  );
2948
2943
  var PHONG_FS = (
2949
2944
  /* glsl */
2950
- `uniform phongMaterialUniforms {
2945
+ `#define MAX_LIGHTS 1
2946
+
2947
+ uniform phongMaterialUniforms {
2951
2948
  uniform float ambient;
2952
2949
  uniform float diffuse;
2953
2950
  uniform float shininess;
@@ -3095,7 +3092,7 @@ var gouraudMaterial = {
3095
3092
  fs: PHONG_VS.replace("phongMaterial", "gouraudMaterial"),
3096
3093
  source: PHONG_WGSL.replaceAll("phongMaterial", "gouraudMaterial"),
3097
3094
  defines: {
3098
- LIGHTING_VERTEX: 1
3095
+ LIGHTING_VERTEX: true
3099
3096
  },
3100
3097
  dependencies: [lighting],
3101
3098
  uniformTypes: {
@@ -3128,7 +3125,7 @@ var phongMaterial = {
3128
3125
  vs: PHONG_VS,
3129
3126
  fs: PHONG_FS,
3130
3127
  defines: {
3131
- LIGHTING_FRAGMENT: 1
3128
+ LIGHTING_FRAGMENT: true
3132
3129
  },
3133
3130
  uniformTypes: {
3134
3131
  ambient: "f32",
@@ -3151,7 +3148,7 @@ var phongMaterial = {
3151
3148
  }
3152
3149
  };
3153
3150
 
3154
- // dist/modules/lighting/pbr-material/pbr-vertex-glsl.js
3151
+ // dist/modules/lighting/pbr-material/pbr-material-glsl.js
3155
3152
  var vs2 = (
3156
3153
  /* glsl */
3157
3154
  `out vec3 pbr_vPosition;
@@ -3189,8 +3186,6 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
3189
3186
  }
3190
3187
  `
3191
3188
  );
3192
-
3193
- // dist/modules/lighting/pbr-material/pbr-fragment-glsl.js
3194
3189
  var fs3 = (
3195
3190
  /* glsl */
3196
3191
  `precision highp float;
@@ -3597,524 +3592,31 @@ vec4 pbr_filterColor(vec4 colorUnused)
3597
3592
  `
3598
3593
  );
3599
3594
 
3600
- // dist/modules/lighting/pbr-material/pbr-projection.js
3601
- var uniformBlock = (
3602
- /* glsl */
3603
- `uniform pbrProjectionUniforms {
3604
- mat4 modelViewProjectionMatrix;
3605
- mat4 modelMatrix;
3606
- mat4 normalMatrix;
3607
- vec3 camera;
3608
- } pbrProjection;
3609
- `
3610
- );
3611
- var pbrProjection = {
3612
- name: "pbrProjection",
3613
- vs: uniformBlock,
3614
- fs: uniformBlock,
3615
- // TODO why is this needed?
3616
- getUniforms: (props) => props,
3617
- uniformTypes: {
3618
- modelViewProjectionMatrix: "mat4x4<f32>",
3619
- modelMatrix: "mat4x4<f32>",
3620
- normalMatrix: "mat4x4<f32>",
3621
- camera: "vec3<i32>"
3622
- }
3623
- };
3624
-
3625
- // dist/modules/lighting/pbr-material/pbr-material.js
3626
- var pbrMaterial = {
3627
- props: {},
3628
- uniforms: {},
3629
- name: "pbrMaterial",
3630
- dependencies: [lighting, pbrProjection],
3631
- vs: vs2,
3632
- fs: fs3,
3633
- defines: {
3634
- LIGHTING_FRAGMENT: 1
3635
- // TODO defining these as 0 breaks shader
3636
- // HAS_NORMALMAP: 0
3637
- // HAS_EMISSIVEMAP: 0,
3638
- // HAS_OCCLUSIONMAP: 0,
3639
- // HAS_BASECOLORMAP: 0,
3640
- // HAS_METALROUGHNESSMAP: 0,
3641
- // ALPHA_CUTOFF: 0
3642
- // USE_IBL: 0
3643
- // PBR_DEBUG: 0
3644
- },
3645
- getUniforms: (props) => props,
3646
- uniformTypes: {
3647
- // Material is unlit
3648
- unlit: "i32",
3649
- // Base color map
3650
- baseColorMapEnabled: "i32",
3651
- baseColorFactor: "vec4<f32>",
3652
- normalMapEnabled: "i32",
3653
- normalScale: "f32",
3654
- // #ifdef HAS_NORMALMAP
3655
- emissiveMapEnabled: "i32",
3656
- emissiveFactor: "vec3<f32>",
3657
- // #ifdef HAS_EMISSIVEMAP
3658
- metallicRoughnessValues: "vec2<f32>",
3659
- metallicRoughnessMapEnabled: "i32",
3660
- occlusionMapEnabled: "i32",
3661
- occlusionStrength: "f32",
3662
- // #ifdef HAS_OCCLUSIONMAP
3663
- alphaCutoffEnabled: "i32",
3664
- alphaCutoff: "f32",
3665
- // #ifdef ALPHA_CUTOFF
3666
- // IBL
3667
- IBLenabled: "i32",
3668
- scaleIBLAmbient: "vec2<f32>",
3669
- // #ifdef USE_IBL
3670
- // debugging flags used for shader output of intermediate PBR variables
3671
- // #ifdef PBR_DEBUG
3672
- scaleDiffBaseMR: "vec4<f32>",
3673
- scaleFGDSpec: "vec4<f32>"
3674
- }
3675
- };
3676
-
3677
- // dist/modules-webgl1/geometry/geometry.js
3678
- var vs3 = (
3679
- /* glsl */
3680
- `varying vec4 geometry_vPosition;
3681
- varying vec3 geometry_vNormal;
3682
-
3683
- void geometry_setNormal(vec3 normal) {
3684
- geometry_vNormal = normal;
3685
- }
3686
-
3687
- void geometry_setPosition(vec4 position) {
3688
- geometry_vPosition = position;
3689
- }
3690
-
3691
- void geometry_setPosition(vec3 position) {
3692
- geometry_vPosition = vec4(position, 1.);
3693
- }
3694
- `
3695
- );
3696
- var fs4 = (
3697
- /* glsl */
3698
- `varying vec4 geometry_vPosition;
3699
- varying vec3 geometry_vNormal;
3700
-
3701
- vec4 geometry_getPosition() {
3702
- return geometry_vPosition;
3703
- }
3704
-
3705
- vec3 geometry_getNormal() {
3706
- return geometry_vNormal;
3707
- }
3708
- `
3709
- );
3710
- var geometry = {
3711
- name: "geometry",
3712
- vs: vs3,
3713
- fs: fs4
3714
- };
3715
-
3716
- // dist/modules-webgl1/project/project.js
3717
- var import_core4 = require("@math.gl/core");
3718
- var IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
3719
- var DEFAULT_MODULE_OPTIONS = {
3720
- modelMatrix: IDENTITY_MATRIX,
3721
- viewMatrix: IDENTITY_MATRIX,
3722
- projectionMatrix: IDENTITY_MATRIX,
3723
- cameraPositionWorld: [0, 0, 0]
3724
- };
3725
- function getUniforms4(opts = DEFAULT_MODULE_OPTIONS, prevUniforms = {}) {
3726
- const uniforms = {};
3727
- if (opts.modelMatrix !== void 0) {
3728
- uniforms.modelMatrix = opts.modelMatrix;
3729
- }
3730
- if (opts.viewMatrix !== void 0) {
3731
- uniforms.viewMatrix = opts.viewMatrix;
3732
- }
3733
- if (opts.projectionMatrix !== void 0) {
3734
- uniforms.projectionMatrix = opts.projectionMatrix;
3735
- }
3736
- if (opts.cameraPositionWorld !== void 0) {
3737
- uniforms.cameraPositionWorld = opts.cameraPositionWorld;
3738
- }
3739
- if (opts.projectionMatrix !== void 0 && opts.viewMatrix !== void 0) {
3740
- uniforms.viewProjectionMatrix = new import_core4.Matrix4(opts.projectionMatrix).multiplyRight(opts.viewMatrix);
3741
- }
3742
- return uniforms;
3743
- }
3744
- var common = (
3745
- /* glsl */
3746
- `varying vec4 project_vPositionWorld;
3747
- varying vec3 project_vNormalWorld;
3748
-
3749
- vec4 project_getPosition_World() {
3750
- return project_vPositionWorld;
3751
- }
3752
-
3753
- vec3 project_getNormal_World() {
3754
- return project_vNormalWorld;
3755
- }
3756
- `
3757
- );
3758
- var vs4 = `${common}
3759
-
3760
- // Unprefixed uniforms
3761
- uniform mat4 modelMatrix;
3762
- uniform mat4 viewMatrix;
3763
- uniform mat4 projectionMatrix;
3764
- uniform mat4 viewProjectionMatrix;
3765
- uniform vec3 cameraPositionWorld;
3766
-
3767
- struct World {
3768
- vec3 position;
3769
- vec3 normal;
3770
- };
3771
-
3772
- World world;
3773
-
3774
- void project_setPosition(vec4 position) {
3775
- project_vPositionWorld = position;
3776
- }
3777
-
3778
- void project_setNormal(vec3 normal) {
3779
- project_vNormalWorld = normal;
3780
- }
3781
-
3782
- void project_setPositionAndNormal_World(vec3 position, vec3 normal) {
3783
- world.position = position;
3784
- world.normal = normal;
3785
- }
3786
-
3787
- void project_setPositionAndNormal_Model(vec3 position, vec3 normal) {
3788
- world.position = (modelMatrix * vec4(position, 1.)).xyz;
3789
- world.normal = mat3(modelMatrix) * normal;
3790
- }
3791
-
3792
- vec4 project_model_to_clipspace(vec4 position) {
3793
- return viewProjectionMatrix * modelMatrix * position;
3794
- }
3795
-
3796
- vec4 project_model_to_clipspace(vec3 position) {
3797
- return viewProjectionMatrix * modelMatrix * vec4(position, 1.);
3798
- }
3799
-
3800
- vec4 project_world_to_clipspace(vec3 position) {
3801
- return viewProjectionMatrix * vec4(position, 1.);
3802
- }
3803
-
3804
- vec4 project_view_to_clipspace(vec3 position) {
3805
- return projectionMatrix * vec4(position, 1.);
3806
- }
3807
-
3808
- vec4 project_to_clipspace(vec3 position) {
3809
- return viewProjectionMatrix * vec4(position, 1.);
3810
- }
3811
- `;
3812
- var fs5 = `
3813
- ${common}`;
3814
- var project = {
3815
- name: "project",
3816
- getUniforms: getUniforms4,
3817
- vs: vs4,
3818
- fs: fs5
3819
- };
3820
-
3821
- // dist/modules-webgl1/lighting/lights/lights-glsl.js
3822
- var lightingShader = (
3823
- /* glsl */
3824
- `#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3825
-
3826
- struct AmbientLight {
3827
- vec3 color;
3828
- };
3829
-
3830
- struct PointLight {
3831
- vec3 color;
3832
- vec3 position;
3833
-
3834
- // Constant-Linear-Exponential
3835
- vec3 attenuation;
3836
- };
3837
-
3838
- struct DirectionalLight {
3839
- vec3 color;
3840
- vec3 direction;
3841
- };
3842
-
3843
- uniform AmbientLight lighting_uAmbientLight;
3844
- uniform PointLight lighting_uPointLight[MAX_LIGHTS];
3845
- uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
3846
- uniform int lighting_uPointLightCount;
3847
- uniform int lighting_uDirectionalLightCount;
3848
-
3849
- uniform bool lighting_uEnabled;
3850
-
3851
- float getPointLightAttenuation(PointLight pointLight, float distance) {
3852
- return pointLight.attenuation.x
3853
- + pointLight.attenuation.y * distance
3854
- + pointLight.attenuation.z * distance * distance;
3855
- }
3856
-
3857
- #endif
3858
- `
3859
- );
3860
-
3861
- // dist/modules-webgl1/lighting/lights/lights.js
3862
- var INITIAL_MODULE_OPTIONS = {
3863
- lightSources: {}
3864
- };
3865
- function convertColor2(colorDef = {}) {
3866
- const { color = [0, 0, 0], intensity = 1 } = colorDef;
3867
- return color.map((component) => component * intensity / 255);
3868
- }
3869
- function getLightSourceUniforms2({ ambientLight, pointLights = [], directionalLights = [] }) {
3870
- const lightSourceUniforms = {};
3871
- if (ambientLight) {
3872
- lightSourceUniforms["lighting_uAmbientLight.color"] = convertColor2(ambientLight);
3873
- } else {
3874
- lightSourceUniforms["lighting_uAmbientLight.color"] = [0, 0, 0];
3875
- }
3876
- pointLights.forEach((pointLight, index) => {
3877
- lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor2(pointLight);
3878
- lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;
3879
- lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [
3880
- 1,
3881
- 0,
3882
- 0
3883
- ];
3884
- });
3885
- lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
3886
- directionalLights.forEach((directionalLight, index) => {
3887
- lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor2(directionalLight);
3888
- lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] = directionalLight.direction;
3889
- });
3890
- lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;
3891
- return lightSourceUniforms;
3892
- }
3893
- function getUniforms5(opts = INITIAL_MODULE_OPTIONS) {
3894
- var _a, _b;
3895
- if ("lightSources" in opts) {
3896
- const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
3897
- const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
3898
- if (!hasLights) {
3899
- return { lighting_uEnabled: false };
3900
- }
3901
- return Object.assign({}, getLightSourceUniforms2({ ambientLight, pointLights, directionalLights }), {
3902
- lighting_uEnabled: true
3903
- });
3904
- }
3905
- if ("lights" in opts) {
3906
- const lightSources = { pointLights: [], directionalLights: [] };
3907
- for (const light of opts.lights || []) {
3908
- switch (light.type) {
3909
- case "ambient":
3910
- lightSources.ambientLight = light;
3911
- break;
3912
- case "directional":
3913
- (_a = lightSources.directionalLights) == null ? void 0 : _a.push(light);
3914
- break;
3915
- case "point":
3916
- (_b = lightSources.pointLights) == null ? void 0 : _b.push(light);
3917
- break;
3918
- default:
3919
- }
3920
- }
3921
- return getUniforms5({ lightSources });
3922
- }
3923
- return {};
3924
- }
3925
- var lights = {
3926
- name: "lights",
3927
- vs: lightingShader,
3928
- fs: lightingShader,
3929
- getUniforms: getUniforms5,
3930
- defines: {
3931
- MAX_LIGHTS: 3
3932
- }
3933
- };
3934
-
3935
- // dist/modules-webgl1/lighting/dirlight/dirlight.js
3936
- var DEFAULT_MODULE_OPTIONS2 = {
3937
- lightDirection: new Float32Array([1, 1, 2])
3938
- };
3939
- function getUniforms6(opts = DEFAULT_MODULE_OPTIONS2) {
3940
- const uniforms = {};
3941
- if (opts.lightDirection) {
3942
- uniforms.dirlight_uLightDirection = opts.lightDirection;
3943
- }
3944
- return uniforms;
3945
- }
3946
- var fs6 = (
3947
- /* glsl */
3948
- `uniform vec3 dirlight_uLightDirection;
3949
-
3950
- /*
3951
- * Returns color attenuated by angle from light source
3952
- */
3953
- vec4 dirlight_filterColor(vec4 color) {
3954
- vec3 normal = project_getNormal_World();
3955
- float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
3956
- return vec4(color.rgb * d, color.a);
3957
- }
3958
- `
3959
- );
3960
- var dirlight2 = {
3961
- name: "dirlight",
3962
- // vs // TODO - reuse normal from geometry module
3963
- fs: fs6,
3964
- getUniforms: getUniforms6,
3965
- dependencies: [project]
3966
- };
3967
-
3968
- // dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js
3969
- var lightingShader2 = (
3970
- /* glsl */
3971
- `
3972
- uniform float lighting_uAmbient;
3973
- uniform float lighting_uDiffuse;
3974
- uniform float lighting_uShininess;
3975
- uniform vec3 lighting_uSpecularColor;
3976
-
3977
- vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
3978
- vec3 halfway_direction = normalize(light_direction + view_direction);
3979
- float lambertian = dot(light_direction, normal_worldspace);
3980
- float specular = 0.0;
3981
- if (lambertian > 0.0) {
3982
- float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
3983
- specular = pow(specular_angle, lighting_uShininess);
3984
- }
3985
- lambertian = max(lambertian, 0.0);
3986
- return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;
3987
- }
3988
-
3989
- vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
3990
- vec3 lightColor = surfaceColor;
3991
-
3992
- if (lighting_uEnabled) {
3993
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
3994
- lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;
3995
-
3996
- for (int i = 0; i < MAX_LIGHTS; i++) {
3997
- if (i >= lighting_uPointLightCount) {
3998
- break;
3999
- }
4000
- PointLight pointLight = lighting_uPointLight[i];
4001
- vec3 light_position_worldspace = pointLight.position;
4002
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
4003
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
4004
- }
4005
-
4006
- for (int i = 0; i < MAX_LIGHTS; i++) {
4007
- if (i >= lighting_uDirectionalLightCount) {
4008
- break;
4009
- }
4010
- DirectionalLight directionalLight = lighting_uDirectionalLight[i];
4011
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
4012
- }
4013
- }
4014
- return lightColor;
4015
- }
4016
-
4017
- vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
4018
- vec3 lightColor = vec3(0, 0, 0);
4019
- vec3 surfaceColor = vec3(0, 0, 0);
4020
-
4021
- if (lighting_uEnabled) {
4022
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
4023
-
4024
- for (int i = 0; i < MAX_LIGHTS; i++) {
4025
- if (i >= lighting_uPointLightCount) {
4026
- break;
4027
- }
4028
- PointLight pointLight = lighting_uPointLight[i];
4029
- vec3 light_position_worldspace = pointLight.position;
4030
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
4031
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
4032
- }
4033
-
4034
- for (int i = 0; i < MAX_LIGHTS; i++) {
4035
- if (i >= lighting_uDirectionalLightCount) {
4036
- break;
4037
- }
4038
- DirectionalLight directionalLight = lighting_uDirectionalLight[i];
4039
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
4040
- }
4041
- }
4042
- return lightColor;
4043
- }
4044
- `
4045
- );
4046
-
4047
- // dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js
4048
- var INITIAL_MODULE_OPTIONS2 = {};
4049
- function getMaterialUniforms(material) {
4050
- const { ambient = 0.35, diffuse = 0.6, shininess = 32, specularColor = [30, 30, 30] } = material;
4051
- return {
4052
- lighting_uAmbient: ambient,
4053
- lighting_uDiffuse: diffuse,
4054
- lighting_uShininess: shininess,
4055
- lighting_uSpecularColor: specularColor.map((x) => x / 255)
4056
- };
4057
- }
4058
- function getUniforms7(opts = INITIAL_MODULE_OPTIONS2) {
4059
- if (!("material" in opts)) {
4060
- return {};
4061
- }
4062
- const { material } = opts;
4063
- if (!material) {
4064
- return { lighting_uEnabled: false };
4065
- }
4066
- return getMaterialUniforms(material);
4067
- }
4068
- var gouraudLighting = {
4069
- name: "gouraud-lighting",
4070
- dependencies: [lights],
4071
- vs: lightingShader2,
4072
- defines: {
4073
- LIGHTING_VERTEX: 1
4074
- },
4075
- getUniforms: getUniforms7
4076
- };
4077
- var phongLighting = {
4078
- name: "phong-lighting",
4079
- dependencies: [lights],
4080
- fs: lightingShader2,
4081
- defines: {
4082
- LIGHTING_FRAGMENT: 1
4083
- },
4084
- getUniforms: getUniforms7
3595
+ // dist/modules/lighting/pbr-material/pbr-material-wgsl.js
3596
+ var source2 = (
3597
+ /* wgsl */
3598
+ `struct PBRFragmentInputs {
3599
+ pbr_vPosition: vec3f,
3600
+ pbr_vUV: vec2f,
3601
+ pbr_vTBN: mat3f,
3602
+ pbr_vNormal: vec3f
4085
3603
  };
4086
3604
 
4087
- // dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js
4088
- var vs5 = (
4089
- /* glsl */
4090
- `uniform mat4 u_MVPMatrix;
4091
- uniform mat4 u_ModelMatrix;
4092
- uniform mat4 u_NormalMatrix;
4093
-
4094
- out vec3 pbr_vPosition;
4095
- out vec2 pbr_vUV;
4096
-
4097
- #ifdef HAS_NORMALS
4098
- # ifdef HAS_TANGENTS
4099
- out mat3 pbr_vTBN;
4100
- # else
4101
- out vec3 pbr_vNormal;
4102
- # endif
4103
- #endif
3605
+ var fragmentInputs: PBRFragmentInputs;
4104
3606
 
4105
- void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
3607
+ fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)
4106
3608
  {
4107
- vec4 pos = u_ModelMatrix * position;
3609
+ var pos: vec4f = pbrProjection.modelMatrix * position;
4108
3610
  pbr_vPosition = vec3(pos.xyz) / pos.w;
4109
3611
 
4110
3612
  #ifdef HAS_NORMALS
4111
3613
  #ifdef HAS_TANGENTS
4112
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
4113
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
4114
- vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
4115
- pbr_vTBN = mat3(tangentW, bitangentW, normalW);
3614
+ let normalW: vec3f = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
3615
+ let tangentW: vec3f = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
3616
+ let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;
3617
+ fragmentInputs,pbr_vTBN = mat3(tangentW, bitangentW, normalW);
4116
3618
  #else // HAS_TANGENTS != 1
4117
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
3619
+ fragmentInputs.pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
4118
3620
  #endif
4119
3621
  #endif
4120
3622
 
@@ -4124,103 +3626,98 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
4124
3626
  pbr_vUV = vec2(0.,0.);
4125
3627
  #endif
4126
3628
  }
4127
- `
4128
- );
4129
3629
 
4130
- // dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js
4131
- var fs7 = (
4132
- /* glsl */
4133
- `precision highp float;
3630
+ struct pbrMaterialUniforms {
3631
+ // Material is unlit
3632
+ unlit: uint32,
4134
3633
 
4135
- uniform bool pbr_uUnlit;
3634
+ // Base color map
3635
+ baseColorMapEnabled: uint32,
3636
+ baseColorFactor: vec4f,
4136
3637
 
4137
- #ifdef USE_IBL
4138
- uniform samplerCube u_DiffuseEnvSampler;
4139
- uniform samplerCube u_SpecularEnvSampler;
4140
- uniform sampler2D u_brdfLUT;
4141
- uniform vec2 u_ScaleIBLAmbient;
4142
- #endif
3638
+ normalMapEnabled : uint32,
3639
+ normalScale: f32, // #ifdef HAS_NORMALMAP
4143
3640
 
3641
+ emissiveMapEnabled: uint32,
3642
+ emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP
3643
+
3644
+ metallicRoughnessValues: vec2f,
3645
+ metallicRoughnessMapEnabled: uint32,
3646
+
3647
+ occlusionMapEnabled: i32,
3648
+ occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP
3649
+
3650
+ alphaCutoffEnabled: i32,
3651
+ alphaCutoff: f32, // #ifdef ALPHA_CUTOFF
3652
+
3653
+ // IBL
3654
+ IBLenabled: i32,
3655
+ scaleIBLAmbient: vec2f, // #ifdef USE_IBL
3656
+
3657
+ // debugging flags used for shader output of intermediate PBR variables
3658
+ // #ifdef PBR_DEBUG
3659
+ scaleDiffBaseMR: vec4f,
3660
+ scaleFGDSpec: vec4f
3661
+ // #endif
3662
+ }
3663
+
3664
+ @binding(2) @group(0) var<uniform> material : pbrMaterialUniforms;
3665
+
3666
+ // Samplers
4144
3667
  #ifdef HAS_BASECOLORMAP
4145
- uniform sampler2D u_BaseColorSampler;
3668
+ uniform sampler2D pbr_baseColorSampler;
4146
3669
  #endif
4147
3670
  #ifdef HAS_NORMALMAP
4148
- uniform sampler2D u_NormalSampler;
4149
- uniform float u_NormalScale;
3671
+ uniform sampler2D pbr_normalSampler;
4150
3672
  #endif
4151
3673
  #ifdef HAS_EMISSIVEMAP
4152
- uniform sampler2D u_EmissiveSampler;
4153
- uniform vec3 u_EmissiveFactor;
3674
+ uniform sampler2D pbr_emissiveSampler;
4154
3675
  #endif
4155
3676
  #ifdef HAS_METALROUGHNESSMAP
4156
- uniform sampler2D u_MetallicRoughnessSampler;
3677
+ uniform sampler2D pbr_metallicRoughnessSampler;
4157
3678
  #endif
4158
3679
  #ifdef HAS_OCCLUSIONMAP
4159
- uniform sampler2D u_OcclusionSampler;
4160
- uniform float u_OcclusionStrength;
4161
- #endif
4162
-
4163
- #ifdef ALPHA_CUTOFF
4164
- uniform float u_AlphaCutoff;
4165
- #endif
4166
-
4167
- uniform vec2 u_MetallicRoughnessValues;
4168
- uniform vec4 u_BaseColorFactor;
4169
-
4170
- uniform vec3 u_Camera;
4171
-
4172
- // debugging flags used for shader output of intermediate PBR variables
4173
- #ifdef PBR_DEBUG
4174
- uniform vec4 u_ScaleDiffBaseMR;
4175
- uniform vec4 u_ScaleFGDSpec;
4176
- #endif
4177
-
4178
- in vec3 pbr_vPosition;
4179
-
4180
- in vec2 pbr_vUV;
4181
-
4182
- #ifdef HAS_NORMALS
4183
- #ifdef HAS_TANGENTS
4184
- in mat3 pbr_vTBN;
4185
- #else
4186
- in vec3 pbr_vNormal;
3680
+ uniform sampler2D pbr_occlusionSampler;
4187
3681
  #endif
3682
+ #ifdef USE_IBL
3683
+ uniform samplerCube pbr_diffuseEnvSampler;
3684
+ uniform samplerCube pbr_specularEnvSampler;
3685
+ uniform sampler2D pbr_brdfLUT;
4188
3686
  #endif
4189
3687
 
4190
3688
  // Encapsulate the various inputs used by the various functions in the shading equation
4191
3689
  // We store values in this struct to simplify the integration of alternative implementations
4192
3690
  // of the shading terms, outlined in the Readme.MD Appendix.
4193
- struct PBRInfo
4194
- {
4195
- float NdotL; // cos angle between normal and light direction
4196
- float NdotV; // cos angle between normal and view direction
4197
- float NdotH; // cos angle between normal and half vector
4198
- float LdotH; // cos angle between light direction and half vector
4199
- float VdotH; // cos angle between view direction and half vector
4200
- float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)
4201
- float metalness; // metallic value at the surface
4202
- vec3 reflectance0; // full reflectance color (normal incidence angle)
4203
- vec3 reflectance90; // reflectance color at grazing angle
4204
- float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])
4205
- vec3 diffuseColor; // color contribution from diffuse lighting
4206
- vec3 specularColor; // color contribution from specular lighting
4207
- vec3 n; // normal at surface point
4208
- vec3 v; // vector from surface point to camera
3691
+ struct PBRInfo {
3692
+ NdotL: f32, // cos angle between normal and light direction
3693
+ NdotV: f32, // cos angle between normal and view direction
3694
+ NdotH: f32, // cos angle between normal and half vector
3695
+ LdotH: f32, // cos angle between light direction and half vector
3696
+ VdotH: f32, // cos angle between view direction and half vector
3697
+ perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader)
3698
+ metalness: f32, // metallic value at the surface
3699
+ reflectance0: vec3f, // full reflectance color (normal incidence angle)
3700
+ reflectance90: vec3f, // reflectance color at grazing angle
3701
+ alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2])
3702
+ diffuseColor: vec3f, // color contribution from diffuse lighting
3703
+ specularColor: vec3f, // color contribution from specular lighting
3704
+ n: vec3f, // normal at surface point
3705
+ v: vec3f, // vector from surface point to camera
4209
3706
  };
4210
3707
 
4211
- const float M_PI = 3.141592653589793;
4212
- const float c_MinRoughness = 0.04;
3708
+ const M_PI = 3.141592653589793;
3709
+ const c_MinRoughness = 0.04;
4213
3710
 
4214
- vec4 SRGBtoLINEAR(vec4 srgbIn)
3711
+ fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
4215
3712
  {
4216
3713
  #ifdef MANUAL_SRGB
4217
3714
  #ifdef SRGB_FAST_APPROXIMATION
4218
- vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
4219
- #else //SRGB_FAST_APPROXIMATION
4220
- vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
4221
- vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
3715
+ var linOut: vec3f = pow(srgbIn.xyz,vec3(2.2));
3716
+ #else // SRGB_FAST_APPROXIMATION
3717
+ var bLess: vec3f = step(vec3(0.04045),srgbIn.xyz);
3718
+ var linOut: vec3f = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
4222
3719
  #endif //SRGB_FAST_APPROXIMATION
4223
- return vec4(linOut,srgbIn.w);;
3720
+ return vec4f(linOut,srgbIn.w);;
4224
3721
  #else //MANUAL_SRGB
4225
3722
  return srgbIn;
4226
3723
  #endif //MANUAL_SRGB
@@ -4228,32 +3725,32 @@ vec4 SRGBtoLINEAR(vec4 srgbIn)
4228
3725
 
4229
3726
  // Find the normal for this fragment, pulling either from a predefined normal map
4230
3727
  // or from the interpolated mesh normal and tangent attributes.
4231
- vec3 getNormal()
3728
+ fn getNormal() -> vec3f
4232
3729
  {
4233
3730
  // Retrieve the tangent space matrix
4234
3731
  #ifndef HAS_TANGENTS
4235
- vec3 pos_dx = dFdx(pbr_vPosition);
4236
- vec3 pos_dy = dFdy(pbr_vPosition);
4237
- vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));
4238
- vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));
4239
- vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
3732
+ var pos_dx: vec3f = dFdx(pbr_vPosition);
3733
+ var pos_dy: vec3f = dFdy(pbr_vPosition);
3734
+ var tex_dx: vec3f = dFdx(vec3(pbr_vUV, 0.0));
3735
+ var tex_dy: vec3f = dFdy(vec3(pbr_vUV, 0.0));
3736
+ var t: vec3f = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
4240
3737
 
4241
3738
  #ifdef HAS_NORMALS
4242
- vec3 ng = normalize(pbr_vNormal);
3739
+ var ng: vec3f = normalize(pbr_vNormal);
4243
3740
  #else
4244
- vec3 ng = cross(pos_dx, pos_dy);
3741
+ var ng: vec3f = cross(pos_dx, pos_dy);
4245
3742
  #endif
4246
3743
 
4247
3744
  t = normalize(t - ng * dot(ng, t));
4248
- vec3 b = normalize(cross(ng, t));
4249
- mat3 tbn = mat3(t, b, ng);
3745
+ var b: vec3f = normalize(cross(ng, t));
3746
+ var tbn: mat3f = mat3f(t, b, ng);
4250
3747
  #else // HAS_TANGENTS
4251
- mat3 tbn = pbr_vTBN;
3748
+ var tbn: mat3f = pbr_vTBN;
4252
3749
  #endif
4253
3750
 
4254
3751
  #ifdef HAS_NORMALMAP
4255
- vec3 n = texture(u_NormalSampler, pbr_vUV).rgb;
4256
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));
3752
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
3753
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
4257
3754
  #else
4258
3755
  // The tbn matrix is linearly interpolated, so we need to re-normalize
4259
3756
  vec3 n = normalize(tbn[2].xyz);
@@ -4266,27 +3763,27 @@ vec3 getNormal()
4266
3763
  // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
4267
3764
  // See our README.md on Environment Maps [3] for additional discussion.
4268
3765
  #ifdef USE_IBL
4269
- vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)
3766
+ fn getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection) -> vec3f
4270
3767
  {
4271
3768
  float mipCount = 9.0; // resolution of 512x512
4272
- float lod = (pbrInputs.perceptualRoughness * mipCount);
3769
+ float lod = (pbrInfo.perceptualRoughness * mipCount);
4273
3770
  // retrieve a scale and bias to F0. See [1], Figure 3
4274
- vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,
4275
- vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;
4276
- vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
3771
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
3772
+ vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
3773
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
4277
3774
 
4278
3775
  #ifdef USE_TEX_LOD
4279
- vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
3776
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
4280
3777
  #else
4281
- vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
3778
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
4282
3779
  #endif
4283
3780
 
4284
- vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;
4285
- vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);
3781
+ vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
3782
+ vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
4286
3783
 
4287
3784
  // For presentation, this allows us to disable IBL terms
4288
- diffuse *= u_ScaleIBLAmbient.x;
4289
- specular *= u_ScaleIBLAmbient.y;
3785
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
3786
+ specular *= pbrMaterial.scaleIBLAmbient.y;
4290
3787
 
4291
3788
  return diffuse + specular;
4292
3789
  }
@@ -4295,32 +3792,29 @@ vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)
4295
3792
  // Basic Lambertian diffuse
4296
3793
  // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
4297
3794
  // See also [1], Equation 1
4298
- vec3 diffuse(PBRInfo pbrInputs)
4299
- {
4300
- return pbrInputs.diffuseColor / M_PI;
3795
+ fn diffuse(pbrInfo: PBRInfo) -> vec3<f32> {
3796
+ return pbrInfo.diffuseColor / PI;
4301
3797
  }
4302
3798
 
4303
3799
  // The following equation models the Fresnel reflectance term of the spec equation (aka F())
4304
3800
  // Implementation of fresnel from [4], Equation 15
4305
- vec3 specularReflection(PBRInfo pbrInputs)
4306
- {
4307
- return pbrInputs.reflectance0 +
4308
- (pbrInputs.reflectance90 - pbrInputs.reflectance0) *
4309
- pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);
3801
+ fn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> {
3802
+ return pbrInfo.reflectance0 +
3803
+ (pbrInfo.reflectance90 - pbrInfo.reflectance0) *
3804
+ pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
4310
3805
  }
4311
3806
 
4312
3807
  // This calculates the specular geometric attenuation (aka G()),
4313
3808
  // where rougher material will reflect less light back to the viewer.
4314
3809
  // This implementation is based on [1] Equation 4, and we adopt their modifications to
4315
3810
  // alphaRoughness as input as originally proposed in [2].
4316
- float geometricOcclusion(PBRInfo pbrInputs)
4317
- {
4318
- float NdotL = pbrInputs.NdotL;
4319
- float NdotV = pbrInputs.NdotV;
4320
- float r = pbrInputs.alphaRoughness;
3811
+ fn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {
3812
+ let NdotL: f32 = pbrInfo.NdotL;
3813
+ let NdotV: f32 = pbrInfo.NdotV;
3814
+ let r: f32 = pbrInfo.alphaRoughness;
4321
3815
 
4322
- float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
4323
- float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
3816
+ let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
3817
+ let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
4324
3818
  return attenuationL * attenuationV;
4325
3819
  }
4326
3820
 
@@ -4330,112 +3824,110 @@ float geometricOcclusion(PBRInfo pbrInputs)
4330
3824
  // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
4331
3825
  // Follows the distribution function recommended in the SIGGRAPH 2013 course notes
4332
3826
  // from EPIC Games [1], Equation 3.
4333
- float microfacetDistribution(PBRInfo pbrInputs)
4334
- {
4335
- float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
4336
- float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;
4337
- return roughnessSq / (M_PI * f * f);
3827
+ fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {
3828
+ let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
3829
+ let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
3830
+ return roughnessSq / (PI * f * f);
4338
3831
  }
4339
3832
 
4340
- void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {
4341
- pbrInputs.NdotL = 1.0;
4342
- pbrInputs.NdotH = 0.0;
4343
- pbrInputs.LdotH = 0.0;
4344
- pbrInputs.VdotH = 1.0;
3833
+ fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
3834
+ (*pbrInfo).NdotL = 1.0;
3835
+ (*pbrInfo).NdotH = 0.0;
3836
+ (*pbrInfo).LdotH = 0.0;
3837
+ (*pbrInfo).VdotH = 1.0;
4345
3838
  }
4346
3839
 
4347
- void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {
4348
- vec3 n = pbrInputs.n;
4349
- vec3 v = pbrInputs.v;
4350
- vec3 l = normalize(lightDirection); // Vector from surface point to light
4351
- vec3 h = normalize(l+v); // Half vector between both l and v
3840
+ fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {
3841
+ let n = (*pbrInfo).n;
3842
+ let v = (*pbrInfo).v;
3843
+ let l = normalize(lightDirection); // Vector from surface point to light
3844
+ let h = normalize(l + v); // Half vector between both l and v
4352
3845
 
4353
- pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);
4354
- pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);
4355
- pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);
4356
- pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);
3846
+ (*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0);
3847
+ (*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);
3848
+ (*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);
3849
+ (*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);
4357
3850
  }
4358
3851
 
4359
- void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {
4360
- vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
4361
- PBRInfo_setDirectionalLight(pbrInputs, light_direction);
3852
+ fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {
3853
+ let light_direction = normalize(pointLight.position - pbr_vPosition);
3854
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
4362
3855
  }
4363
3856
 
4364
- vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {
3857
+ fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
4365
3858
  // Calculate the shading terms for the microfacet specular shading model
4366
- vec3 F = specularReflection(pbrInputs);
4367
- float G = geometricOcclusion(pbrInputs);
4368
- float D = microfacetDistribution(pbrInputs);
3859
+ let F = specularReflection(pbrInfo);
3860
+ let G = geometricOcclusion(pbrInfo);
3861
+ let D = microfacetDistribution(pbrInfo);
4369
3862
 
4370
3863
  // Calculation of analytical lighting contribution
4371
- vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
4372
- vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);
3864
+ let diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
3865
+ let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
4373
3866
  // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
4374
- return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);
3867
+ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
4375
3868
  }
4376
3869
 
4377
- vec4 pbr_filterColor(vec4 colorUnused)
4378
- {
3870
+ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
4379
3871
  // The albedo may be defined from a base texture or a flat color
4380
- #ifdef HAS_BASECOLORMAP
4381
- vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;
4382
- #else
4383
- vec4 baseColor = u_BaseColorFactor;
4384
- #endif
4385
-
4386
- #ifdef ALPHA_CUTOFF
4387
- if (baseColor.a < u_AlphaCutoff) {
3872
+ var baseColor: vec4<f32>;
3873
+ #ifdef HAS_BASECOLORMAP
3874
+ baseColor = SRGBtoLINEAR(textureSample(pbr_baseColorSampler, pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
3875
+ #else
3876
+ baseColor = pbrMaterial.baseColorFactor;
3877
+ #endif
3878
+
3879
+ #ifdef ALPHA_CUTOFF
3880
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
4388
3881
  discard;
4389
3882
  }
4390
- #endif
3883
+ #endif
4391
3884
 
4392
- vec3 color = vec3(0, 0, 0);
3885
+ var color = vec3<f32>(0.0, 0.0, 0.0);
4393
3886
 
4394
- if(pbr_uUnlit){
4395
- color.rgb = baseColor.rgb;
4396
- }
4397
- else{
3887
+ if (pbrMaterial.unlit) {
3888
+ color = baseColor.rgb;
3889
+ } else {
4398
3890
  // Metallic and Roughness material properties are packed together
4399
3891
  // In glTF, these factors can be specified by fixed scalar values
4400
3892
  // or from a metallic-roughness map
4401
- float perceptualRoughness = u_MetallicRoughnessValues.y;
4402
- float metallic = u_MetallicRoughnessValues.x;
4403
- #ifdef HAS_METALROUGHNESSMAP
3893
+ var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
3894
+ var metallic = pbrMaterial.metallicRoughnessValues.x;
3895
+ #ifdef HAS_METALROUGHNESSMAP
4404
3896
  // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
4405
3897
  // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
4406
- vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);
3898
+ let mrSample = textureSample(pbr_metallicRoughnessSampler, pbr_metallicRoughnessSampler, pbr_vUV);
4407
3899
  perceptualRoughness = mrSample.g * perceptualRoughness;
4408
3900
  metallic = mrSample.b * metallic;
4409
- #endif
3901
+ #endif
4410
3902
  perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
4411
3903
  metallic = clamp(metallic, 0.0, 1.0);
4412
3904
  // Roughness is authored as perceptual roughness; as is convention,
4413
3905
  // convert to material roughness by squaring the perceptual roughness [2].
4414
- float alphaRoughness = perceptualRoughness * perceptualRoughness;
3906
+ let alphaRoughness = perceptualRoughness * perceptualRoughness;
4415
3907
 
4416
- vec3 f0 = vec3(0.04);
4417
- vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
3908
+ let f0 = vec3<f32>(0.04);
3909
+ var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);
4418
3910
  diffuseColor *= 1.0 - metallic;
4419
- vec3 specularColor = mix(f0, baseColor.rgb, metallic);
3911
+ let specularColor = mix(f0, baseColor.rgb, metallic);
4420
3912
 
4421
3913
  // Compute reflectance.
4422
- float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
3914
+ let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
4423
3915
 
4424
3916
  // For typical incident reflectance range (between 4% to 100%) set the grazing
4425
3917
  // reflectance to 100% for typical fresnel effect.
4426
3918
  // For very low reflectance range on highly diffuse objects (below 4%),
4427
- // incrementally reduce grazing reflecance to 0%.
4428
- float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
4429
- vec3 specularEnvironmentR0 = specularColor.rgb;
4430
- vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
3919
+ // incrementally reduce grazing reflectance to 0%.
3920
+ let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
3921
+ let specularEnvironmentR0 = specularColor;
3922
+ let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
4431
3923
 
4432
- vec3 n = getNormal(); // normal at surface point
4433
- vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera
3924
+ let n = getNormal(); // normal at surface point
3925
+ let v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
4434
3926
 
4435
- float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
4436
- vec3 reflection = -normalize(reflect(v, n));
3927
+ let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
3928
+ let reflection = -normalize(reflect(v, n));
4437
3929
 
4438
- PBRInfo pbrInputs = PBRInfo(
3930
+ var pbrInfo = PBRInfo(
4439
3931
  0.0, // NdotL
4440
3932
  NdotV,
4441
3933
  0.0, // NdotH
@@ -4452,77 +3944,147 @@ vec4 pbr_filterColor(vec4 colorUnused)
4452
3944
  v
4453
3945
  );
4454
3946
 
4455
- #ifdef USE_LIGHTS
3947
+ #ifdef USE_LIGHTS
4456
3948
  // Apply ambient light
4457
- PBRInfo_setAmbientLight(pbrInputs);
4458
- color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);
3949
+ PBRInfo_setAmbientLight(&pbrInfo);
3950
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
4459
3951
 
4460
3952
  // Apply directional light
4461
- for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
4462
- if (i < lighting_uDirectionalLightCount) {
4463
- PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);
4464
- color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);
3953
+ for (var i = 0; i < lighting.directionalLightCount; i++) {
3954
+ if (i < lighting.directionalLightCount) {
3955
+ PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
3956
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
4465
3957
  }
4466
3958
  }
4467
3959
 
4468
3960
  // Apply point light
4469
- for(int i = 0; i < lighting_uPointLightCount; i++) {
4470
- if (i < lighting_uPointLightCount) {
4471
- PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
4472
- float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
4473
- color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);
3961
+ for (var i = 0; i < lighting.pointLightCount; i++) {
3962
+ if (i < lighting.pointLightCount) {
3963
+ PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));
3964
+ let attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
3965
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
4474
3966
  }
4475
3967
  }
4476
- #endif
3968
+ #endif
4477
3969
 
4478
3970
  // Calculate lighting contribution from image based lighting source (IBL)
4479
- #ifdef USE_IBL
4480
- color += getIBLContribution(pbrInputs, n, reflection);
4481
- #endif
3971
+ #ifdef USE_IBL
3972
+ if (pbrMaterial.IBLenabled) {
3973
+ color += getIBLContribution(pbrInfo, n, reflection);
3974
+ }
3975
+ #endif
4482
3976
 
4483
3977
  // Apply optional PBR terms for additional (optional) shading
4484
- #ifdef HAS_OCCLUSIONMAP
4485
- float ao = texture(u_OcclusionSampler, pbr_vUV).r;
4486
- color = mix(color, color * ao, u_OcclusionStrength);
4487
- #endif
3978
+ #ifdef HAS_OCCLUSIONMAP
3979
+ if (pbrMaterial.occlusionMapEnabled) {
3980
+ let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSampler, pbr_vUV).r;
3981
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
3982
+ }
3983
+ #endif
4488
3984
 
4489
- #ifdef HAS_EMISSIVEMAP
4490
- vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;
4491
- color += emissive;
4492
- #endif
3985
+ #ifdef HAS_EMISSIVEMAP
3986
+ if (pbrMaterial.emissiveMapEnabled) {
3987
+ let emissive = SRGBtoLINEAR(textureSample(pbr_emissiveSampler, pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
3988
+ color += emissive;
3989
+ }
3990
+ #endif
4493
3991
 
4494
3992
  // This section uses mix to override final color for reference app visualization
4495
3993
  // of various parameters in the lighting equation.
4496
- #ifdef PBR_DEBUG
3994
+ #ifdef PBR_DEBUG
4497
3995
  // TODO: Figure out how to debug multiple lights
4498
3996
 
4499
- // color = mix(color, F, u_ScaleFGDSpec.x);
4500
- // color = mix(color, vec3(G), u_ScaleFGDSpec.y);
4501
- // color = mix(color, vec3(D), u_ScaleFGDSpec.z);
4502
- // color = mix(color, specContrib, u_ScaleFGDSpec.w);
4503
-
4504
- // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);
4505
- color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);
4506
- color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);
4507
- color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
4508
- #endif
3997
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
3998
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
3999
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
4000
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
4509
4001
 
4002
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
4003
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
4004
+ color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);
4005
+ color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
4006
+ #endif
4510
4007
  }
4511
4008
 
4512
- return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
4009
+ return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);
4513
4010
  }
4514
4011
  `
4515
4012
  );
4516
4013
 
4517
- // dist/modules-webgl1/lighting/pbr/pbr.js
4518
- var pbr = {
4519
- name: "pbr",
4520
- vs: vs5,
4521
- fs: fs7,
4014
+ // dist/modules/lighting/pbr-material/pbr-projection.js
4015
+ var uniformBlock = (
4016
+ /* glsl */
4017
+ `uniform pbrProjectionUniforms {
4018
+ mat4 modelViewProjectionMatrix;
4019
+ mat4 modelMatrix;
4020
+ mat4 normalMatrix;
4021
+ vec3 camera;
4022
+ } pbrProjection;
4023
+ `
4024
+ );
4025
+ var pbrProjection = {
4026
+ name: "pbrProjection",
4027
+ vs: uniformBlock,
4028
+ fs: uniformBlock,
4029
+ // TODO why is this needed?
4030
+ getUniforms: (props) => props,
4031
+ uniformTypes: {
4032
+ modelViewProjectionMatrix: "mat4x4<f32>",
4033
+ modelMatrix: "mat4x4<f32>",
4034
+ normalMatrix: "mat4x4<f32>",
4035
+ camera: "vec3<i32>"
4036
+ }
4037
+ };
4038
+
4039
+ // dist/modules/lighting/pbr-material/pbr-material.js
4040
+ var pbrMaterial = {
4041
+ props: {},
4042
+ uniforms: {},
4043
+ name: "pbrMaterial",
4044
+ dependencies: [lighting, pbrProjection],
4045
+ source: source2,
4046
+ vs: vs2,
4047
+ fs: fs3,
4522
4048
  defines: {
4523
- LIGHTING_FRAGMENT: 1
4049
+ LIGHTING_FRAGMENT: true,
4050
+ HAS_NORMALMAP: false,
4051
+ HAS_EMISSIVEMAP: false,
4052
+ HAS_OCCLUSIONMAP: false,
4053
+ HAS_BASECOLORMAP: false,
4054
+ HAS_METALROUGHNESSMAP: false,
4055
+ ALPHA_CUTOFF: false,
4056
+ USE_IBL: false,
4057
+ PBR_DEBUG: false
4524
4058
  },
4525
- dependencies: [lights],
4526
- getUniforms: (props) => props
4059
+ getUniforms: (props) => props,
4060
+ uniformTypes: {
4061
+ // Material is unlit
4062
+ unlit: "i32",
4063
+ // Base color map
4064
+ baseColorMapEnabled: "i32",
4065
+ baseColorFactor: "vec4<f32>",
4066
+ normalMapEnabled: "i32",
4067
+ normalScale: "f32",
4068
+ // #ifdef HAS_NORMALMAP
4069
+ emissiveMapEnabled: "i32",
4070
+ emissiveFactor: "vec3<f32>",
4071
+ // #ifdef HAS_EMISSIVEMAP
4072
+ metallicRoughnessValues: "vec2<f32>",
4073
+ metallicRoughnessMapEnabled: "i32",
4074
+ occlusionMapEnabled: "i32",
4075
+ occlusionStrength: "f32",
4076
+ // #ifdef HAS_OCCLUSIONMAP
4077
+ alphaCutoffEnabled: "i32",
4078
+ alphaCutoff: "f32",
4079
+ // #ifdef ALPHA_CUTOFF
4080
+ // IBL
4081
+ IBLenabled: "i32",
4082
+ scaleIBLAmbient: "vec2<f32>",
4083
+ // #ifdef USE_IBL
4084
+ // debugging flags used for shader output of intermediate PBR variables
4085
+ // #ifdef PBR_DEBUG
4086
+ scaleDiffBaseMR: "vec4<f32>",
4087
+ scaleFGDSpec: "vec4<f32>"
4088
+ }
4527
4089
  };
4528
4090
  //# sourceMappingURL=index.cjs.map