@luma.gl/shadertools 9.0.16 → 9.0.19

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 (74) hide show
  1. package/dist/dist.dev.js +90 -97
  2. package/dist/dist.min.js +81 -78
  3. package/dist/index.cjs +34 -46
  4. package/dist/index.cjs.map +2 -2
  5. package/dist/lib/shader-module/shader-module.d.ts +22 -13
  6. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  7. package/dist/lib/shader-module/shader-pass.d.ts +4 -2
  8. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  9. package/dist/lib/utils/uniform-types.d.ts +49 -0
  10. package/dist/lib/utils/uniform-types.d.ts.map +1 -0
  11. package/dist/lib/utils/uniform-types.js +1 -0
  12. package/dist/modules/engine/picking/picking.d.ts +5 -5
  13. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  14. package/dist/modules/engine/picking/picking.js +2 -2
  15. package/dist/modules/engine/project/project.d.ts +9 -8
  16. package/dist/modules/engine/project/project.d.ts.map +1 -1
  17. package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
  18. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
  19. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +15 -13
  20. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  21. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +3 -3
  22. package/dist/modules/lighting/lights/lighting-uniforms.d.ts +15 -14
  23. package/dist/modules/lighting/lights/lighting-uniforms.d.ts.map +1 -1
  24. package/dist/modules/lighting/lights/lighting-uniforms.js +8 -5
  25. package/dist/modules/lighting/no-material/dirlight.d.ts +2 -2
  26. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  27. package/dist/modules/lighting/no-material/dirlight.js +1 -1
  28. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +14 -13
  29. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  30. package/dist/modules/lighting/pbr-material/pbr-material.js +0 -11
  31. package/dist/modules/lighting/phong-material/phong-material.js +1 -1
  32. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  33. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +2 -1
  34. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +2 -2
  35. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  36. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +1 -1
  37. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  38. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
  39. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  40. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
  41. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  42. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
  43. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  44. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
  45. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  46. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -2
  47. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  48. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
  49. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  50. package/dist/modules-webgl1/project/project.d.ts +6 -4
  51. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/src/lib/shader-module/shader-module.ts +24 -12
  54. package/src/lib/shader-module/shader-pass.ts +7 -4
  55. package/src/lib/utils/uniform-types.ts +91 -0
  56. package/src/modules/engine/picking/picking.ts +9 -9
  57. package/src/modules/engine/project/project.ts +10 -9
  58. package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
  59. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +57 -52
  60. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +4 -3
  61. package/src/modules/lighting/lights/lighting-uniforms.ts +30 -22
  62. package/src/modules/lighting/no-material/dirlight.ts +3 -3
  63. package/src/modules/lighting/pbr-material/pbr-material.ts +14 -24
  64. package/src/modules/lighting/phong-material/phong-material.ts +1 -1
  65. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +16 -14
  66. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +2 -2
  67. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +1 -1
  68. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +1 -1
  69. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +1 -1
  70. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +1 -1
  71. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +1 -1
  72. package/src/modules/postprocessing/image-fun-filters/magnify.ts +2 -2
  73. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +1 -1
  74. package/src/modules-webgl1/project/project.ts +8 -7
package/dist/dist.dev.js CHANGED
@@ -4909,7 +4909,7 @@ float tan_fp32(float a) {
4909
4909
  };
4910
4910
 
4911
4911
  // src/modules/engine/picking/picking.ts
4912
- var DEFAULT_HIGHLIGHT_COLOR = new Float32Array([0, 1, 1, 1]);
4912
+ var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
4913
4913
  var vs = glsl`\
4914
4914
  uniform pickingUniforms {
4915
4915
  float isActive;
@@ -5058,7 +5058,7 @@ vec4 picking_filterColor(vec4 color) {
5058
5058
  isAttribute: false,
5059
5059
  isHighlightActive: false,
5060
5060
  useFloatColors: true,
5061
- highlightedObjectColor: new Float32Array([0, 0, 0]),
5061
+ highlightedObjectColor: [0, 0, 0],
5062
5062
  highlightColor: DEFAULT_HIGHLIGHT_COLOR
5063
5063
  },
5064
5064
  getUniforms
@@ -5112,15 +5112,16 @@ struct DirectionalLight {
5112
5112
 
5113
5113
  uniform lightingUniforms {
5114
5114
  int enabled;
5115
- int pointLightCount;
5115
+ int lightType;
5116
+
5116
5117
  int directionalLightCount;
5118
+ int pointLightCount;
5117
5119
 
5118
5120
  vec3 ambientColor;
5119
5121
 
5120
- int lightType;
5121
5122
  vec3 lightColor;
5122
- vec3 lightDirection;
5123
5123
  vec3 lightPosition;
5124
+ vec3 lightDirection;
5124
5125
  vec3 lightAttenuation;
5125
5126
 
5126
5127
  // AmbientLight ambientLight;
@@ -5160,11 +5161,13 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
5160
5161
  },
5161
5162
  uniformTypes: {
5162
5163
  enabled: "i32",
5163
- ambientLightColor: "vec3<f32>",
5164
- numberOfLights: "i32",
5165
- // , array: MAX_LIGHTS,
5166
5164
  lightType: "i32",
5167
5165
  // , array: MAX_LIGHTS,
5166
+ directionalLightCount: "i32",
5167
+ // , array: MAX_LIGHTS,
5168
+ pointLightCount: "i32",
5169
+ // , array: MAX_LIGHTS,
5170
+ ambientLightColor: "vec3<f32>",
5168
5171
  lightColor: "vec3<f32>",
5169
5172
  // , array: MAX_LIGHTS,
5170
5173
  lightPosition: "vec3<f32>",
@@ -5177,9 +5180,10 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
5177
5180
  },
5178
5181
  defaultUniforms: {
5179
5182
  enabled: 1,
5180
- ambientLightColor: [0.1, 0.1, 0.1],
5181
- numberOfLights: 0,
5182
5183
  lightType: 0 /* POINT */,
5184
+ directionalLightCount: 0,
5185
+ pointLightCount: 0,
5186
+ ambientLightColor: [0.1, 0.1, 0.1],
5183
5187
  lightColor: [1, 1, 1],
5184
5188
  lightPosition: [1, 1, 2],
5185
5189
  // TODO - could combine direction and attenuation
@@ -5238,7 +5242,8 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
5238
5242
  lightSourceUniforms.lightDirection = directionalLight.direction;
5239
5243
  currentLight++;
5240
5244
  }
5241
- lightSourceUniforms.numberOfLights = currentLight;
5245
+ lightSourceUniforms.directionalLightCount = directionalLights.length;
5246
+ lightSourceUniforms.pointLightCount = pointLights.length;
5242
5247
  return lightSourceUniforms;
5243
5248
  }
5244
5249
  function extractLightTypes(lights2) {
@@ -5300,7 +5305,7 @@ vec4 dirlight_filterColor(vec4 color) {
5300
5305
  lightDirection: "vec3<f32>"
5301
5306
  },
5302
5307
  defaultUniforms: {
5303
- lightDirection: new Float32Array([1, 1, 2])
5308
+ lightDirection: [1, 1, 2]
5304
5309
  },
5305
5310
  getUniforms: getUniforms3
5306
5311
  };
@@ -5314,15 +5319,7 @@ vec4 dirlight_filterColor(vec4 color) {
5314
5319
 
5315
5320
  // src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
5316
5321
  var GOURAUD_VS = glsl`\
5317
- uniform materialUniforms {
5318
- uniform float ambient;
5319
- uniform float diffuse;
5320
- uniform float shininess;
5321
- uniform vec3 specularColor;
5322
- } material;
5323
- `;
5324
- var GOURAUD_FS = glsl`\
5325
- uniform materialUniforms {
5322
+ uniform gouraudMaterialUniforms {
5326
5323
  uniform float ambient;
5327
5324
  uniform float diffuse;
5328
5325
  uniform float shininess;
@@ -5344,39 +5341,41 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
5344
5341
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
5345
5342
  vec3 lightColor = surfaceColor;
5346
5343
 
5347
- if (lighting.enabled) {
5348
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
5349
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
5344
+ if (lighting.enabled == 0) {
5345
+ return lightColor;
5346
+ }
5350
5347
 
5351
- if (lighting.lightType == 0) {
5352
- PointLight pointLight = lighting_getPointLight(0);
5353
- vec3 light_position_worldspace = pointLight.position;
5354
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5355
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5356
- } else if (lighting.lightType == 1) {
5357
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
5358
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5359
- }
5360
- /*
5361
- for (int i = 0; i < MAX_LIGHTS; i++) {
5362
- if (i >= lighting.pointLightCount) {
5363
- break;
5364
- }
5365
- PointLight pointLight = lighting.pointLight[i];
5366
- vec3 light_position_worldspace = pointLight.position;
5367
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5368
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5348
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
5349
+ lightColor = material.ambient * surfaceColor * lighting.ambientColor;
5350
+
5351
+ if (lighting.lightType == 0) {
5352
+ PointLight pointLight = lighting_getPointLight(0);
5353
+ vec3 light_position_worldspace = pointLight.position;
5354
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5355
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5356
+ } else if (lighting.lightType == 1) {
5357
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
5358
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5359
+ }
5360
+ /*
5361
+ for (int i = 0; i < MAX_LIGHTS; i++) {
5362
+ if (i >= lighting.pointLightCount) {
5363
+ break;
5369
5364
  }
5365
+ PointLight pointLight = lighting.pointLight[i];
5366
+ vec3 light_position_worldspace = pointLight.position;
5367
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5368
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5369
+ }
5370
5370
 
5371
- for (int i = 0; i < MAX_LIGHTS; i++) {
5372
- if (i >= lighting.directionalLightCount) {
5373
- break;
5374
- }
5375
- DirectionalLight directionalLight = lighting.directionalLight[i];
5376
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5371
+ for (int i = 0; i < MAX_LIGHTS; i++) {
5372
+ if (i >= lighting.directionalLightCount) {
5373
+ break;
5377
5374
  }
5378
- */
5375
+ DirectionalLight directionalLight = lighting.directionalLight[i];
5376
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5379
5377
  }
5378
+ */
5380
5379
  return lightColor;
5381
5380
  }
5382
5381
 
@@ -5384,30 +5383,41 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
5384
5383
  vec3 lightColor = vec3(0, 0, 0);
5385
5384
  vec3 surfaceColor = vec3(0, 0, 0);
5386
5385
 
5387
- if (lighting.enabled) {
5388
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
5386
+ if (lighting.enabled == 0) {
5387
+ return lightColor;
5388
+ }
5389
5389
 
5390
- switch (lighting.lightType) {
5391
- case 0:
5392
- PointLight pointLight = lighting_getPointLight(0);
5393
- vec3 light_position_worldspace = pointLight.position;
5394
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5395
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5396
- break;
5390
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
5397
5391
 
5398
- case 1:
5399
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
5400
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5401
- break;
5402
- }
5392
+ switch (lighting.lightType) {
5393
+ case 0:
5394
+ PointLight pointLight = lighting_getPointLight(0);
5395
+ vec3 light_position_worldspace = pointLight.position;
5396
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5397
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5398
+ break;
5399
+
5400
+ case 1:
5401
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
5402
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5403
+ break;
5403
5404
  }
5405
+
5404
5406
  return lightColor;
5405
5407
  }
5408
+ `;
5409
+ var GOURAUD_FS = glsl`\
5410
+ uniform gouraudMaterialUniforms {
5411
+ uniform float ambient;
5412
+ uniform float diffuse;
5413
+ uniform float shininess;
5414
+ uniform vec3 specularColor;
5415
+ } material;
5406
5416
  `;
5407
5417
 
5408
5418
  // src/modules/lighting/gouraud-material/gouraud-material.ts
5409
5419
  var gouraudMaterial = {
5410
- name: "gouraud-lighting",
5420
+ name: "gouraudMaterial",
5411
5421
  // Note these are switched between phong and gouraud
5412
5422
  vs: GOURAUD_VS,
5413
5423
  fs: GOURAUD_FS,
@@ -5508,21 +5518,23 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
5508
5518
  vec3 surfaceColor = vec3(0, 0, 0);
5509
5519
 
5510
5520
  if (lighting.enabled == 0) {
5511
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
5521
+ return lightColor;
5522
+ }
5512
5523
 
5513
- switch (lighting.lightType) {
5514
- case 0:
5515
- PointLight pointLight = lighting_getPointLight(0);
5516
- vec3 light_position_worldspace = pointLight.position;
5517
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5518
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5519
- break;
5524
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
5520
5525
 
5521
- case 1:
5522
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
5523
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5524
- break;
5525
- }
5526
+ switch (lighting.lightType) {
5527
+ case 0:
5528
+ PointLight pointLight = lighting_getPointLight(0);
5529
+ vec3 light_position_worldspace = pointLight.position;
5530
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
5531
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
5532
+ break;
5533
+
5534
+ case 1:
5535
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
5536
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
5537
+ break;
5526
5538
  }
5527
5539
  return lightColor;
5528
5540
  }
@@ -5530,7 +5542,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
5530
5542
 
5531
5543
  // src/modules/lighting/phong-material/phong-material.ts
5532
5544
  var phongMaterial = {
5533
- name: "phong-lighting",
5545
+ name: "phongMaterial",
5534
5546
  // Note these are switched between phong and gouraud
5535
5547
  vs: PHONG_VS,
5536
5548
  fs: PHONG_FS,
@@ -6054,25 +6066,6 @@ vec4 pbr_filterColor(vec4 colorUnused)
6054
6066
  scaleDiffBaseMR: "vec4<f32>",
6055
6067
  scaleFGDSpec: "vec4<f32>"
6056
6068
  },
6057
- bindings: {
6058
- baseColorSampler: { type: "texture", location: 8 },
6059
- // #ifdef HAS_BASECOLORMAP
6060
- normalSampler: { type: "texture", location: 9 },
6061
- // #ifdef HAS_NORMALMAP
6062
- emissiveSampler: { type: "texture", location: 10 },
6063
- // #ifdef HAS_EMISSIVEMAP
6064
- metallicRoughnessSampler: { type: "texture", location: 11 },
6065
- // #ifdef HAS_METALROUGHNESSMAP
6066
- occlusionSampler: { type: "texture", location: 12 },
6067
- // #ifdef HAS_OCCLUSIONMAP
6068
- // IBL Samplers
6069
- diffuseEnvSampler: { type: "texture", location: 13 },
6070
- // #ifdef USE_IBL (samplerCube)
6071
- specularEnvSampler: { type: "texture", location: 14 },
6072
- // #ifdef USE_IBL (samplerCube)
6073
- brdfLUT: { type: "texture", location: 15 }
6074
- // #ifdef USE_IBL
6075
- },
6076
6069
  dependencies: [lighting]
6077
6070
  };
6078
6071