@luma.gl/shadertools 9.1.0-alpha.15 → 9.1.0-alpha.17

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 (155) hide show
  1. package/dist/dist.dev.js +322 -389
  2. package/dist/dist.min.js +229 -336
  3. package/dist/index.cjs +321 -391
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -1
  8. package/dist/lib/shader-module/shader-module.d.ts +25 -15
  9. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  10. package/dist/lib/shader-module/shader-module.js +18 -4
  11. package/dist/lib/shader-module/shader-pass.d.ts +4 -2
  12. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  13. package/dist/lib/utils/uniform-types.d.ts +11 -0
  14. package/dist/lib/utils/uniform-types.d.ts.map +1 -0
  15. package/dist/lib/utils/uniform-types.js +1 -0
  16. package/dist/module-injectors.d.ts +1 -1
  17. package/dist/module-injectors.d.ts.map +1 -1
  18. package/dist/module-injectors.js +5 -5
  19. package/dist/modules/engine/picking/picking.d.ts +7 -7
  20. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  21. package/dist/modules/engine/picking/picking.js +2 -2
  22. package/dist/modules/engine/project/project.d.ts +9 -8
  23. package/dist/modules/engine/project/project.d.ts.map +1 -1
  24. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +3 -57
  25. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  26. package/dist/modules/lighting/gouraud-material/gouraud-material.js +9 -6
  27. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  28. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  29. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +35 -12
  30. package/dist/modules/lighting/lights/lighting.d.ts +55 -29
  31. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  32. package/dist/modules/lighting/lights/lighting.js +47 -35
  33. package/dist/modules/lighting/no-material/dirlight.d.ts +3 -3
  34. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  35. package/dist/modules/lighting/no-material/dirlight.js +1 -1
  36. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
  37. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  38. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +56 -60
  39. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +56 -98
  40. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  41. package/dist/modules/lighting/pbr-material/pbr-material.js +14 -22
  42. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
  43. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
  44. package/dist/modules/lighting/pbr-material/pbr-projection.js +24 -0
  45. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
  46. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  47. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +8 -16
  48. package/dist/modules/lighting/phong-material/phong-material.d.ts +5 -59
  49. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  50. package/dist/modules/lighting/phong-material/phong-material.js +6 -4
  51. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -40
  52. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  53. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +8 -87
  54. package/dist/modules/module-injectors.d.ts +1 -1
  55. package/dist/modules/module-injectors.d.ts.map +1 -1
  56. package/dist/modules/module-injectors.js +5 -5
  57. package/dist/modules-webgl1/project/project.d.ts +6 -4
  58. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  59. package/dist/passes/postprocessing/fxaa/fxaa.d.ts +2 -2
  60. package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  61. package/dist/passes/postprocessing/fxaa/fxaa.js +2 -2
  62. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +7 -4
  63. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  64. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +7 -4
  65. package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +1 -1
  66. package/dist/passes/postprocessing/image-adjust-filters/denoise.js +1 -1
  67. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +2 -3
  68. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  69. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +2 -3
  70. package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +2 -2
  71. package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  72. package/dist/passes/postprocessing/image-adjust-filters/noise.js +2 -6
  73. package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +2 -2
  74. package/dist/passes/postprocessing/image-adjust-filters/sepia.js +2 -2
  75. package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +5 -2
  76. package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  77. package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +5 -2
  78. package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +6 -2
  79. package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  80. package/dist/passes/postprocessing/image-adjust-filters/vignette.js +6 -6
  81. package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +3 -3
  82. package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  83. package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +1 -1
  84. package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +2 -2
  85. package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  86. package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +1 -1
  87. package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +2 -2
  88. package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  89. package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +1 -1
  90. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +3 -3
  91. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  92. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +2 -2
  93. package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +3 -3
  94. package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  95. package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +2 -2
  96. package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +16 -12
  97. package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  98. package/dist/passes/postprocessing/image-fun-filters/edgework.js +25 -13
  99. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +2 -2
  100. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  101. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +1 -1
  102. package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +1 -1
  103. package/dist/passes/postprocessing/image-fun-filters/ink.js +1 -1
  104. package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +3 -3
  105. package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  106. package/dist/passes/postprocessing/image-fun-filters/magnify.js +1 -1
  107. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +2 -2
  108. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  109. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +1 -1
  110. package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +1 -1
  111. package/dist/passes/postprocessing/image-warp-filters/swirl.js +1 -1
  112. package/package.json +3 -3
  113. package/src/index.ts +9 -3
  114. package/src/lib/shader-module/shader-module.ts +51 -21
  115. package/src/lib/shader-module/shader-pass.ts +7 -4
  116. package/src/lib/utils/uniform-types.ts +66 -0
  117. package/src/module-injectors.ts +5 -5
  118. package/src/modules/engine/picking/README.md +9 -9
  119. package/src/modules/engine/picking/picking.ts +9 -9
  120. package/src/modules/engine/project/project.ts +10 -9
  121. package/src/modules/lighting/gouraud-material/gouraud-material.ts +14 -12
  122. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +35 -12
  123. package/src/modules/lighting/lights/lighting.ts +84 -54
  124. package/src/modules/lighting/no-material/dirlight.ts +3 -3
  125. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +56 -60
  126. package/src/modules/lighting/pbr-material/pbr-material.ts +40 -74
  127. package/src/modules/lighting/pbr-material/pbr-projection.ts +39 -0
  128. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +8 -16
  129. package/src/modules/lighting/phong-material/phong-material.ts +12 -12
  130. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +8 -88
  131. package/src/modules/module-injectors.ts +5 -5
  132. package/src/modules-webgl1/project/project.ts +8 -7
  133. package/src/passes/postprocessing/fxaa/fxaa.ts +3 -3
  134. package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +7 -4
  135. package/src/passes/postprocessing/image-adjust-filters/denoise.ts +1 -1
  136. package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -3
  137. package/src/passes/postprocessing/image-adjust-filters/noise.ts +2 -6
  138. package/src/passes/postprocessing/image-adjust-filters/sepia.ts +2 -2
  139. package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +5 -2
  140. package/src/passes/postprocessing/image-adjust-filters/vignette.ts +6 -6
  141. package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +3 -3
  142. package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +2 -2
  143. package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +2 -2
  144. package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +3 -3
  145. package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +3 -3
  146. package/src/passes/postprocessing/image-fun-filters/edgework.ts +27 -16
  147. package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +2 -2
  148. package/src/passes/postprocessing/image-fun-filters/ink.ts +1 -1
  149. package/src/passes/postprocessing/image-fun-filters/magnify.ts +3 -3
  150. package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +2 -2
  151. package/src/passes/postprocessing/image-warp-filters/swirl.ts +1 -1
  152. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +0 -42
  153. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +0 -1
  154. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +0 -134
  155. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +0 -137
package/dist/dist.dev.js CHANGED
@@ -203,20 +203,20 @@ var __exports__ = (() => {
203
203
  var MODULE_INJECTORS_FS = (
204
204
  /* glsl */
205
205
  `#ifdef MODULE_MATERIAL
206
- gl_FragColor = material_filterColor(gl_FragColor);
206
+ fragColor = material_filterColor(fragColor);
207
207
  #endif
208
208
 
209
209
  #ifdef MODULE_LIGHTING
210
- gl_FragColor = lighting_filterColor(gl_FragColor);
210
+ fragColor = lighting_filterColor(fragColor);
211
211
  #endif
212
212
 
213
213
  #ifdef MODULE_FOG
214
- gl_FragColor = fog_filterColor(gl_FragColor);
214
+ fragColor = fog_filterColor(fragColor);
215
215
  #endif
216
216
 
217
217
  #ifdef MODULE_PICKING
218
- gl_FragColor = picking_filterHighlightColor(gl_FragColor);
219
- gl_FragColor = picking_filterPickingColor(gl_FragColor);
218
+ fragColor = picking_filterHighlightColor(fragColor);
219
+ fragColor = picking_filterPickingColor(fragColor);
220
220
  #endif
221
221
 
222
222
  #ifdef MODULE_LOGDEPTH
@@ -334,7 +334,7 @@ ${inject[key]}` : inject[key];
334
334
  }
335
335
  initializeShaderModules(module.dependencies || []);
336
336
  const {
337
- uniformPropTypes = {},
337
+ propTypes = {},
338
338
  deprecations = [],
339
339
  // defines = {},
340
340
  inject = {}
@@ -343,26 +343,40 @@ ${inject[key]}` : inject[key];
343
343
  normalizedInjections: normalizeInjections(inject),
344
344
  parsedDeprecations: parseDeprecationDefinitions(deprecations)
345
345
  };
346
- if (uniformPropTypes) {
347
- instance.propValidators = makePropValidators(uniformPropTypes);
346
+ if (propTypes) {
347
+ instance.propValidators = makePropValidators(propTypes);
348
348
  }
349
349
  module.instance = instance;
350
+ let defaultProps = {};
351
+ if (propTypes) {
352
+ defaultProps = Object.entries(propTypes).reduce(
353
+ (obj, [key, propType]) => {
354
+ const value = propType?.value;
355
+ if (value) {
356
+ obj[key] = value;
357
+ }
358
+ return obj;
359
+ },
360
+ {}
361
+ );
362
+ }
363
+ module.defaultUniforms = { ...module.defaultUniforms, ...defaultProps };
350
364
  }
351
365
  function getShaderModuleUniforms(module, props, oldUniforms) {
352
366
  initializeShaderModule(module);
353
367
  const uniforms = oldUniforms || { ...module.defaultUniforms };
354
- if (module.getUniforms) {
368
+ if (props && module.getUniforms) {
355
369
  return module.getUniforms(props, uniforms);
356
370
  }
357
371
  return getValidatedProperties(props, module.instance?.propValidators, module.name);
358
372
  }
359
- function checkShaderModuleDeprecations(shaderModule, shaderSource, log2) {
373
+ function checkShaderModuleDeprecations(shaderModule, shaderSource, log3) {
360
374
  shaderModule.deprecations?.forEach((def) => {
361
375
  if (def.regex?.test(shaderSource)) {
362
376
  if (def.deprecated) {
363
- log2.deprecated(def.old, def.new)();
377
+ log3.deprecated(def.old, def.new)();
364
378
  } else {
365
- log2.removed(def.old, def.new)();
379
+ log3.removed(def.old, def.new)();
366
380
  }
367
381
  }
368
382
  });
@@ -655,7 +669,7 @@ ${DECLARATION_INJECT_MARKER}
655
669
  // defines = {},
656
670
  hookFunctions = [],
657
671
  inject = {},
658
- log: log2
672
+ log: log3
659
673
  } = options;
660
674
  assert(typeof source2 === "string", "shader source must be a string");
661
675
  const coreSource = source2;
@@ -685,8 +699,8 @@ ${DECLARATION_INJECT_MARKER}
685
699
  }
686
700
  const modulesToInject = modules;
687
701
  for (const module of modulesToInject) {
688
- if (log2) {
689
- checkShaderModuleDeprecations(module, coreSource, log2);
702
+ if (log3) {
703
+ checkShaderModuleDeprecations(module, coreSource, log3);
690
704
  }
691
705
  const moduleSource = getShaderModuleSource(module, "wgsl");
692
706
  assembledSource += moduleSource;
@@ -722,7 +736,7 @@ ${DECLARATION_INJECT_MARKER}
722
736
  hookFunctions = [],
723
737
  inject = {},
724
738
  prologue = true,
725
- log: log2
739
+ log: log3
726
740
  } = options;
727
741
  assert(typeof source2 === "string", "shader source must be a string");
728
742
  const sourceVersion = language === "glsl" ? getShaderInfo(source2).version : -1;
@@ -781,8 +795,8 @@ ${getApplicationDefines(allDefines)}
781
795
  }
782
796
  }
783
797
  for (const module of modules) {
784
- if (log2) {
785
- checkShaderModuleDeprecations(module, coreSource, log2);
798
+ if (log3) {
799
+ checkShaderModuleDeprecations(module, coreSource, log3);
786
800
  }
787
801
  const moduleSource = getShaderModuleSource(module, stage);
788
802
  assembledSource += moduleSource;
@@ -6661,7 +6675,7 @@ float tan_fp32(float a) {
6661
6675
  };
6662
6676
 
6663
6677
  // src/modules/engine/picking/picking.ts
6664
- var DEFAULT_HIGHLIGHT_COLOR = new Float32Array([0, 1, 1, 1]);
6678
+ var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
6665
6679
  var vs = (
6666
6680
  /* glsl */
6667
6681
  `uniform pickingUniforms {
@@ -6814,7 +6828,7 @@ vec4 picking_filterColor(vec4 color) {
6814
6828
  isAttribute: false,
6815
6829
  isHighlightActive: false,
6816
6830
  useFloatColors: true,
6817
- highlightedObjectColor: new Float32Array([0, 0, 0]),
6831
+ highlightedObjectColor: [0, 0, 0],
6818
6832
  highlightColor: DEFAULT_HIGHLIGHT_COLOR
6819
6833
  },
6820
6834
  vs,
@@ -6848,6 +6862,9 @@ vec4 picking_filterColor(vec4 color) {
6848
6862
  return uniforms;
6849
6863
  }
6850
6864
 
6865
+ // src/modules/lighting/lights/lighting.ts
6866
+ var import_core3 = __toESM(require_core(), 1);
6867
+
6851
6868
  // src/modules/lighting/lights/lighting-uniforms-glsl.ts
6852
6869
  var lightingUniformsGLSL = (
6853
6870
  /* glsl */
@@ -6871,28 +6888,51 @@ struct DirectionalLight {
6871
6888
 
6872
6889
  uniform lightingUniforms {
6873
6890
  int enabled;
6874
- int pointLightCount;
6891
+ int lightType;
6892
+
6875
6893
  int directionalLightCount;
6894
+ int pointLightCount;
6876
6895
 
6877
6896
  vec3 ambientColor;
6878
6897
 
6879
- int lightType;
6880
- vec3 lightColor;
6881
- vec3 lightDirection;
6882
- vec3 lightPosition;
6883
- vec3 lightAttenuation;
6898
+ vec3 lightColor0;
6899
+ vec3 lightPosition0;
6900
+ vec3 lightDirection0;
6901
+ vec3 lightAttenuation0;
6884
6902
 
6885
- // AmbientLight ambientLight;
6886
- // PointLight pointLight[MAX_LIGHTS];
6887
- // DirectionalLight directionalLight[MAX_LIGHTS];
6903
+ vec3 lightColor1;
6904
+ vec3 lightPosition1;
6905
+ vec3 lightDirection1;
6906
+ vec3 lightAttenuation1;
6907
+
6908
+ vec3 lightColor2;
6909
+ vec3 lightPosition2;
6910
+ vec3 lightDirection2;
6911
+ vec3 lightAttenuation2;
6888
6912
  } lighting;
6889
6913
 
6890
6914
  PointLight lighting_getPointLight(int index) {
6891
- return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
6915
+ switch (index) {
6916
+ case 0:
6917
+ return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
6918
+ case 1:
6919
+ return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
6920
+ case 2:
6921
+ default:
6922
+ return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
6923
+ }
6892
6924
  }
6893
6925
 
6894
6926
  DirectionalLight lighting_getDirectionalLight(int index) {
6895
- return DirectionalLight(lighting.lightColor, lighting.lightDirection);
6927
+ switch (index) {
6928
+ case 0:
6929
+ return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
6930
+ case 1:
6931
+ return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
6932
+ case 2:
6933
+ default:
6934
+ return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
6935
+ }
6896
6936
  }
6897
6937
 
6898
6938
  float getPointLightAttenuation(PointLight pointLight, float distance) {
@@ -6963,7 +7003,7 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
6963
7003
  );
6964
7004
 
6965
7005
  // src/modules/lighting/lights/lighting.ts
6966
- var MAX_LIGHTS = 5;
7006
+ var MAX_LIGHTS = 3;
6967
7007
  var COLOR_FACTOR = 255;
6968
7008
  var lighting = {
6969
7009
  props: {},
@@ -6974,31 +7014,44 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
6974
7014
  },
6975
7015
  uniformTypes: {
6976
7016
  enabled: "i32",
6977
- ambientLightColor: "vec3<f32>",
6978
- numberOfLights: "i32",
6979
- // , array: MAX_LIGHTS,
6980
7017
  lightType: "i32",
6981
- // , array: MAX_LIGHTS,
6982
- lightColor: "vec3<f32>",
6983
- // , array: MAX_LIGHTS,
6984
- lightPosition: "vec3<f32>",
6985
- // , array: MAX_LIGHTS,
7018
+ directionalLightCount: "i32",
7019
+ pointLightCount: "i32",
7020
+ ambientLightColor: "vec3<f32>",
7021
+ // TODO define as arrays once we have appropriate uniformTypes
7022
+ lightColor0: "vec3<f32>",
7023
+ lightPosition0: "vec3<f32>",
6986
7024
  // TODO - could combine direction and attenuation
6987
- lightDirection: "vec3<f32>",
6988
- // , array: MAX_LIGHTS,
6989
- lightAttenuation: "vec3<f32>"
6990
- // , array: MAX_LIGHTS},
7025
+ lightDirection0: "vec3<f32>",
7026
+ lightAttenuation0: "vec3<f32>",
7027
+ lightColor1: "vec3<f32>",
7028
+ lightPosition1: "vec3<f32>",
7029
+ lightDirection1: "vec3<f32>",
7030
+ lightAttenuation1: "vec3<f32>",
7031
+ lightColor2: "vec3<f32>",
7032
+ lightPosition2: "vec3<f32>",
7033
+ lightDirection2: "vec3<f32>",
7034
+ lightAttenuation2: "vec3<f32>"
6991
7035
  },
6992
7036
  defaultUniforms: {
6993
7037
  enabled: 1,
6994
- ambientLightColor: [0.1, 0.1, 0.1],
6995
- numberOfLights: 0,
6996
7038
  lightType: 0 /* POINT */,
6997
- lightColor: [1, 1, 1],
6998
- lightPosition: [1, 1, 2],
7039
+ directionalLightCount: 0,
7040
+ pointLightCount: 0,
7041
+ ambientLightColor: [0.1, 0.1, 0.1],
7042
+ lightColor0: [1, 1, 1],
7043
+ lightPosition0: [1, 1, 2],
6999
7044
  // TODO - could combine direction and attenuation
7000
- lightDirection: [1, 1, 1],
7001
- lightAttenuation: [1, 1, 1]
7045
+ lightDirection0: [1, 1, 1],
7046
+ lightAttenuation0: [1, 0, 0],
7047
+ lightColor1: [1, 1, 1],
7048
+ lightPosition1: [1, 1, 2],
7049
+ lightDirection1: [1, 1, 1],
7050
+ lightAttenuation1: [1, 0, 0],
7051
+ lightColor2: [1, 1, 1],
7052
+ lightPosition2: [1, 1, 2],
7053
+ lightDirection2: [1, 1, 1],
7054
+ lightAttenuation2: [1, 0, 0]
7002
7055
  },
7003
7056
  source: lightingUniformsWGSL,
7004
7057
  vs: lightingUniformsGLSL,
@@ -7033,30 +7086,29 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
7033
7086
  pointLights = [],
7034
7087
  directionalLights = []
7035
7088
  }) {
7036
- const lightSourceUniforms = {
7037
- // lightType: new Array(MAX_LIGHTS).fill(0),
7038
- // lightColor: new Array(MAX_LIGHTS).fill([0, 0, 0]),
7039
- // lightPosition: new Array(MAX_LIGHTS).fill([0, 0, 0]),
7040
- // lightDirection: new Array(MAX_LIGHTS).fill([0, 0, 0]),
7041
- // lightAttenuation: new Array(MAX_LIGHTS).fill([0, 0, 0])
7042
- };
7089
+ const lightSourceUniforms = {};
7043
7090
  lightSourceUniforms.ambientLightColor = convertColor(ambientLight);
7044
7091
  let currentLight = 0;
7045
7092
  for (const pointLight of pointLights) {
7046
7093
  lightSourceUniforms.lightType = 0 /* POINT */;
7047
- lightSourceUniforms.lightColor = convertColor(pointLight);
7048
- lightSourceUniforms.lightPosition = pointLight.position;
7049
- lightSourceUniforms.lightAttenuation = [pointLight.attenuation || 1, 0, 0];
7094
+ const i = currentLight;
7095
+ lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
7096
+ lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
7097
+ lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
7050
7098
  currentLight++;
7051
7099
  }
7052
7100
  for (const directionalLight of directionalLights) {
7053
7101
  lightSourceUniforms.lightType = 1 /* DIRECTIONAL */;
7054
- lightSourceUniforms.lightColor = convertColor(directionalLight);
7055
- lightSourceUniforms.lightPosition = directionalLight.position;
7056
- lightSourceUniforms.lightDirection = directionalLight.direction;
7102
+ const i = currentLight;
7103
+ lightSourceUniforms[`lightColor${i}`] = convertColor(directionalLight);
7104
+ lightSourceUniforms[`lightDirection${i}`] = directionalLight.direction;
7057
7105
  currentLight++;
7058
7106
  }
7059
- lightSourceUniforms.numberOfLights = currentLight;
7107
+ if (currentLight > MAX_LIGHTS) {
7108
+ import_core3.log.warn("MAX_LIGHTS exceeded")();
7109
+ }
7110
+ lightSourceUniforms.directionalLightCount = directionalLights.length;
7111
+ lightSourceUniforms.pointLightCount = pointLights.length;
7060
7112
  return lightSourceUniforms;
7061
7113
  }
7062
7114
  function extractLightTypes(lights2) {
@@ -7155,7 +7207,7 @@ vec4 dirlight_filterColor(vec4 color) {
7155
7207
  lightDirection: "vec3<f32>"
7156
7208
  },
7157
7209
  defaultUniforms: {
7158
- lightDirection: new Float32Array([1, 1, 2])
7210
+ lightDirection: [1, 1, 2]
7159
7211
  },
7160
7212
  getUniforms: getUniforms3
7161
7213
  };
@@ -7167,10 +7219,10 @@ vec4 dirlight_filterColor(vec4 color) {
7167
7219
  return uniforms;
7168
7220
  }
7169
7221
 
7170
- // src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
7171
- var GOURAUD_VS = (
7222
+ // src/modules/lighting/phong-material/phong-shaders-glsl.ts
7223
+ var PHONG_VS = (
7172
7224
  /* glsl */
7173
- `uniform materialUniforms {
7225
+ `uniform phongMaterialUniforms {
7174
7226
  uniform float ambient;
7175
7227
  uniform float diffuse;
7176
7228
  uniform float shininess;
@@ -7178,9 +7230,9 @@ vec4 dirlight_filterColor(vec4 color) {
7178
7230
  } material;
7179
7231
  `
7180
7232
  );
7181
- var GOURAUD_FS = (
7233
+ var PHONG_FS = (
7182
7234
  /* glsl */
7183
- `uniform materialUniforms {
7235
+ `uniform phongMaterialUniforms {
7184
7236
  uniform float ambient;
7185
7237
  uniform float diffuse;
7186
7238
  uniform float shininess;
@@ -7202,63 +7254,27 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
7202
7254
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
7203
7255
  vec3 lightColor = surfaceColor;
7204
7256
 
7205
- if (lighting.enabled) {
7206
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
7207
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
7208
-
7209
- if (lighting.lightType == 0) {
7210
- PointLight pointLight = lighting_getPointLight(0);
7211
- vec3 light_position_worldspace = pointLight.position;
7212
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7213
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
7214
- } else if (lighting.lightType == 1) {
7215
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
7216
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7217
- }
7218
- /*
7219
- for (int i = 0; i < MAX_LIGHTS; i++) {
7220
- if (i >= lighting.pointLightCount) {
7221
- break;
7222
- }
7223
- PointLight pointLight = lighting.pointLight[i];
7224
- vec3 light_position_worldspace = pointLight.position;
7225
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7226
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
7227
- }
7228
-
7229
- for (int i = 0; i < MAX_LIGHTS; i++) {
7230
- if (i >= lighting.directionalLightCount) {
7231
- break;
7232
- }
7233
- DirectionalLight directionalLight = lighting.directionalLight[i];
7234
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7235
- }
7236
- */
7257
+ if (lighting.enabled == 0) {
7258
+ return lightColor;
7237
7259
  }
7238
- return lightColor;
7239
- }
7240
-
7241
- vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
7242
- vec3 lightColor = vec3(0, 0, 0);
7243
- vec3 surfaceColor = vec3(0, 0, 0);
7244
7260
 
7245
- if (lighting.enabled) {
7246
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
7261
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
7262
+ lightColor = material.ambient * surfaceColor * lighting.ambientColor;
7247
7263
 
7248
- switch (lighting.lightType) {
7249
- case 0:
7250
- PointLight pointLight = lighting_getPointLight(0);
7251
- vec3 light_position_worldspace = pointLight.position;
7252
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7253
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
7254
- break;
7264
+ for (int i = 0; i < lighting.pointLightCount; i++) {
7265
+ PointLight pointLight = lighting_getPointLight(i);
7266
+ vec3 light_position_worldspace = pointLight.position;
7267
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7268
+ float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
7269
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
7270
+ }
7255
7271
 
7256
- case 1:
7257
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
7258
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7259
- break;
7260
- }
7272
+ int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
7273
+ for (int i = lighting.pointLightCount; i < totalLights; i++) {
7274
+ DirectionalLight directionalLight = lighting_getDirectionalLight(i);
7275
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7261
7276
  }
7277
+
7262
7278
  return lightColor;
7263
7279
  }
7264
7280
  `
@@ -7267,11 +7283,10 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
7267
7283
  // src/modules/lighting/gouraud-material/gouraud-material.ts
7268
7284
  var gouraudMaterial = {
7269
7285
  props: {},
7270
- uniforms: {},
7271
- name: "gouraud-lighting",
7286
+ name: "gouraudMaterial",
7272
7287
  // Note these are switched between phong and gouraud
7273
- vs: GOURAUD_VS,
7274
- fs: GOURAUD_FS,
7288
+ vs: PHONG_FS.replace("phongMaterial", "gouraudMaterial"),
7289
+ fs: PHONG_VS.replace("phongMaterial", "gouraudMaterial"),
7275
7290
  defines: {
7276
7291
  LIGHTING_VERTEX: 1
7277
7292
  },
@@ -7289,7 +7304,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
7289
7304
  specularColor: [0.15, 0.15, 0.15]
7290
7305
  },
7291
7306
  getUniforms(props) {
7292
- return { ...gouraudMaterial.defaultUniforms, ...props };
7307
+ const uniforms = { ...props };
7308
+ if (uniforms.specularColor) {
7309
+ uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
7310
+ }
7311
+ return { ...gouraudMaterial.defaultUniforms, ...uniforms };
7293
7312
  }
7294
7313
  };
7295
7314
 
@@ -7384,111 +7403,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
7384
7403
  `
7385
7404
  );
7386
7405
 
7387
- // src/modules/lighting/phong-material/phong-shaders-glsl.ts
7388
- var PHONG_VS = (
7389
- /* glsl */
7390
- `uniform phongMaterialUniforms {
7391
- uniform float ambient;
7392
- uniform float diffuse;
7393
- uniform float shininess;
7394
- uniform vec3 specularColor;
7395
- } material;
7396
- `
7397
- );
7398
- var PHONG_FS = (
7399
- /* glsl */
7400
- `uniform phongMaterialUniforms {
7401
- uniform float ambient;
7402
- uniform float diffuse;
7403
- uniform float shininess;
7404
- uniform vec3 specularColor;
7405
- } material;
7406
-
7407
- vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
7408
- vec3 halfway_direction = normalize(light_direction + view_direction);
7409
- float lambertian = dot(light_direction, normal_worldspace);
7410
- float specular = 0.0;
7411
- if (lambertian > 0.0) {
7412
- float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
7413
- specular = pow(specular_angle, material.shininess);
7414
- }
7415
- lambertian = max(lambertian, 0.0);
7416
- return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
7417
- }
7418
-
7419
- vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
7420
- vec3 lightColor = surfaceColor;
7421
-
7422
- if (lighting.enabled == 0) {
7423
- return lightColor;
7424
- }
7425
-
7426
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
7427
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
7428
-
7429
- if (lighting.lightType == 0) {
7430
- PointLight pointLight = lighting_getPointLight(0);
7431
- vec3 light_position_worldspace = pointLight.position;
7432
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7433
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
7434
- } else if (lighting.lightType == 1) {
7435
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
7436
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7437
- }
7438
-
7439
- /*
7440
- for (int i = 0; i < MAX_LIGHTS; i++) {
7441
- if (i >= lighting.pointLightCount) {
7442
- break;
7443
- }
7444
- PointLight pointLight = lighting.pointLight[i];
7445
- vec3 light_position_worldspace = pointLight.position;
7446
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7447
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
7448
- }
7449
-
7450
- for (int i = 0; i < MAX_LIGHTS; i++) {
7451
- if (i >= lighting.directionalLightCount) {
7452
- break;
7453
- }
7454
- DirectionalLight directionalLight = lighting.directionalLight[i];
7455
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7456
- }
7457
- */
7458
- return lightColor;
7459
- }
7460
-
7461
- vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
7462
- vec3 lightColor = vec3(0, 0, 0);
7463
- vec3 surfaceColor = vec3(0, 0, 0);
7464
-
7465
- if (lighting.enabled == 0) {
7466
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
7467
-
7468
- switch (lighting.lightType) {
7469
- case 0:
7470
- PointLight pointLight = lighting_getPointLight(0);
7471
- vec3 light_position_worldspace = pointLight.position;
7472
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
7473
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
7474
- break;
7475
-
7476
- case 1:
7477
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
7478
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
7479
- break;
7480
- }
7481
- }
7482
- return lightColor;
7483
- }
7484
- `
7485
- );
7486
-
7487
7406
  // src/modules/lighting/phong-material/phong-material.ts
7488
7407
  var phongMaterial = {
7489
- props: {},
7490
- uniforms: {},
7491
- name: "phong-lighting",
7408
+ name: "phongMaterial",
7492
7409
  dependencies: [lighting],
7493
7410
  // Note these are switched between phong and gouraud
7494
7411
  source: PHONG_WGSL,
@@ -7510,45 +7427,41 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
7510
7427
  specularColor: [0.15, 0.15, 0.15]
7511
7428
  },
7512
7429
  getUniforms(props) {
7513
- return { ...phongMaterial.defaultUniforms, ...props };
7430
+ const uniforms = { ...props };
7431
+ if (uniforms.specularColor) {
7432
+ uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
7433
+ }
7434
+ return { ...phongMaterial.defaultUniforms, ...uniforms };
7514
7435
  }
7515
7436
  };
7516
7437
 
7517
7438
  // src/modules/lighting/pbr-material/pbr-vertex-glsl.ts
7518
7439
  var vs2 = (
7519
7440
  /* glsl */
7520
- `uniform projection {
7521
- mat4 u_MVPMatrix;
7522
- mat4 u_ModelMatrix;
7523
- mat4 u_NormalMatrix;
7524
- // Projection
7525
- vec3 u_Camera;
7526
- }
7527
-
7528
- varying vec3 pbr_vPosition;
7529
- varying vec2 pbr_vUV;
7441
+ `out vec3 pbr_vPosition;
7442
+ out vec2 pbr_vUV;
7530
7443
 
7531
7444
  #ifdef HAS_NORMALS
7532
7445
  # ifdef HAS_TANGENTS
7533
- varying mat3 pbr_vTBN;
7446
+ out mat3 pbr_vTBN;
7534
7447
  # else
7535
- varying vec3 pbr_vNormal;
7448
+ out vec3 pbr_vNormal;
7536
7449
  # endif
7537
7450
  #endif
7538
7451
 
7539
7452
  void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
7540
7453
  {
7541
- vec4 pos = u_ModelMatrix * position;
7454
+ vec4 pos = pbrProjection.modelMatrix * position;
7542
7455
  pbr_vPosition = vec3(pos.xyz) / pos.w;
7543
7456
 
7544
7457
  #ifdef HAS_NORMALS
7545
7458
  #ifdef HAS_TANGENTS
7546
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
7547
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
7459
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
7460
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
7548
7461
  vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
7549
7462
  pbr_vTBN = mat3(tangentW, bitangentW, normalW);
7550
7463
  #else // HAS_TANGENTS != 1
7551
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
7464
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
7552
7465
  #endif
7553
7466
  #endif
7554
7467
 
@@ -7566,12 +7479,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
7566
7479
  /* glsl */
7567
7480
  `precision highp float;
7568
7481
 
7569
- uniform Projection {
7570
- // Projection
7571
- uniform vec3 u_Camera;
7572
- };
7573
-
7574
- uniform pbrMaterial {
7482
+ uniform pbrMaterialUniforms {
7575
7483
  // Material is unlit
7576
7484
  bool unlit;
7577
7485
 
@@ -7603,40 +7511,40 @@ uniform pbrMaterial {
7603
7511
  vec4 scaleDiffBaseMR;
7604
7512
  vec4 scaleFGDSpec;
7605
7513
  // #endif
7606
- } u_pbrMaterial;
7514
+ } pbrMaterial;
7607
7515
 
7608
7516
  // Samplers
7609
7517
  #ifdef HAS_BASECOLORMAP
7610
- uniform sampler2D u_BaseColorSampler;
7518
+ uniform sampler2D pbr_baseColorSampler;
7611
7519
  #endif
7612
7520
  #ifdef HAS_NORMALMAP
7613
- uniform sampler2D u_NormalSampler;
7521
+ uniform sampler2D pbr_normalSampler;
7614
7522
  #endif
7615
7523
  #ifdef HAS_EMISSIVEMAP
7616
- uniform sampler2D u_EmissiveSampler;
7524
+ uniform sampler2D pbr_emissiveSampler;
7617
7525
  #endif
7618
7526
  #ifdef HAS_METALROUGHNESSMAP
7619
- uniform sampler2D u_MetallicRoughnessSampler;
7527
+ uniform sampler2D pbr_metallicRoughnessSampler;
7620
7528
  #endif
7621
7529
  #ifdef HAS_OCCLUSIONMAP
7622
- uniform sampler2D u_OcclusionSampler;
7530
+ uniform sampler2D pbr_occlusionSampler;
7623
7531
  #endif
7624
7532
  #ifdef USE_IBL
7625
- uniform samplerCube u_DiffuseEnvSampler;
7626
- uniform samplerCube u_SpecularEnvSampler;
7627
- uniform sampler2D u_brdfLUT;
7533
+ uniform samplerCube pbr_diffuseEnvSampler;
7534
+ uniform samplerCube pbr_specularEnvSampler;
7535
+ uniform sampler2D pbr_brdfLUT;
7628
7536
  #endif
7629
7537
 
7630
7538
  // Inputs from vertex shader
7631
7539
 
7632
- varying vec3 pbr_vPosition;
7633
- varying vec2 pbr_vUV;
7540
+ in vec3 pbr_vPosition;
7541
+ in vec2 pbr_vUV;
7634
7542
 
7635
7543
  #ifdef HAS_NORMALS
7636
7544
  #ifdef HAS_TANGENTS
7637
- varying mat3 pbr_vTBN;
7545
+ in mat3 pbr_vTBN;
7638
7546
  #else
7639
- varying vec3 pbr_vNormal;
7547
+ in vec3 pbr_vNormal;
7640
7548
  #endif
7641
7549
  #endif
7642
7550
 
@@ -7704,8 +7612,8 @@ vec3 getNormal()
7704
7612
  #endif
7705
7613
 
7706
7614
  #ifdef HAS_NORMALMAP
7707
- vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;
7708
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_pbrMaterial.normalScale, u_pbrMaterial.normalScale, 1.0)));
7615
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
7616
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
7709
7617
  #else
7710
7618
  // The tbn matrix is linearly interpolated, so we need to re-normalize
7711
7619
  vec3 n = normalize(tbn[2].xyz);
@@ -7723,22 +7631,22 @@ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
7723
7631
  float mipCount = 9.0; // resolution of 512x512
7724
7632
  float lod = (pbrInfo.perceptualRoughness * mipCount);
7725
7633
  // retrieve a scale and bias to F0. See [1], Figure 3
7726
- vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,
7634
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
7727
7635
  vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
7728
- vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
7636
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
7729
7637
 
7730
7638
  #ifdef USE_TEX_LOD
7731
- vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
7639
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
7732
7640
  #else
7733
- vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
7641
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
7734
7642
  #endif
7735
7643
 
7736
7644
  vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
7737
7645
  vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
7738
7646
 
7739
7647
  // For presentation, this allows us to disable IBL terms
7740
- diffuse *= u_pbrMaterial.scaleIBLAmbient.x;
7741
- specular *= u_pbrMaterial.scaleIBLAmbient.y;
7648
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
7649
+ specular *= pbrMaterial.scaleIBLAmbient.y;
7742
7650
 
7743
7651
  return diffuse + specular;
7744
7652
  }
@@ -7830,32 +7738,32 @@ vec4 pbr_filterColor(vec4 colorUnused)
7830
7738
  {
7831
7739
  // The albedo may be defined from a base texture or a flat color
7832
7740
  #ifdef HAS_BASECOLORMAP
7833
- vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_pbrMaterial.baseColorFactor;
7741
+ vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
7834
7742
  #else
7835
- vec4 baseColor = u_pbrMaterial.baseColorFactor;
7743
+ vec4 baseColor = pbrMaterial.baseColorFactor;
7836
7744
  #endif
7837
7745
 
7838
7746
  #ifdef ALPHA_CUTOFF
7839
- if (baseColor.a < u_pbrMaterial.alphaCutoff) {
7747
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
7840
7748
  discard;
7841
7749
  }
7842
7750
  #endif
7843
7751
 
7844
7752
  vec3 color = vec3(0, 0, 0);
7845
7753
 
7846
- if(u_pbrMaterial.unlit){
7754
+ if(pbrMaterial.unlit){
7847
7755
  color.rgb = baseColor.rgb;
7848
7756
  }
7849
7757
  else{
7850
7758
  // Metallic and Roughness material properties are packed together
7851
7759
  // In glTF, these factors can be specified by fixed scalar values
7852
7760
  // or from a metallic-roughness map
7853
- float perceptualRoughness = u_pbrMaterial.metallicRoughnessValues.y;
7854
- float metallic = u_pbrMaterial.metallicRoughnessValues.x;
7761
+ float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
7762
+ float metallic = pbrMaterial.metallicRoughnessValues.x;
7855
7763
  #ifdef HAS_METALROUGHNESSMAP
7856
7764
  // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
7857
7765
  // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
7858
- vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);
7766
+ vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
7859
7767
  perceptualRoughness = mrSample.g * perceptualRoughness;
7860
7768
  metallic = mrSample.b * metallic;
7861
7769
  #endif
@@ -7882,7 +7790,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7882
7790
  vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
7883
7791
 
7884
7792
  vec3 n = getNormal(); // normal at surface point
7885
- vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera
7793
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
7886
7794
 
7887
7795
  float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
7888
7796
  vec3 reflection = -normalize(reflect(v, n));
@@ -7904,47 +7812,48 @@ vec4 pbr_filterColor(vec4 colorUnused)
7904
7812
  v
7905
7813
  );
7906
7814
 
7815
+
7907
7816
  #ifdef USE_LIGHTS
7908
7817
  // Apply ambient light
7909
7818
  PBRInfo_setAmbientLight(pbrInfo);
7910
- color += calculateFinalColor(pbrInfo, lighting_uAmbientLight.color);
7819
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
7911
7820
 
7912
7821
  // Apply directional light
7913
- for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
7914
- if (i < lighting_uDirectionalLightCount) {
7915
- PBRInfo_setDirectionalLight(pbrInfo, lighting_uDirectionalLight[i].direction);
7916
- color += calculateFinalColor(pbrInfo, lighting_uDirectionalLight[i].color);
7822
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
7823
+ if (i < lighting.directionalLightCount) {
7824
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
7825
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
7917
7826
  }
7918
7827
  }
7919
7828
 
7920
7829
  // Apply point light
7921
- for(int i = 0; i < lighting_uPointLightCount; i++) {
7922
- if (i < lighting_uPointLightCount) {
7923
- PBRInfo_setPointLight(pbrInfo, lighting_uPointLight[i]);
7924
- float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
7925
- color += calculateFinalColor(pbrInfo, lighting_uPointLight[i].color / attenuation);
7830
+ for(int i = 0; i < lighting.pointLightCount; i++) {
7831
+ if (i < lighting.pointLightCount) {
7832
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
7833
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
7834
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
7926
7835
  }
7927
7836
  }
7928
7837
  #endif
7929
7838
 
7930
7839
  // Calculate lighting contribution from image based lighting source (IBL)
7931
7840
  #ifdef USE_IBL
7932
- if (u_pbrMateral.IBLEnabled) {
7841
+ if (pbrMaterial.IBLenabled) {
7933
7842
  color += getIBLContribution(pbrInfo, n, reflection);
7934
7843
  }
7935
7844
  #endif
7936
7845
 
7937
- // Apply optional PBR terms for additional (optional) shading
7846
+ // Apply optional PBR terms for additional (optional) shading
7938
7847
  #ifdef HAS_OCCLUSIONMAP
7939
- if (u_pbrMaterial.occlusionMapEnabled) {
7940
- float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;
7941
- color = mix(color, color * ao, u_pbrMaterial.occlusionStrength);
7848
+ if (pbrMaterial.occlusionMapEnabled) {
7849
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
7850
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
7942
7851
  }
7943
7852
  #endif
7944
7853
 
7945
7854
  #ifdef HAS_EMISSIVEMAP
7946
- if (u_pbrMaterial.emmissiveMapEnabled) {
7947
- vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_pbrMaterial.emissiveFactor;
7855
+ if (pbrMaterial.emissiveMapEnabled) {
7856
+ vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
7948
7857
  color += emissive;
7949
7858
  }
7950
7859
  #endif
@@ -7954,15 +7863,15 @@ vec4 pbr_filterColor(vec4 colorUnused)
7954
7863
  #ifdef PBR_DEBUG
7955
7864
  // TODO: Figure out how to debug multiple lights
7956
7865
 
7957
- // color = mix(color, F, u_ScaleFGDSpec.x);
7958
- // color = mix(color, vec3(G), u_ScaleFGDSpec.y);
7959
- // color = mix(color, vec3(D), u_ScaleFGDSpec.z);
7960
- // color = mix(color, specContrib, u_ScaleFGDSpec.w);
7866
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
7867
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
7868
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
7869
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
7961
7870
 
7962
- // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);
7963
- color = mix(color, baseColor.rgb, u_pbrMaterial.scaleDiffBaseMR.y);
7964
- color = mix(color, vec3(metallic), u_pbrMaterial.scaleDiffBaseMR.z);
7965
- color = mix(color, vec3(perceptualRoughness), u_pbrMaterial.scaleDiffBaseMR.w);
7871
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
7872
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
7873
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
7874
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
7966
7875
  #endif
7967
7876
 
7968
7877
  }
@@ -7972,25 +7881,52 @@ vec4 pbr_filterColor(vec4 colorUnused)
7972
7881
  `
7973
7882
  );
7974
7883
 
7884
+ // src/modules/lighting/pbr-material/pbr-projection.ts
7885
+ var uniformBlock = (
7886
+ /* glsl */
7887
+ `uniform pbrProjectionUniforms {
7888
+ mat4 modelViewProjectionMatrix;
7889
+ mat4 modelMatrix;
7890
+ mat4 normalMatrix;
7891
+ vec3 camera;
7892
+ } pbrProjection;
7893
+ `
7894
+ );
7895
+ var pbrProjection = {
7896
+ name: "pbrProjection",
7897
+ vs: uniformBlock,
7898
+ fs: uniformBlock,
7899
+ // TODO why is this needed?
7900
+ getUniforms: (props) => props,
7901
+ uniformTypes: {
7902
+ modelViewProjectionMatrix: "mat4x4<f32>",
7903
+ modelMatrix: "mat4x4<f32>",
7904
+ normalMatrix: "mat4x4<f32>",
7905
+ camera: "vec3<i32>"
7906
+ }
7907
+ };
7908
+
7975
7909
  // src/modules/lighting/pbr-material/pbr-material.ts
7976
7910
  var pbrMaterial = {
7977
7911
  props: {},
7978
7912
  uniforms: {},
7979
- name: "pbr",
7980
- dependencies: [lighting],
7913
+ name: "pbrMaterial",
7914
+ dependencies: [lighting, pbrProjection],
7981
7915
  vs: vs2,
7982
7916
  fs: fs3,
7983
7917
  defines: {
7984
- LIGHTING_FRAGMENT: 1,
7985
- HAS_NORMALMAP: 0,
7986
- HAS_EMISSIVEMAP: 0,
7987
- HAS_OCCLUSIONMAP: 0,
7988
- HAS_BASECOLORMAP: 0,
7989
- HAS_METALROUGHNESSMAP: 0,
7990
- ALPHA_CUTOFF: 0,
7991
- USE_IBL: 0,
7992
- PBR_DEBUG: 0
7918
+ LIGHTING_FRAGMENT: 1
7919
+ // TODO defining these as 0 breaks shader
7920
+ // HAS_NORMALMAP: 0
7921
+ // HAS_EMISSIVEMAP: 0,
7922
+ // HAS_OCCLUSIONMAP: 0,
7923
+ // HAS_BASECOLORMAP: 0,
7924
+ // HAS_METALROUGHNESSMAP: 0,
7925
+ // ALPHA_CUTOFF: 0
7926
+ // USE_IBL: 0
7927
+ // PBR_DEBUG: 0
7993
7928
  },
7929
+ getUniforms: (props) => props,
7994
7930
  uniformTypes: {
7995
7931
  // Material is unlit
7996
7932
  unlit: "i32",
@@ -8019,25 +7955,6 @@ vec4 pbr_filterColor(vec4 colorUnused)
8019
7955
  // #ifdef PBR_DEBUG
8020
7956
  scaleDiffBaseMR: "vec4<f32>",
8021
7957
  scaleFGDSpec: "vec4<f32>"
8022
- },
8023
- bindings: {
8024
- baseColorSampler: { type: "texture", location: 8 },
8025
- // #ifdef HAS_BASECOLORMAP
8026
- normalSampler: { type: "texture", location: 9 },
8027
- // #ifdef HAS_NORMALMAP
8028
- emissiveSampler: { type: "texture", location: 10 },
8029
- // #ifdef HAS_EMISSIVEMAP
8030
- metallicRoughnessSampler: { type: "texture", location: 11 },
8031
- // #ifdef HAS_METALROUGHNESSMAP
8032
- occlusionSampler: { type: "texture", location: 12 },
8033
- // #ifdef HAS_OCCLUSIONMAP
8034
- // IBL Samplers
8035
- diffuseEnvSampler: { type: "texture", location: 13 },
8036
- // #ifdef USE_IBL (samplerCube)
8037
- specularEnvSampler: { type: "texture", location: 14 },
8038
- // #ifdef USE_IBL (samplerCube)
8039
- brdfLUT: { type: "texture", location: 15 }
8040
- // #ifdef USE_IBL
8041
7958
  }
8042
7959
  };
8043
7960
 
@@ -8052,7 +7969,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
8052
7969
  // Binding 0:1 is reserved for shader passes
8053
7970
  @binding(1) @group(0) var<uniform> brightnessContrast : brightnessContrastUniforms;
8054
7971
 
8055
- fn brightnessContrast_filterColor(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {
7972
+ fn brightnessContrast_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {
8056
7973
  color.rgb += brightnessContrast.brightness;
8057
7974
  if (brightnessContrast.contrast > 0.0) {
8058
7975
  color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
@@ -8080,20 +7997,23 @@ vec4 brightnessContrast_filterColor(vec4 color) {
8080
7997
  return color;
8081
7998
  }
8082
7999
 
8083
- vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
8000
+ vec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8084
8001
  return brightnessContrast_filterColor(color);
8085
8002
  }
8086
8003
  `
8087
8004
  );
8088
8005
  var brightnessContrast = {
8089
8006
  props: {},
8090
- uniforms: {},
8091
8007
  name: "brightnessContrast",
8092
8008
  uniformTypes: {
8093
8009
  brightness: "f32",
8094
8010
  contrast: "f32"
8095
8011
  },
8096
- uniformPropTypes: {
8012
+ defaultUniforms: {
8013
+ brightness: 0,
8014
+ contrast: 0
8015
+ },
8016
+ propTypes: {
8097
8017
  brightness: { format: "f32", value: 0, min: -1, max: 1 },
8098
8018
  contrast: { format: "f32", value: 0, min: -1, max: 1 }
8099
8019
  },
@@ -8136,7 +8056,7 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8136
8056
  uniformTypes: {
8137
8057
  strength: "f32"
8138
8058
  },
8139
- uniformPropTypes: {
8059
+ propTypes: {
8140
8060
  strength: { format: "f32", value: 0.5, min: 0, max: 1 }
8141
8061
  // strength: {..., adjust: (strength: number): number => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing
8142
8062
  },
@@ -8175,21 +8095,20 @@ vec4 hueSaturation_filterColor(vec4 color) {
8175
8095
  return color;
8176
8096
  }
8177
8097
 
8178
- vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8098
+ vec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8179
8099
  return hueSaturation_filterColor(color);
8180
8100
  }
8181
8101
  `
8182
8102
  );
8183
8103
  var hueSaturation = {
8184
8104
  props: {},
8185
- uniforms: {},
8186
8105
  name: "hueSaturation",
8187
8106
  fs: fs6,
8188
8107
  uniformTypes: {
8189
8108
  hue: "f32",
8190
8109
  saturation: "f32"
8191
8110
  },
8192
- uniformPropTypes: {
8111
+ propTypes: {
8193
8112
  hue: { value: 0, min: -1, max: 1 },
8194
8113
  saturation: { value: 0, min: -1, max: 1 }
8195
8114
  },
@@ -8207,17 +8126,13 @@ float rand(vec2 co) {
8207
8126
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
8208
8127
  }
8209
8128
 
8210
- vec4 noise_filterColor(vec4 color, vec2 texCoord) {
8129
+ vec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8211
8130
  float diff = (rand(texCoord) - 0.5) * noise.amount;
8212
8131
  color.r += diff;
8213
8132
  color.g += diff;
8214
8133
  color.b += diff;
8215
8134
  return color;
8216
8135
  }
8217
-
8218
- vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8219
- return noise_filterColor(color, texCoord);
8220
- }
8221
8136
  `
8222
8137
  );
8223
8138
  var noise = {
@@ -8227,7 +8142,7 @@ vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8227
8142
  uniformTypes: {
8228
8143
  amount: "f32"
8229
8144
  },
8230
- uniformPropTypes: {
8145
+ propTypes: {
8231
8146
  amount: { value: 0.5, min: 0, max: 1 }
8232
8147
  },
8233
8148
  fs: fs7,
@@ -8254,7 +8169,7 @@ vec4 sepia_filterColor(vec4 color) {
8254
8169
  return color;
8255
8170
  }
8256
8171
 
8257
- vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8172
+ vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8258
8173
  return sepia_filterColor(color);
8259
8174
  }
8260
8175
  `
@@ -8266,7 +8181,7 @@ vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8266
8181
  uniformTypes: {
8267
8182
  amount: "f32"
8268
8183
  },
8269
- uniformPropTypes: {
8184
+ propTypes: {
8270
8185
  amount: { value: 0.5, min: 0, max: 1 }
8271
8186
  },
8272
8187
  fs: fs8,
@@ -8288,7 +8203,7 @@ vec4 vibrance_filterColor(vec4 color) {
8288
8203
  return color;
8289
8204
  }
8290
8205
 
8291
- vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8206
+ vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8292
8207
  return vibrance_filterColor(color);
8293
8208
  }
8294
8209
  `
@@ -8297,7 +8212,10 @@ vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8297
8212
  props: {},
8298
8213
  uniforms: {},
8299
8214
  name: "vibrance",
8300
- uniformPropTypes: {
8215
+ uniformTypes: {
8216
+ amount: "f32"
8217
+ },
8218
+ propTypes: {
8301
8219
  amount: { value: 0, min: -1, max: 1 }
8302
8220
  },
8303
8221
  fs: fs9,
@@ -8312,15 +8230,11 @@ vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8312
8230
  float amount;
8313
8231
  } vignette;
8314
8232
 
8315
- vec4 vignette_filterColor(vec4 color, vec2 texCoord) {
8233
+ vec4 vignette_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8316
8234
  float dist = distance(texCoord, vec2(0.5, 0.5));
8317
8235
  float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
8318
8236
  return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
8319
8237
  }
8320
-
8321
- vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8322
- return vignette_filterColor(color, texCoord);
8323
- }
8324
8238
  `
8325
8239
  );
8326
8240
  var vignette = {
@@ -8331,7 +8245,11 @@ vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8331
8245
  radius: "f32",
8332
8246
  amount: "f32"
8333
8247
  },
8334
- uniformPropTypes: {
8248
+ defaultUniforms: {
8249
+ radius: 0.5,
8250
+ amount: 0.5
8251
+ },
8252
+ propTypes: {
8335
8253
  radius: { value: 0.5, min: 0, max: 1 },
8336
8254
  amount: { value: 0.5, min: 0, max: 1 }
8337
8255
  },
@@ -8399,7 +8317,7 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8399
8317
  end: "vec2<f32>",
8400
8318
  invert: "i32"
8401
8319
  },
8402
- uniformPropTypes: {
8320
+ propTypes: {
8403
8321
  blurRadius: { value: 15, min: 0, max: 50 },
8404
8322
  gradientRadius: { value: 200, min: 0, max: 400 },
8405
8323
  start: { value: [0, 0] },
@@ -8459,7 +8377,7 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8459
8377
  radius: "f32",
8460
8378
  delta: "vec2<f32>"
8461
8379
  },
8462
- uniformPropTypes: {
8380
+ propTypes: {
8463
8381
  radius: { value: 20, min: 0, softMax: 100 },
8464
8382
  delta: { value: [1, 0], private: true }
8465
8383
  },
@@ -8514,7 +8432,7 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8514
8432
  center: "vec2<f32>",
8515
8433
  strength: "f32"
8516
8434
  },
8517
- uniformPropTypes: {
8435
+ propTypes: {
8518
8436
  center: { value: [0.5, 0.5] },
8519
8437
  strength: { value: 0.3, min: 0, softMax: 1 }
8520
8438
  },
@@ -8542,7 +8460,7 @@ float pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {
8542
8460
  return (sin(point.x) * sin(point.y)) * 4.0;
8543
8461
  }
8544
8462
 
8545
- vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8463
+ vec4 colorHalftone_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8546
8464
  float scale = 3.1514 / colorHalftone.size;
8547
8465
  vec3 cmy = 1.0 - color.rgb;
8548
8466
  float k = min(cmy.x, min(cmy.y, cmy.z));
@@ -8571,7 +8489,7 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8571
8489
  angle: "f32",
8572
8490
  size: "f32"
8573
8491
  },
8574
- uniformPropTypes: {
8492
+ propTypes: {
8575
8493
  center: { value: [0.5, 0.5] },
8576
8494
  angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
8577
8495
  size: { value: 4, min: 1, softMin: 3, softMax: 20 }
@@ -8601,7 +8519,7 @@ float pattern(vec2 texSize, vec2 texCoord) {
8601
8519
  return (sin(point.x) * sin(point.y)) * 4.0;
8602
8520
  }
8603
8521
 
8604
- vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8522
+ vec4 dotScreen_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
8605
8523
  float average = (color.r + color.g + color.b) / 3.0;
8606
8524
  return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
8607
8525
  }
@@ -8616,7 +8534,7 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8616
8534
  angle: "f32",
8617
8535
  size: "f32"
8618
8536
  },
8619
- uniformPropTypes: {
8537
+ propTypes: {
8620
8538
  center: { value: [0.5, 0.5] },
8621
8539
  angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
8622
8540
  size: { value: 3, min: 1, softMin: 3, softMax: 20 }
@@ -8630,11 +8548,11 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8630
8548
  /* glsl */
8631
8549
  `uniform edgeWorkUniforms {
8632
8550
  float radius;
8633
- vec2 delta;
8551
+ int mode;
8634
8552
  } edgeWork;
8635
8553
 
8636
- vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
8637
- vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
8554
+ vec4 edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) {
8555
+ vec2 relativeDelta = edgeWork.radius * delta / texSize;
8638
8556
 
8639
8557
  vec2 color = vec2(0.0);
8640
8558
  vec2 total = vec2(0.0);
@@ -8658,8 +8576,8 @@ vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
8658
8576
  return vec4(color / total, 0.0, 1.0);
8659
8577
  }
8660
8578
 
8661
- vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
8662
- vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
8579
+ vec4 edgeWork_sampleColorXY(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) {
8580
+ vec2 relativeDelta = edgeWork.radius * delta / texSize;
8663
8581
 
8664
8582
  vec2 color = vec2(0.0);
8665
8583
  vec2 total = vec2(0.0);
@@ -8682,6 +8600,16 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
8682
8600
  float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
8683
8601
  return vec4(c, c, c, 1.0);
8684
8602
  }
8603
+
8604
+ vec4 edgeWork_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8605
+ switch (edgeWork.mode) {
8606
+ case 0:
8607
+ return edgeWork_sampleColorRGB(source, texSize, texCoord, vec2(1., 0.));
8608
+ case 1:
8609
+ default:
8610
+ return edgeWork_sampleColorXY(source, texSize, texCoord, vec2(0., 1.));
8611
+ }
8612
+ }
8685
8613
  `
8686
8614
  );
8687
8615
  var edgeWork = {
@@ -8690,20 +8618,22 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
8690
8618
  name: "edgeWork",
8691
8619
  dependencies: [random],
8692
8620
  fs: fs16,
8693
- uniformPropTypes: {
8621
+ uniformTypes: {
8622
+ radius: "f32",
8623
+ mode: "i32"
8624
+ },
8625
+ propTypes: {
8694
8626
  radius: { value: 2, min: 1, softMax: 50 },
8695
- delta: { value: [1, 0], private: true }
8627
+ mode: { value: 0, private: true }
8696
8628
  },
8697
8629
  passes: [
8698
8630
  {
8699
- // @ts-expect-error
8700
- sampler: "edgeWork_sampleColor1",
8701
- uniformPropTypes: { delta: [1, 0] }
8631
+ sampler: true,
8632
+ uniforms: { mode: 0 }
8702
8633
  },
8703
8634
  {
8704
- // @ts-expect-error
8705
- sampler: "edgeWork_sampleColor2",
8706
- uniformPropTypes: { delta: [0, 1] }
8635
+ sampler: true,
8636
+ uniforms: { mode: 1 }
8707
8637
  }
8708
8638
  ]
8709
8639
  };
@@ -8763,7 +8693,7 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
8763
8693
  center: "vec2<f32>",
8764
8694
  scale: "f32"
8765
8695
  },
8766
- uniformPropTypes: {
8696
+ propTypes: {
8767
8697
  center: { value: [0.5, 0.5], hint: "screenspace" },
8768
8698
  scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
8769
8699
  },
@@ -8811,7 +8741,7 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8811
8741
  uniformTypes: {
8812
8742
  strength: "f32"
8813
8743
  },
8814
- uniformPropTypes: {
8744
+ propTypes: {
8815
8745
  strength: { value: 0.25, min: 0, softMax: 1 }
8816
8746
  },
8817
8747
  passes: [{ sampler: true }]
@@ -8851,7 +8781,7 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8851
8781
  borderWidthPixels: "f32",
8852
8782
  borderColor: "vec4<f32>"
8853
8783
  },
8854
- uniformPropTypes: {
8784
+ propTypes: {
8855
8785
  // range 0 to 1
8856
8786
  screenXY: { value: [0, 0] },
8857
8787
  radiusPixels: 200,
@@ -8927,7 +8857,7 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8927
8857
  radius: "f32",
8928
8858
  strength: "f32"
8929
8859
  },
8930
- uniformPropTypes: {
8860
+ propTypes: {
8931
8861
  center: { value: [0.5, 0.5] },
8932
8862
  radius: { value: 200, min: 1, softMax: 600 },
8933
8863
  strength: { value: 0.5, min: -1, max: 1 }
@@ -8980,7 +8910,7 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8980
8910
  radius: "f32",
8981
8911
  angle: "f32"
8982
8912
  },
8983
- uniformPropTypes: {
8913
+ propTypes: {
8984
8914
  center: { value: [0.5, 0.5] },
8985
8915
  radius: { value: 200, min: 1, softMax: 600 },
8986
8916
  angle: { value: 3, softMin: -25, softMax: 25 }
@@ -8989,7 +8919,9 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8989
8919
  };
8990
8920
 
8991
8921
  // src/passes/postprocessing/fxaa/fxaa.ts
8992
- var fs23 = `
8922
+ var fs23 = (
8923
+ /* glsl */
8924
+ `
8993
8925
  #define FXAA_QUALITY_PRESET 29
8994
8926
 
8995
8927
  #if (FXAA_QUALITY_PRESET == 10)
@@ -9569,10 +9501,11 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
9569
9501
  fxaa_QualityEdgeThresholdMin
9570
9502
  );
9571
9503
  }
9572
- `;
9504
+ `
9505
+ );
9573
9506
  var fxaa = {
9574
9507
  name: "fxaa",
9575
- uniformPropTypes: {},
9508
+ propTypes: {},
9576
9509
  fs: fs23,
9577
9510
  passes: [{ sampler: true }],
9578
9511
  getUniforms: (props) => props