@luma.gl/shadertools 9.2.6 → 9.3.0-alpha.10

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 (174) hide show
  1. package/dist/dist.dev.js +4798 -6439
  2. package/dist/dist.min.js +2047 -311
  3. package/dist/index.cjs +3033 -507
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +12 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/preprocessor/preprocessor.d.ts.map +1 -1
  10. package/dist/lib/preprocessor/preprocessor.js +35 -8
  11. package/dist/lib/preprocessor/preprocessor.js.map +1 -1
  12. package/dist/lib/shader-assembler.d.ts +10 -0
  13. package/dist/lib/shader-assembler.d.ts.map +1 -1
  14. package/dist/lib/shader-assembler.js +20 -3
  15. package/dist/lib/shader-assembler.js.map +1 -1
  16. package/dist/lib/shader-assembly/assemble-shaders.d.ts +23 -2
  17. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  18. package/dist/lib/shader-assembly/assemble-shaders.js +214 -11
  19. package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
  20. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts +37 -0
  21. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts.map +1 -0
  22. package/dist/lib/shader-assembly/wgsl-binding-debug.js +140 -0
  23. package/dist/lib/shader-assembly/wgsl-binding-debug.js.map +1 -0
  24. package/dist/lib/shader-generator/glsl/generate-glsl.js +7 -4
  25. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -1
  26. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -1
  27. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +3 -0
  28. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -1
  29. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts +91 -0
  30. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts.map +1 -0
  31. package/dist/lib/shader-module/shader-module-uniform-layout.js +209 -0
  32. package/dist/lib/shader-module/shader-module-uniform-layout.js.map +1 -0
  33. package/dist/lib/shader-module/shader-module.d.ts +12 -6
  34. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  35. package/dist/lib/shader-module/shader-module.js.map +1 -1
  36. package/dist/lib/utils/assert.d.ts.map +1 -1
  37. package/dist/lib/utils/assert.js +3 -1
  38. package/dist/lib/utils/assert.js.map +1 -1
  39. package/dist/lib/utils/uniform-types.d.ts +11 -7
  40. package/dist/lib/utils/uniform-types.d.ts.map +1 -1
  41. package/dist/modules/engine/picking/picking.d.ts +5 -2
  42. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  43. package/dist/modules/engine/picking/picking.js +5 -2
  44. package/dist/modules/engine/picking/picking.js.map +1 -1
  45. package/dist/modules/engine/project/project.d.ts +1 -1
  46. package/dist/modules/engine/project/project.js +1 -1
  47. package/dist/modules/engine/skin/skin.d.ts +30 -0
  48. package/dist/modules/engine/skin/skin.d.ts.map +1 -0
  49. package/dist/modules/engine/skin/skin.js +86 -0
  50. package/dist/modules/engine/skin/skin.js.map +1 -0
  51. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -0
  52. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  53. package/dist/modules/lighting/gouraud-material/gouraud-material.js +3 -0
  54. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  55. package/dist/modules/lighting/ibl/ibl.d.ts +26 -0
  56. package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
  57. package/dist/modules/lighting/ibl/ibl.js +33 -0
  58. package/dist/modules/lighting/ibl/ibl.js.map +1 -0
  59. package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
  60. package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
  61. package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
  62. package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
  63. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
  64. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
  65. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
  66. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
  67. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
  68. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
  69. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
  70. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
  71. package/dist/modules/lighting/lights/lighting-glsl.d.ts +1 -1
  72. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -1
  73. package/dist/modules/lighting/lights/lighting-glsl.js +44 -38
  74. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -1
  75. package/dist/modules/lighting/lights/lighting-wgsl.d.ts +1 -1
  76. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -1
  77. package/dist/modules/lighting/lights/lighting-wgsl.js +46 -18
  78. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -1
  79. package/dist/modules/lighting/lights/lighting.d.ts +104 -62
  80. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  81. package/dist/modules/lighting/lights/lighting.js +107 -68
  82. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  83. package/dist/modules/lighting/no-material/dirlight.d.ts +8 -3
  84. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  85. package/dist/modules/lighting/no-material/dirlight.js +4 -2
  86. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  87. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
  88. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
  89. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +581 -28
  90. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -1
  91. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +2 -2
  92. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
  93. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +850 -107
  94. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -1
  95. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +172 -41
  96. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  97. package/dist/modules/lighting/pbr-material/pbr-material.js +109 -1
  98. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  99. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  100. package/dist/modules/lighting/pbr-material/pbr-projection.js +14 -2
  101. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  102. package/dist/modules/lighting/pbr-material/pbr-scene.d.ts +40 -0
  103. package/dist/modules/lighting/pbr-material/pbr-scene.d.ts.map +1 -0
  104. package/dist/modules/lighting/pbr-material/pbr-scene.js +67 -0
  105. package/dist/modules/lighting/pbr-material/pbr-scene.js.map +1 -0
  106. package/dist/modules/lighting/phong-material/phong-material.d.ts +1 -0
  107. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  108. package/dist/modules/lighting/phong-material/phong-material.js +4 -0
  109. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  110. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  111. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  112. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +17 -6
  113. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  114. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +1 -40
  115. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -1
  116. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +71 -76
  117. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -1
  118. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  119. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  120. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +42 -11
  121. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -1
  122. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +2 -0
  123. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
  124. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +212 -0
  125. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
  126. package/dist/modules/math/fp64/fp64.d.ts +1 -0
  127. package/dist/modules/math/fp64/fp64.d.ts.map +1 -1
  128. package/dist/modules/math/fp64/fp64.js +8 -2
  129. package/dist/modules/math/fp64/fp64.js.map +1 -1
  130. package/dist/modules/math/random/random.d.ts +1 -1
  131. package/dist/modules/math/random/random.d.ts.map +1 -1
  132. package/dist/modules/math/random/random.js +2 -3
  133. package/dist/modules/math/random/random.js.map +1 -1
  134. package/package.json +4 -5
  135. package/src/index.ts +37 -6
  136. package/src/lib/preprocessor/preprocessor.ts +44 -8
  137. package/src/lib/shader-assembler.ts +25 -3
  138. package/src/lib/shader-assembly/assemble-shaders.ts +384 -12
  139. package/src/lib/shader-assembly/wgsl-binding-debug.ts +216 -0
  140. package/src/lib/shader-generator/glsl/generate-glsl.ts +11 -5
  141. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +6 -0
  142. package/src/lib/shader-module/shader-module-uniform-layout.ts +346 -0
  143. package/src/lib/shader-module/shader-module.ts +17 -7
  144. package/src/lib/utils/assert.ts +3 -1
  145. package/src/lib/utils/uniform-types.ts +24 -9
  146. package/src/modules/engine/picking/picking.ts +5 -2
  147. package/src/modules/engine/project/project.ts +1 -1
  148. package/src/modules/engine/skin/skin.ts +114 -0
  149. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  150. package/src/modules/lighting/ibl/ibl.ts +44 -0
  151. package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
  152. package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
  153. package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
  154. package/src/modules/lighting/lights/lighting-glsl.ts +44 -38
  155. package/src/modules/lighting/lights/lighting-wgsl.ts +46 -18
  156. package/src/modules/lighting/lights/lighting.ts +198 -99
  157. package/src/modules/lighting/no-material/dirlight.ts +4 -2
  158. package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +581 -28
  159. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +850 -107
  160. package/src/modules/lighting/pbr-material/pbr-material.ts +185 -5
  161. package/src/modules/lighting/pbr-material/pbr-projection.ts +15 -2
  162. package/src/modules/lighting/pbr-material/pbr-scene.ts +91 -0
  163. package/src/modules/lighting/phong-material/phong-material.ts +5 -0
  164. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +17 -6
  165. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +71 -77
  166. package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +42 -11
  167. package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +212 -0
  168. package/src/modules/math/fp64/fp64.ts +9 -3
  169. package/src/modules/math/random/random.ts +2 -3
  170. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts +0 -8
  171. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +0 -1
  172. package/dist/lib/wgsl/get-shader-layout-wgsl.js +0 -95
  173. package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +0 -1
  174. package/src/lib/wgsl/get-shader-layout-wgsl.ts +0 -105
@@ -3,6 +3,8 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  export const lightingUniformsWGSL = /* wgsl */ `\
5
5
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
6
+ const MAX_LIGHTS: i32 = 5;
7
+
6
8
  struct AmbientLight {
7
9
  color: vec3<f32>,
8
10
  };
@@ -13,45 +15,71 @@ struct PointLight {
13
15
  attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
14
16
  };
15
17
 
18
+ struct SpotLight {
19
+ color: vec3<f32>,
20
+ position: vec3<f32>,
21
+ direction: vec3<f32>,
22
+ attenuation: vec3<f32>,
23
+ coneCos: vec2<f32>,
24
+ };
25
+
16
26
  struct DirectionalLight {
17
27
  color: vec3<f32>,
18
28
  direction: vec3<f32>,
19
29
  };
20
30
 
31
+ struct UniformLight {
32
+ color: vec3<f32>,
33
+ position: vec3<f32>,
34
+ direction: vec3<f32>,
35
+ attenuation: vec3<f32>,
36
+ coneCos: vec2<f32>,
37
+ };
38
+
21
39
  struct lightingUniforms {
22
40
  enabled: i32,
23
- pointLightCount: i32,
24
41
  directionalLightCount: i32,
25
-
42
+ pointLightCount: i32,
43
+ spotLightCount: i32,
26
44
  ambientColor: vec3<f32>,
27
-
28
- // TODO - support multiple lights by uncommenting arrays below
29
- lightType: i32,
30
- lightColor: vec3<f32>,
31
- lightDirection: vec3<f32>,
32
- lightPosition: vec3<f32>,
33
- lightAttenuation: vec3<f32>,
34
-
35
- // AmbientLight ambientLight;
36
- // PointLight pointLight[MAX_LIGHTS];
37
- // DirectionalLight directionalLight[MAX_LIGHTS];
45
+ lights: array<UniformLight, 5>,
38
46
  };
39
47
 
40
- // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
41
- @binding(1) @group(0) var<uniform> lighting : lightingUniforms;
48
+ @group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
42
49
 
43
50
  fn lighting_getPointLight(index: i32) -> PointLight {
44
- return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
51
+ let light = lighting.lights[index];
52
+ return PointLight(light.color, light.position, light.attenuation);
53
+ }
54
+
55
+ fn lighting_getSpotLight(index: i32) -> SpotLight {
56
+ let light = lighting.lights[lighting.pointLightCount + index];
57
+ return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
45
58
  }
46
59
 
47
60
  fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
48
- return DirectionalLight(lighting.lightColor, lighting.lightDirection);
49
- }
61
+ let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
62
+ return DirectionalLight(light.color, light.direction);
63
+ }
50
64
 
51
65
  fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
52
66
  return pointLight.attenuation.x
53
67
  + pointLight.attenuation.y * distance
54
68
  + pointLight.attenuation.z * distance * distance;
55
69
  }
70
+
71
+ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
72
+ let lightDirection = normalize(positionWorldspace - spotLight.position);
73
+ let coneFactor = smoothstep(
74
+ spotLight.coneCos.y,
75
+ spotLight.coneCos.x,
76
+ dot(normalize(spotLight.direction), lightDirection)
77
+ );
78
+ let distanceAttenuation = getPointLightAttenuation(
79
+ PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
80
+ distance(spotLight.position, positionWorldspace)
81
+ );
82
+ return distanceAttenuation / max(coneFactor, 0.0001);
83
+ }
56
84
  `;
57
85
  //# sourceMappingURL=lighting-wgsl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lighting-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoD9C,CAAC"}
1
+ {"version":3,"file":"lighting-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgF9C,CAAC"}
@@ -1,59 +1,119 @@
1
- import type { NumberArray3 } from '@math.gl/core';
2
- /** Shader type field for lights */
3
- export declare enum LIGHT_TYPE {
4
- POINT = 0,
5
- DIRECTIONAL = 1
6
- }
7
- /** Lighting helper types */
8
- export type Light = AmbientLight | PointLight | DirectionalLight;
1
+ import type { NumberArray2, NumberArray3 } from '@math.gl/core';
2
+ /** Supported light source descriptions accepted by the lighting shader module. */
3
+ export type Light = AmbientLight | PointLight | SpotLight | DirectionalLight;
4
+ /** Ambient light contribution shared across the entire scene. */
9
5
  export type AmbientLight = {
6
+ /** Discriminator used to identify ambient lights in `lights: Light[]`. */
10
7
  type: 'ambient';
8
+ /** RGB light color in the existing `0..255` convention used by luma.gl materials. */
11
9
  color?: Readonly<NumberArray3>;
10
+ /** Scalar intensity multiplier applied to the light color. */
12
11
  intensity?: number;
13
12
  };
13
+ /** Omnidirectional point light emitted from a world-space position. */
14
14
  export type PointLight = {
15
+ /** Discriminator used to identify point lights in `lights: Light[]`. */
15
16
  type: 'point';
17
+ /** World-space light position. */
16
18
  position: Readonly<NumberArray3>;
19
+ /** RGB light color in the existing `0..255` convention used by luma.gl materials. */
17
20
  color?: Readonly<NumberArray3>;
21
+ /** Scalar intensity multiplier applied to the light color. */
18
22
  intensity?: number;
23
+ /** Constant, linear, and quadratic attenuation coefficients. */
19
24
  attenuation?: Readonly<NumberArray3>;
20
25
  };
26
+ /** Directional light defined only by its incoming world-space direction. */
21
27
  export type DirectionalLight = {
28
+ /** Discriminator used to identify directional lights in `lights: Light[]`. */
22
29
  type: 'directional';
30
+ /** World-space light direction. */
23
31
  direction: Readonly<NumberArray3>;
32
+ /** RGB light color in the existing `0..255` convention used by luma.gl materials. */
24
33
  color?: Readonly<NumberArray3>;
34
+ /** Scalar intensity multiplier applied to the light color. */
25
35
  intensity?: number;
26
36
  };
37
+ /** Cone-shaped light emitted from a position and focused along a direction. */
38
+ export type SpotLight = {
39
+ /** Discriminator used to identify spot lights in `lights: Light[]`. */
40
+ type: 'spot';
41
+ /** World-space light position. */
42
+ position: Readonly<NumberArray3>;
43
+ /** World-space light direction. */
44
+ direction: Readonly<NumberArray3>;
45
+ /** RGB light color in the existing `0..255` convention used by luma.gl materials. */
46
+ color?: Readonly<NumberArray3>;
47
+ /** Scalar intensity multiplier applied to the light color. */
48
+ intensity?: number;
49
+ /** Constant, linear, and quadratic attenuation coefficients. */
50
+ attenuation?: Readonly<NumberArray3>;
51
+ /** Inner spotlight cone angle in radians. */
52
+ innerConeAngle?: number;
53
+ /** Outer spotlight cone angle in radians. */
54
+ outerConeAngle?: number;
55
+ };
56
+ /** Public JavaScript props accepted by the `lighting` shader module. */
27
57
  export type LightingProps = {
58
+ /** Enables or disables lighting calculations for the module. */
28
59
  enabled?: boolean;
60
+ /** Preferred API for supplying mixed ambient, point, spot, and directional lights. */
29
61
  lights?: Light[];
30
- /** @deprecated */
62
+ /**
63
+ * Legacy ambient-light prop.
64
+ * @deprecated Use `lights` with `{type: 'ambient', ...}` entries instead.
65
+ */
31
66
  ambientLight?: AmbientLight;
32
- /** @deprecated */
67
+ /**
68
+ * Legacy point-light prop.
69
+ * @deprecated Use `lights` with `{type: 'point', ...}` entries instead.
70
+ */
33
71
  pointLights?: PointLight[];
34
- /** @deprecated */
72
+ /**
73
+ * Legacy spot-light prop.
74
+ * @deprecated Use `lights` with `{type: 'spot', ...}` entries instead.
75
+ */
76
+ spotLights?: SpotLight[];
77
+ /**
78
+ * Legacy directional-light prop.
79
+ * @deprecated Use `lights` with `{type: 'directional', ...}` entries instead.
80
+ */
35
81
  directionalLights?: DirectionalLight[];
36
82
  };
83
+ /** Packed per-light data written into the module's fixed-size uniform array. */
84
+ export type LightingLightUniform = {
85
+ /** Light color converted to normalized shader-space RGB. */
86
+ color: Readonly<NumberArray3>;
87
+ /** World-space light position or a default placeholder for non-positional lights. */
88
+ position: Readonly<NumberArray3>;
89
+ /** World-space light direction or a default placeholder for positional lights. */
90
+ direction: Readonly<NumberArray3>;
91
+ /** Constant, linear, and quadratic attenuation coefficients. */
92
+ attenuation: Readonly<NumberArray3>;
93
+ /** Cosines of the inner and outer spotlight cone angles. */
94
+ coneCos: Readonly<NumberArray2>;
95
+ };
96
+ /** Fully normalized uniform values produced by the `lighting` shader module. */
37
97
  export type LightingUniforms = {
98
+ /** `1` when lighting is enabled, otherwise `0`. */
38
99
  enabled: number;
39
- ambientColor: Readonly<NumberArray3>;
100
+ /** Number of packed directional lights in the `lights` array. */
40
101
  directionalLightCount: number;
102
+ /** Number of packed point lights in the `lights` array. */
41
103
  pointLightCount: number;
42
- lightType: number;
43
- lightColor0: Readonly<NumberArray3>;
44
- lightPosition0: Readonly<NumberArray3>;
45
- lightDirection0: Readonly<NumberArray3>;
46
- lightAttenuation0: Readonly<NumberArray3>;
47
- lightColor1: Readonly<NumberArray3>;
48
- lightPosition1: Readonly<NumberArray3>;
49
- lightDirection1: Readonly<NumberArray3>;
50
- lightAttenuation1: Readonly<NumberArray3>;
51
- lightColor2: Readonly<NumberArray3>;
52
- lightPosition2: Readonly<NumberArray3>;
53
- lightDirection2: Readonly<NumberArray3>;
54
- lightAttenuation2: Readonly<NumberArray3>;
104
+ /** Number of packed spot lights in the `lights` array. */
105
+ spotLightCount: number;
106
+ /** Accumulated ambient color converted to normalized shader-space RGB. */
107
+ ambientColor: Readonly<NumberArray3>;
108
+ /** Packed trailing array of non-ambient light structs. */
109
+ lights: ReadonlyArray<LightingLightUniform>;
55
110
  };
56
- /** UBO ready lighting module */
111
+ /**
112
+ * Portable lighting shader module shared by the Phong, Gouraud, and PBR material modules.
113
+ *
114
+ * The public JavaScript API accepts `lights: Light[]`, while the uniform buffer packs
115
+ * non-ambient lights into a fixed-size trailing array for portability across WebGL2 and WebGPU.
116
+ */
57
117
  export declare const lighting: {
58
118
  readonly props: LightingProps;
59
119
  readonly uniforms: LightingUniforms;
@@ -61,47 +121,29 @@ export declare const lighting: {
61
121
  readonly defines: {};
62
122
  readonly uniformTypes: {
63
123
  readonly enabled: "i32";
64
- readonly lightType: "i32";
65
124
  readonly directionalLightCount: "i32";
66
125
  readonly pointLightCount: "i32";
126
+ readonly spotLightCount: "i32";
67
127
  readonly ambientColor: "vec3<f32>";
68
- readonly lightColor0: "vec3<f32>";
69
- readonly lightPosition0: "vec3<f32>";
70
- readonly lightDirection0: "vec3<f32>";
71
- readonly lightAttenuation0: "vec3<f32>";
72
- readonly lightColor1: "vec3<f32>";
73
- readonly lightPosition1: "vec3<f32>";
74
- readonly lightDirection1: "vec3<f32>";
75
- readonly lightAttenuation1: "vec3<f32>";
76
- readonly lightColor2: "vec3<f32>";
77
- readonly lightPosition2: "vec3<f32>";
78
- readonly lightDirection2: "vec3<f32>";
79
- readonly lightAttenuation2: "vec3<f32>";
80
- };
81
- readonly defaultUniforms: {
82
- readonly enabled: 1;
83
- readonly lightType: LIGHT_TYPE.POINT;
84
- readonly directionalLightCount: 0;
85
- readonly pointLightCount: 0;
86
- readonly ambientColor: readonly [0.1, 0.1, 0.1];
87
- readonly lightColor0: readonly [1, 1, 1];
88
- readonly lightPosition0: readonly [1, 1, 2];
89
- readonly lightDirection0: readonly [1, 1, 1];
90
- readonly lightAttenuation0: readonly [1, 0, 0];
91
- readonly lightColor1: readonly [1, 1, 1];
92
- readonly lightPosition1: readonly [1, 1, 2];
93
- readonly lightDirection1: readonly [1, 1, 1];
94
- readonly lightAttenuation1: readonly [1, 0, 0];
95
- readonly lightColor2: readonly [1, 1, 1];
96
- readonly lightPosition2: readonly [1, 1, 2];
97
- readonly lightDirection2: readonly [1, 1, 1];
98
- readonly lightAttenuation2: readonly [1, 0, 0];
128
+ readonly lights: readonly [{
129
+ readonly color: "vec3<f32>";
130
+ readonly position: "vec3<f32>";
131
+ readonly direction: "vec3<f32>";
132
+ readonly attenuation: "vec3<f32>";
133
+ readonly coneCos: "vec2<f32>";
134
+ }, 5];
99
135
  };
100
- readonly source: "// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n pointLightCount: i32,\n directionalLightCount: i32,\n\n ambientColor: vec3<f32>,\n\n // TODO - support multiple lights by uncommenting arrays below\n lightType: i32,\n lightColor: vec3<f32>,\n lightDirection: vec3<f32>,\n lightPosition: vec3<f32>,\n lightAttenuation: vec3<f32>,\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n};\n\n// Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)\n@binding(1) @group(0) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n";
101
- readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int lightType;\n\n int directionalLightCount;\n int pointLightCount;\n\n vec3 ambientColor;\n\n vec3 lightColor0;\n vec3 lightPosition0;\n vec3 lightDirection0;\n vec3 lightAttenuation0;\n\n vec3 lightColor1;\n vec3 lightPosition1;\n vec3 lightDirection1;\n vec3 lightAttenuation1;\n\n vec3 lightColor2;\n vec3 lightPosition2;\n vec3 lightDirection2;\n vec3 lightAttenuation2;\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n switch (index) {\n case 0:\n return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);\n case 1:\n return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);\n case 2:\n default: \n return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);\n }\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n switch (index) {\n case 0:\n return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);\n case 1:\n return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);\n case 2:\n default: \n return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);\n }\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
102
- readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int lightType;\n\n int directionalLightCount;\n int pointLightCount;\n\n vec3 ambientColor;\n\n vec3 lightColor0;\n vec3 lightPosition0;\n vec3 lightDirection0;\n vec3 lightAttenuation0;\n\n vec3 lightColor1;\n vec3 lightPosition1;\n vec3 lightDirection1;\n vec3 lightAttenuation1;\n\n vec3 lightColor2;\n vec3 lightPosition2;\n vec3 lightDirection2;\n vec3 lightAttenuation2;\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n switch (index) {\n case 0:\n return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);\n case 1:\n return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);\n case 2:\n default: \n return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);\n }\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n switch (index) {\n case 0:\n return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);\n case 1:\n return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);\n case 2:\n default: \n return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);\n }\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
136
+ readonly defaultUniforms: LightingUniforms;
137
+ readonly bindingLayout: readonly [{
138
+ readonly name: "lighting";
139
+ readonly group: 2;
140
+ }];
141
+ readonly firstBindingSlot: 0;
142
+ readonly source: "// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nconst MAX_LIGHTS: i32 = 5;\n\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct UniformLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n directionalLightCount: i32,\n pointLightCount: i32,\n spotLightCount: i32,\n ambientColor: vec3<f32>,\n lights: array<UniformLight, 5>,\n};\n\n@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n let light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nfn lighting_getSpotLight(index: i32) -> SpotLight {\n let light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {\n let lightDirection = normalize(positionWorldspace - spotLight.position);\n let coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), lightDirection)\n );\n let distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n";
143
+ readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n";
144
+ readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n";
103
145
  readonly getUniforms: typeof getUniforms;
104
146
  };
105
- declare function getUniforms(props?: LightingProps, prevUniforms?: Partial<LightingUniforms>): LightingUniforms;
147
+ declare function getUniforms(props?: LightingProps, _prevUniforms?: Partial<LightingUniforms>): LightingUniforms;
106
148
  export {};
107
149
  //# sourceMappingURL=lighting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lighting.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAQhD,mCAAmC;AAEnC,oBAAY,UAAU;IACpB,KAAK,IAAI;IACT,WAAW,IAAI;CAChB;AAED,4BAA4B;AAE5B,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,kBAAkB;IAClB,YAAY,CAA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;IAC7B,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrC,0DAA0D;IAC1D,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC7C,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBoC,CAAC;AAEvE,iBAAS,WAAW,CAClB,KAAK,CAAC,EAAE,aAAa,EACrB,aAAa,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAC5C,gBAAgB,CAuClB"}
@@ -8,14 +8,19 @@ import { lightingUniformsWGSL } from "./lighting-wgsl.js";
8
8
  const MAX_LIGHTS = 5;
9
9
  /** Whether to divide */
10
10
  const COLOR_FACTOR = 255.0;
11
- /** Shader type field for lights */
12
- // eslint-disable-next-line no-shadow
13
- export var LIGHT_TYPE;
14
- (function (LIGHT_TYPE) {
15
- LIGHT_TYPE[LIGHT_TYPE["POINT"] = 0] = "POINT";
16
- LIGHT_TYPE[LIGHT_TYPE["DIRECTIONAL"] = 1] = "DIRECTIONAL";
17
- })(LIGHT_TYPE || (LIGHT_TYPE = {}));
18
- /** UBO ready lighting module */
11
+ const LIGHT_UNIFORM_TYPE = {
12
+ color: 'vec3<f32>',
13
+ position: 'vec3<f32>',
14
+ direction: 'vec3<f32>',
15
+ attenuation: 'vec3<f32>',
16
+ coneCos: 'vec2<f32>'
17
+ };
18
+ /**
19
+ * Portable lighting shader module shared by the Phong, Gouraud, and PBR material modules.
20
+ *
21
+ * The public JavaScript API accepts `lights: Light[]`, while the uniform buffer packs
22
+ * non-ambient lights into a fixed-size trailing array for portability across WebGL2 and WebGPU.
23
+ */
19
24
  export const lighting = {
20
25
  props: {},
21
26
  uniforms: {},
@@ -25,108 +30,112 @@ export const lighting = {
25
30
  },
26
31
  uniformTypes: {
27
32
  enabled: 'i32',
28
- lightType: 'i32',
29
33
  directionalLightCount: 'i32',
30
34
  pointLightCount: 'i32',
35
+ spotLightCount: 'i32',
31
36
  ambientColor: 'vec3<f32>',
32
- // TODO define as arrays once we have appropriate uniformTypes
33
- lightColor0: 'vec3<f32>',
34
- lightPosition0: 'vec3<f32>',
35
- // TODO - could combine direction and attenuation
36
- lightDirection0: 'vec3<f32>',
37
- lightAttenuation0: 'vec3<f32>',
38
- lightColor1: 'vec3<f32>',
39
- lightPosition1: 'vec3<f32>',
40
- lightDirection1: 'vec3<f32>',
41
- lightAttenuation1: 'vec3<f32>',
42
- lightColor2: 'vec3<f32>',
43
- lightPosition2: 'vec3<f32>',
44
- lightDirection2: 'vec3<f32>',
45
- lightAttenuation2: 'vec3<f32>'
46
- },
47
- defaultUniforms: {
48
- enabled: 1,
49
- lightType: LIGHT_TYPE.POINT,
50
- directionalLightCount: 0,
51
- pointLightCount: 0,
52
- ambientColor: [0.1, 0.1, 0.1],
53
- lightColor0: [1, 1, 1],
54
- lightPosition0: [1, 1, 2],
55
- // TODO - could combine direction and attenuation
56
- lightDirection0: [1, 1, 1],
57
- lightAttenuation0: [1, 0, 0],
58
- lightColor1: [1, 1, 1],
59
- lightPosition1: [1, 1, 2],
60
- lightDirection1: [1, 1, 1],
61
- lightAttenuation1: [1, 0, 0],
62
- lightColor2: [1, 1, 1],
63
- lightPosition2: [1, 1, 2],
64
- lightDirection2: [1, 1, 1],
65
- lightAttenuation2: [1, 0, 0]
37
+ lights: [LIGHT_UNIFORM_TYPE, MAX_LIGHTS]
66
38
  },
39
+ defaultUniforms: createDefaultLightingUniforms(),
40
+ bindingLayout: [{ name: 'lighting', group: 2 }],
41
+ firstBindingSlot: 0,
67
42
  source: lightingUniformsWGSL,
68
43
  vs: lightingUniformsGLSL,
69
44
  fs: lightingUniformsGLSL,
70
45
  getUniforms
71
46
  };
72
- function getUniforms(props, prevUniforms = {}) {
47
+ function getUniforms(props, _prevUniforms = {}) {
73
48
  // Copy props so we can modify
74
49
  props = props ? { ...props } : props;
75
50
  // TODO legacy
76
51
  if (!props) {
77
- return { ...lighting.defaultUniforms };
52
+ return createDefaultLightingUniforms();
78
53
  }
79
54
  // Support for array of lights. Type of light is detected by type field
80
55
  if (props.lights) {
81
56
  props = { ...props, ...extractLightTypes(props.lights), lights: undefined };
82
57
  }
83
58
  // Specify lights separately
84
- const { ambientLight, pointLights, directionalLights } = props || {};
59
+ const { ambientLight, pointLights, spotLights, directionalLights } = props || {};
85
60
  const hasLights = ambientLight ||
86
61
  (pointLights && pointLights.length > 0) ||
62
+ (spotLights && spotLights.length > 0) ||
87
63
  (directionalLights && directionalLights.length > 0);
88
64
  // TODO - this may not be the correct decision
89
65
  if (!hasLights) {
90
- return { ...lighting.defaultUniforms, enabled: 0 };
66
+ return {
67
+ ...createDefaultLightingUniforms(),
68
+ enabled: 0
69
+ };
91
70
  }
92
71
  const uniforms = {
93
- ...lighting.defaultUniforms,
94
- ...prevUniforms,
95
- ...getLightSourceUniforms({ ambientLight, pointLights, directionalLights })
72
+ ...createDefaultLightingUniforms(),
73
+ ...getLightSourceUniforms({ ambientLight, pointLights, spotLights, directionalLights })
96
74
  };
97
75
  if (props.enabled !== undefined) {
98
76
  uniforms.enabled = props.enabled ? 1 : 0;
99
77
  }
100
78
  return uniforms;
101
79
  }
102
- function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLights = [] }) {
103
- const lightSourceUniforms = {};
104
- lightSourceUniforms.ambientColor = convertColor(ambientLight);
80
+ function getLightSourceUniforms({ ambientLight, pointLights = [], spotLights = [], directionalLights = [] }) {
81
+ const lights = createDefaultLightUniforms();
105
82
  let currentLight = 0;
83
+ let pointLightCount = 0;
84
+ let spotLightCount = 0;
85
+ let directionalLightCount = 0;
106
86
  for (const pointLight of pointLights) {
107
- lightSourceUniforms.lightType = LIGHT_TYPE.POINT;
108
- const i = currentLight;
109
- lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
110
- lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
111
- lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
87
+ if (currentLight >= MAX_LIGHTS) {
88
+ break;
89
+ }
90
+ lights[currentLight] = {
91
+ ...lights[currentLight],
92
+ color: convertColor(pointLight),
93
+ position: pointLight.position,
94
+ attenuation: pointLight.attenuation || [1, 0, 0]
95
+ };
96
+ currentLight++;
97
+ pointLightCount++;
98
+ }
99
+ for (const spotLight of spotLights) {
100
+ if (currentLight >= MAX_LIGHTS) {
101
+ break;
102
+ }
103
+ lights[currentLight] = {
104
+ ...lights[currentLight],
105
+ color: convertColor(spotLight),
106
+ position: spotLight.position,
107
+ direction: spotLight.direction,
108
+ attenuation: spotLight.attenuation || [1, 0, 0],
109
+ coneCos: getSpotConeCos(spotLight)
110
+ };
112
111
  currentLight++;
112
+ spotLightCount++;
113
113
  }
114
114
  for (const directionalLight of directionalLights) {
115
- lightSourceUniforms.lightType = LIGHT_TYPE.DIRECTIONAL;
116
- const i = currentLight;
117
- lightSourceUniforms[`lightColor${i}`] = convertColor(directionalLight);
118
- lightSourceUniforms[`lightDirection${i}`] = directionalLight.direction;
115
+ if (currentLight >= MAX_LIGHTS) {
116
+ break;
117
+ }
118
+ lights[currentLight] = {
119
+ ...lights[currentLight],
120
+ color: convertColor(directionalLight),
121
+ direction: directionalLight.direction
122
+ };
119
123
  currentLight++;
124
+ directionalLightCount++;
120
125
  }
121
- if (currentLight > MAX_LIGHTS) {
122
- log.warn('MAX_LIGHTS exceeded')();
126
+ if (pointLights.length + spotLights.length + directionalLights.length > MAX_LIGHTS) {
127
+ log.warn(`MAX_LIGHTS exceeded, truncating to ${MAX_LIGHTS}`)();
123
128
  }
124
- lightSourceUniforms.directionalLightCount = directionalLights.length;
125
- lightSourceUniforms.pointLightCount = pointLights.length;
126
- return lightSourceUniforms;
129
+ return {
130
+ ambientColor: convertColor(ambientLight),
131
+ directionalLightCount,
132
+ pointLightCount,
133
+ spotLightCount,
134
+ lights
135
+ };
127
136
  }
128
137
  function extractLightTypes(lights) {
129
- const lightSources = { pointLights: [], directionalLights: [] };
138
+ const lightSources = { pointLights: [], spotLights: [], directionalLights: [] };
130
139
  for (const light of lights || []) {
131
140
  switch (light.type) {
132
141
  case 'ambient':
@@ -140,6 +149,9 @@ function extractLightTypes(lights) {
140
149
  case 'point':
141
150
  lightSources.pointLights?.push(light);
142
151
  break;
152
+ case 'spot':
153
+ lightSources.spotLights?.push(light);
154
+ break;
143
155
  default:
144
156
  // eslint-disable-next-line
145
157
  // console.warn(light.type);
@@ -152,4 +164,31 @@ function convertColor(colorDef = {}) {
152
164
  const { color = [0, 0, 0], intensity = 1.0 } = colorDef;
153
165
  return color.map(component => (component * intensity) / COLOR_FACTOR);
154
166
  }
167
+ function createDefaultLightingUniforms() {
168
+ return {
169
+ enabled: 1,
170
+ directionalLightCount: 0,
171
+ pointLightCount: 0,
172
+ spotLightCount: 0,
173
+ ambientColor: [0.1, 0.1, 0.1],
174
+ lights: createDefaultLightUniforms()
175
+ };
176
+ }
177
+ function createDefaultLightUniforms() {
178
+ return Array.from({ length: MAX_LIGHTS }, () => createDefaultLightUniform());
179
+ }
180
+ function createDefaultLightUniform() {
181
+ return {
182
+ color: [1, 1, 1],
183
+ position: [1, 1, 2],
184
+ direction: [1, 1, 1],
185
+ attenuation: [1, 0, 0],
186
+ coneCos: [1, 0]
187
+ };
188
+ }
189
+ function getSpotConeCos(spotLight) {
190
+ const innerConeAngle = spotLight.innerConeAngle ?? 0;
191
+ const outerConeAngle = spotLight.outerConeAngle ?? Math.PI / 4;
192
+ return [Math.cos(innerConeAngle), Math.cos(outerConeAngle)];
193
+ }
155
194
  //# sourceMappingURL=lighting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lighting.js","sourceRoot":"","s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