@luma.gl/shaders 10.0.0-alpha.11 → 10.0.0-alpha.13

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 (35) hide show
  1. package/LICENSE +4 -4
  2. package/THIRD-PARTY-NOTICES.md +31 -0
  3. package/dist/dist.dev.js +147 -2
  4. package/dist/dist.min.js +235 -131
  5. package/dist/glsl.cjs.map +1 -1
  6. package/dist/index.cjs +6 -0
  7. package/dist/index.cjs.map +2 -2
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/modules/lighting/lightmap/lightmap-filter.cjs +93 -0
  13. package/dist/modules/lighting/lightmap/lightmap-filter.d.ts +35 -0
  14. package/dist/modules/lighting/lightmap/lightmap-filter.d.ts.map +1 -0
  15. package/dist/modules/lighting/lightmap/lightmap-filter.js +71 -0
  16. package/dist/modules/lighting/lightmap/lightmap-filter.js.map +1 -0
  17. package/dist/modules/lighting/lightmap/lightmap.cjs +89 -0
  18. package/dist/modules/lighting/lightmap/lightmap.d.ts +405 -0
  19. package/dist/modules/lighting/lightmap/lightmap.d.ts.map +1 -0
  20. package/dist/modules/lighting/lightmap/lightmap.js +67 -0
  21. package/dist/modules/lighting/lightmap/lightmap.js.map +1 -0
  22. package/dist/types/shader-type-decoder.cjs +12 -2
  23. package/dist/types/shader-type-decoder.d.ts +7 -7
  24. package/dist/types/shader-type-decoder.d.ts.map +1 -1
  25. package/dist/types/shader-type-decoder.js +13 -2
  26. package/dist/types/shader-type-decoder.js.map +1 -1
  27. package/dist/types.cjs.map +1 -1
  28. package/dist/wgsl.cjs.map +1 -1
  29. package/licenses/pbr.txt +58 -0
  30. package/licenses/three.txt +21 -0
  31. package/package.json +7 -4
  32. package/src/index.ts +4 -0
  33. package/src/modules/lighting/lightmap/lightmap-filter.ts +73 -0
  34. package/src/modules/lighting/lightmap/lightmap.ts +76 -0
  35. package/src/types/shader-type-decoder.ts +22 -9
package/LICENSE CHANGED
@@ -8,16 +8,16 @@ Copyright (c) 2015 Uber Technologies, Inc.
8
8
  This software includes parts of PhiloGL (https://github.com/philogb/philogl)
9
9
  under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
10
10
 
11
- This software includes adaptations of some postprocessing code from
12
- THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
13
- THREE.js parts Copyright © 2010-2018 three.js authors.
11
+ This software includes adaptations of some postprocessing code from
12
+ THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
13
+ THREE.js parts Copyright © 2010-2018 three.js authors.
14
14
 
15
15
  This software includes adaptations of Gaussian-splat rendering and
16
16
  level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark)
17
17
  under MIT license.
18
18
  Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC.
19
19
 
20
- Additional attribution given in specific source files.
20
+ Additional attribution given in specific source files.
21
21
 
22
22
  Permission is hereby granted, free of charge, to any person obtaining a copy
23
23
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,31 @@
1
+ # Third-party notices: @luma.gl/shaders
2
+
3
+ Shader composition by vis.gl contributors; historical Khronos PBR shaders, three.js half-float conversion, and Uber geospatial shader contributions.
4
+
5
+ The [repository license](./LICENSE) retains historical project notices.
6
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
7
+ Separately installed dependencies retain their own licenses; this is not a transitive dependency inventory.
8
+
9
+ ## Khronos glTF-WebGL-PBR
10
+
11
+ Copyright (c) 2016-2017 Mohamad Moneimne and Contributors.
12
+
13
+ Source: [Khronos glTF-WebGL-PBR](https://github.com/KhronosGroup/glTF-Sample-Viewer/tree/88eda8c5358efe03128b72b6c5f5f6e5b6d023e1).
14
+
15
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
16
+
17
+ Adaptation: src/modules/lighting/pbr-material/pbr-material-glsl.ts and pbr-material-wgsl.ts adapt uniforms, lighting, extensions, and WGSL translation. The pinned historical MIT reference does not assert an exact original import revision. Later Apache terms do not replace this MIT version. The full upstream license includes its own third-party appendix; this does not mean the viewer GUI is bundled here.
18
+
19
+ Full terms: [pbr](./licenses/pbr.txt).
20
+
21
+ ## three.js
22
+
23
+ three.js authors.
24
+
25
+ Source: [three.js](https://github.com/mrdoob/three.js).
26
+
27
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
28
+
29
+ Adaptation: src/modules/math/fp16/fp16-utils.ts adapts half-float conversion to TypeScript and math.gl clamp.
30
+
31
+ Full terms: [three](./licenses/three.txt).
package/dist/dist.dev.js CHANGED
@@ -86,6 +86,8 @@ var __exports__ = (() => {
86
86
  integrateSurfaceWeather: () => integrateSurfaceWeather,
87
87
  lambertMaterial: () => lambertMaterial,
88
88
  lighting: () => lighting,
89
+ lightmapBake: () => lightmapBake,
90
+ lightmapFilter: () => lightmapFilter,
89
91
  mergeShaderPluginModules: () => mergeShaderPluginModules,
90
92
  normalizeByteColor3: () => normalizeByteColor3,
91
93
  normalizeByteColor4: () => normalizeByteColor4,
@@ -1197,8 +1199,13 @@ ${fragmentString}${source7.slice(insertionIndex)}`;
1197
1199
  }
1198
1200
  return decoded;
1199
1201
  }
1202
+ var attributeShaderTypeInfoCache = /* @__PURE__ */ new Map();
1200
1203
  function getAttributeShaderTypeInfo(attributeType) {
1201
1204
  const resolvedAttributeType = resolveAttributeShaderTypeAlias(attributeType);
1205
+ const cached = attributeShaderTypeInfoCache.get(resolvedAttributeType);
1206
+ if (cached) {
1207
+ return cached;
1208
+ }
1202
1209
  const decoded = TYPE_INFO[resolvedAttributeType];
1203
1210
  if (!decoded) {
1204
1211
  throw new Error(`Unsupported attribute shader type: ${attributeType}`);
@@ -1207,13 +1214,15 @@ ${fragmentString}${source7.slice(insertionIndex)}`;
1207
1214
  const integer = primitiveType === "i32" || primitiveType === "u32";
1208
1215
  const signed = primitiveType !== "u32";
1209
1216
  const byteLength = PRIMITIVE_TYPE_SIZES[primitiveType] * components;
1210
- return {
1217
+ const result = Object.freeze({
1211
1218
  primitiveType,
1212
1219
  components,
1213
1220
  byteLength,
1214
1221
  integer,
1215
1222
  signed
1216
- };
1223
+ });
1224
+ attributeShaderTypeInfoCache.set(resolvedAttributeType, result);
1225
+ return result;
1217
1226
  }
1218
1227
  var ShaderTypeDecoder = class {
1219
1228
  getVariableShaderTypeInfo(format) {
@@ -1322,6 +1331,9 @@ ${fragmentString}${source7.slice(insertionIndex)}`;
1322
1331
  "mat4x3<u32>": { type: "u32", components: 12 },
1323
1332
  "mat4x4<u32>": { type: "u32", components: 16 }
1324
1333
  };
1334
+ for (const info of Object.values(UNIFORM_FORMATS)) {
1335
+ Object.freeze(info);
1336
+ }
1325
1337
  var WGSL_ATTRIBUTE_TYPE_ALIAS_MAP = {
1326
1338
  vec2i: "vec2<i32>",
1327
1339
  vec3i: "vec3<i32>",
@@ -21592,6 +21604,139 @@ void pbrAmbientOcclusion_setFactor(vec2 pixelPosition) {
21592
21604
  }`
21593
21605
  )
21594
21606
  };
21607
+
21608
+ // src/modules/lighting/lightmap/lightmap.ts
21609
+ var lightmapBake = {
21610
+ name: "lightmapBake",
21611
+ dependencies: [pbrMaterial],
21612
+ bindingLayout: [{ name: "lightmapBake", group: 0 }],
21613
+ uniformTypes: { uvSet: "i32", uvTransform: "mat3x3<f32>", chartId: "f32" },
21614
+ defaultUniforms: { uvSet: 1, uvTransform: [1, 0, 0, 0, 1, 0, 0, 0, 1], chartId: 1 },
21615
+ getUniforms: (props) => props,
21616
+ source: `
21617
+ struct LightmapBakeUniforms {uvSet: i32, uvTransform: mat3x3f, chartId: f32};
21618
+ @group(0) @binding(auto) var<uniform> lightmapBake: LightmapBakeUniforms;
21619
+
21620
+ fn lightmap_getIrradiance(position: vec3f, normal: vec3f, directionalVisibility: f32, pointVisibility: vec4f, spotVisibility: vec4f) -> vec3f {
21621
+ if (lighting.enabled == 0) {return vec3f(0.0);}
21622
+ var irradiance = lighting.ambientColor;
21623
+ for (var index = 0; index < lighting.directionalLightCount; index++) {
21624
+ let light = lighting_getDirectionalLight(index);
21625
+ irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * select(1.0, directionalVisibility, index == 0);
21626
+ }
21627
+ for (var index = 0; index < lighting.pointLightCount; index++) {
21628
+ let light = lighting_getPointLight(index);
21629
+ let offset = light.position - position;
21630
+ let visibility = select(1.0, pointVisibility[min(index, 3)], index < 4);
21631
+ irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * visibility / max(getPointLightAttenuation(light, length(offset)), 0.0001);
21632
+ }
21633
+ for (var index = 0; index < lighting.spotLightCount; index++) {
21634
+ let light = lighting_getSpotLight(index);
21635
+ irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * select(1.0, spotVisibility[min(index, 3)], index < 4) / max(getSpotLightAttenuation(light, position), 0.0001);
21636
+ }
21637
+ return irradiance;
21638
+ }
21639
+ `,
21640
+ vs: `layout(std140) uniform lightmapBakeUniforms {
21641
+ int uvSet;
21642
+ mat3 uvTransform;
21643
+ float chartId;
21644
+ } lightmapBake;`,
21645
+ fs: `layout(std140) uniform lightmapBakeUniforms {
21646
+ int uvSet;
21647
+ mat3 uvTransform;
21648
+ float chartId;
21649
+ } lightmapBake;
21650
+
21651
+ vec3 lightmap_getIrradiance(vec3 position, vec3 normal, float directionalVisibility, vec4 pointVisibility, vec4 spotVisibility) {
21652
+ if (lighting.enabled == 0) {return vec3(0.0);}
21653
+ vec3 irradiance = lighting.ambientColor;
21654
+ for (int index = 0; index < lighting.directionalLightCount; index++) {
21655
+ DirectionalLight light = lighting_getDirectionalLight(index);
21656
+ irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * (index == 0 ? directionalVisibility : 1.0);
21657
+ }
21658
+ for (int index = 0; index < lighting.pointLightCount; index++) {
21659
+ PointLight light = lighting_getPointLight(index);
21660
+ vec3 offset = light.position - position;
21661
+ irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * (index < 4 ? pointVisibility[index] : 1.0) / max(getPointLightAttenuation(light, length(offset)), 0.0001);
21662
+ }
21663
+ for (int index = 0; index < lighting.spotLightCount; index++) {
21664
+ SpotLight light = lighting_getSpotLight(index);
21665
+ irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * (index < 4 ? spotVisibility[index] : 1.0) / max(getSpotLightAttenuation(light, position), 0.0001);
21666
+ }
21667
+ return irradiance;
21668
+ }
21669
+ `
21670
+ };
21671
+
21672
+ // src/modules/lighting/lightmap/lightmap-filter.ts
21673
+ var lightmapFilter = {
21674
+ name: "lightmapFilter",
21675
+ bindingLayout: [
21676
+ { name: "lightmapFilter", group: 0 },
21677
+ { name: "currentTexture", group: 0 },
21678
+ { name: "previousTexture", group: 0 },
21679
+ { name: "chartTexture", group: 0 }
21680
+ ],
21681
+ uniformTypes: { weight: "f32", mode: "i32" },
21682
+ defaultUniforms: { weight: 1, mode: 0 },
21683
+ getUniforms: (props) => props,
21684
+ source: `
21685
+ struct LightmapFilterUniforms {weight: f32, mode: i32};
21686
+ @group(0) @binding(auto) var<uniform> lightmapFilter: LightmapFilterUniforms;
21687
+ @group(0) @binding(auto) var currentTexture: texture_2d<f32>;
21688
+ @group(0) @binding(auto) var previousTexture: texture_2d<f32>;
21689
+ @group(0) @binding(auto) var chartTexture: texture_2d<f32>;
21690
+ fn lightmapFilter_getColor(coordinates: vec2i) -> vec4f {
21691
+ let current = textureLoad(currentTexture, coordinates, 0);
21692
+ if (lightmapFilter.mode == 0) {
21693
+ let previous = textureLoad(previousTexture, coordinates, 0);
21694
+ return vec4f(mix(previous.rgb, current.rgb, lightmapFilter.weight), current.a);
21695
+ }
21696
+ if (lightmapFilter.mode == 2 || current.a > 0.0) {return current;}
21697
+ let chart = textureLoad(chartTexture, coordinates, 0).r;
21698
+ if (chart <= 0.0) {return current;}
21699
+ let size = vec2i(textureDimensions(currentTexture));
21700
+ for (var y = -1; y <= 1; y++) {
21701
+ for (var x = -1; x <= 1; x++) {
21702
+ let neighbor = coordinates + vec2i(x, y);
21703
+ if (all(neighbor >= vec2i(0)) && all(neighbor < size)) {
21704
+ let candidate = textureLoad(currentTexture, neighbor, 0);
21705
+ if (candidate.a == chart) {return candidate;}
21706
+ }
21707
+ }
21708
+ }
21709
+ return current;
21710
+ }`,
21711
+ fs: `
21712
+ layout(std140) uniform lightmapFilterUniforms {
21713
+ float weight;
21714
+ int mode;
21715
+ } lightmapFilter;
21716
+ uniform sampler2D currentTexture;
21717
+ uniform sampler2D previousTexture;
21718
+ uniform sampler2D chartTexture;
21719
+ vec4 lightmapFilter_getColor(ivec2 coordinates) {
21720
+ vec4 current = texelFetch(currentTexture, coordinates, 0);
21721
+ if (lightmapFilter.mode == 0) {
21722
+ return vec4(mix(texelFetch(previousTexture, coordinates, 0).rgb, current.rgb, lightmapFilter.weight), current.a);
21723
+ }
21724
+ if (lightmapFilter.mode == 2 || current.a > 0.0) {return current;}
21725
+ float chart = texelFetch(chartTexture, coordinates, 0).r;
21726
+ ivec2 size = textureSize(currentTexture, 0);
21727
+ if (chart <= 0.0) return current;
21728
+ for (int y = -1; y <= 1; y++) {
21729
+ for (int x = -1; x <= 1; x++) {
21730
+ ivec2 neighbor = coordinates + ivec2(x,y);
21731
+ if (all(greaterThanEqual(neighbor, ivec2(0))) && all(lessThan(neighbor,size))) {
21732
+ vec4 candidate = texelFetch(currentTexture, neighbor, 0);
21733
+ if (candidate.a == chart) {return candidate;}
21734
+ }
21735
+ }
21736
+ }
21737
+ return current;
21738
+ }`
21739
+ };
21595
21740
  return __toCommonJS(bundle_exports);
21596
21741
  })();
21597
21742
  return __exports__;