@luma.gl/shadertools 9.3.0-alpha.4 → 9.3.0-alpha.8

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 (157) hide show
  1. package/dist/dist.dev.js +4657 -523
  2. package/dist/dist.min.js +1952 -301
  3. package/dist/index.cjs +2804 -406
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +10 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +4 -0
  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 +211 -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 +3 -0
  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 +22 -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 +112 -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/uniform-types.d.ts +11 -7
  37. package/dist/lib/utils/uniform-types.d.ts.map +1 -1
  38. package/dist/modules/engine/picking/picking.d.ts +3 -0
  39. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  40. package/dist/modules/engine/picking/picking.js +3 -0
  41. package/dist/modules/engine/picking/picking.js.map +1 -1
  42. package/dist/modules/engine/skin/skin.d.ts +30 -0
  43. package/dist/modules/engine/skin/skin.d.ts.map +1 -0
  44. package/dist/modules/engine/skin/skin.js +86 -0
  45. package/dist/modules/engine/skin/skin.js.map +1 -0
  46. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -0
  47. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  48. package/dist/modules/lighting/gouraud-material/gouraud-material.js +3 -0
  49. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  50. package/dist/modules/lighting/ibl/ibl.d.ts +26 -0
  51. package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
  52. package/dist/modules/lighting/ibl/ibl.js +33 -0
  53. package/dist/modules/lighting/ibl/ibl.js.map +1 -0
  54. package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
  55. package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
  56. package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
  57. package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
  58. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
  59. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
  60. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
  61. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
  62. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
  63. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
  64. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
  65. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
  66. package/dist/modules/lighting/lights/lighting-glsl.d.ts +1 -1
  67. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -1
  68. package/dist/modules/lighting/lights/lighting-glsl.js +43 -37
  69. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -1
  70. package/dist/modules/lighting/lights/lighting-wgsl.d.ts +1 -1
  71. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -1
  72. package/dist/modules/lighting/lights/lighting-wgsl.js +46 -18
  73. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -1
  74. package/dist/modules/lighting/lights/lighting.d.ts +104 -62
  75. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  76. package/dist/modules/lighting/lights/lighting.js +107 -68
  77. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  78. package/dist/modules/lighting/no-material/dirlight.d.ts +7 -2
  79. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  80. package/dist/modules/lighting/no-material/dirlight.js +3 -1
  81. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  82. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
  83. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
  84. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +524 -28
  85. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -1
  86. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +2 -2
  87. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
  88. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +784 -101
  89. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -1
  90. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +110 -45
  91. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  92. package/dist/modules/lighting/pbr-material/pbr-material.js +85 -9
  93. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  94. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  95. package/dist/modules/lighting/pbr-material/pbr-projection.js +13 -1
  96. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  97. package/dist/modules/lighting/phong-material/phong-material.d.ts +1 -0
  98. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  99. package/dist/modules/lighting/phong-material/phong-material.js +4 -0
  100. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  101. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  102. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  103. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +15 -4
  104. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  105. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +1 -40
  106. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -1
  107. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +71 -76
  108. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -1
  109. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  110. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  111. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +41 -10
  112. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -1
  113. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +2 -0
  114. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
  115. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +212 -0
  116. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
  117. package/dist/modules/math/fp64/fp64.d.ts +1 -0
  118. package/dist/modules/math/fp64/fp64.d.ts.map +1 -1
  119. package/dist/modules/math/fp64/fp64.js +8 -2
  120. package/dist/modules/math/fp64/fp64.js.map +1 -1
  121. package/dist/modules/math/random/random.d.ts +1 -1
  122. package/dist/modules/math/random/random.d.ts.map +1 -1
  123. package/dist/modules/math/random/random.js +2 -3
  124. package/dist/modules/math/random/random.js.map +1 -1
  125. package/package.json +3 -3
  126. package/src/index.ts +20 -2
  127. package/src/lib/preprocessor/preprocessor.ts +44 -8
  128. package/src/lib/shader-assembler.ts +25 -3
  129. package/src/lib/shader-assembly/assemble-shaders.ts +377 -12
  130. package/src/lib/shader-assembly/wgsl-binding-debug.ts +216 -0
  131. package/src/lib/shader-generator/glsl/generate-glsl.ts +7 -1
  132. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +6 -0
  133. package/src/lib/shader-module/shader-module-uniform-layout.ts +194 -0
  134. package/src/lib/shader-module/shader-module.ts +17 -7
  135. package/src/lib/utils/uniform-types.ts +24 -9
  136. package/src/modules/engine/picking/picking.ts +3 -0
  137. package/src/modules/engine/skin/skin.ts +114 -0
  138. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  139. package/src/modules/lighting/ibl/ibl.ts +44 -0
  140. package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
  141. package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
  142. package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
  143. package/src/modules/lighting/lights/lighting-glsl.ts +43 -37
  144. package/src/modules/lighting/lights/lighting-wgsl.ts +46 -18
  145. package/src/modules/lighting/lights/lighting.ts +198 -99
  146. package/src/modules/lighting/no-material/dirlight.ts +3 -1
  147. package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +524 -28
  148. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +784 -101
  149. package/src/modules/lighting/pbr-material/pbr-material.ts +111 -18
  150. package/src/modules/lighting/pbr-material/pbr-projection.ts +14 -1
  151. package/src/modules/lighting/phong-material/phong-material.ts +5 -0
  152. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +15 -4
  153. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +71 -77
  154. package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +41 -10
  155. package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +212 -0
  156. package/src/modules/math/fp64/fp64.ts +9 -3
  157. package/src/modules/math/random/random.ts +2 -3
@@ -0,0 +1,73 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export const LAMBERT_WGSL = /* wgsl */ `\
6
+ struct lambertMaterialUniforms {
7
+ unlit: u32,
8
+ ambient: f32,
9
+ diffuse: f32,
10
+ };
11
+
12
+ @group(3) @binding(auto) var<uniform> lambertMaterial : lambertMaterialUniforms;
13
+
14
+ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
15
+ let lambertian: f32 = max(dot(light_direction, normal_worldspace), 0.0);
16
+ return lambertian * lambertMaterial.diffuse * surfaceColor * color;
17
+ }
18
+
19
+ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
20
+ var lightColor: vec3<f32> = surfaceColor;
21
+
22
+ if (lambertMaterial.unlit != 0u) {
23
+ return surfaceColor;
24
+ }
25
+
26
+ if (lighting.enabled == 0) {
27
+ return lightColor;
28
+ }
29
+
30
+ lightColor = lambertMaterial.ambient * surfaceColor * lighting.ambientColor;
31
+
32
+ for (var i: i32 = 0; i < lighting.pointLightCount; i++) {
33
+ let pointLight: PointLight = lighting_getPointLight(i);
34
+ let light_position_worldspace: vec3<f32> = pointLight.position;
35
+ let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
36
+ let light_attenuation = getPointLightAttenuation(
37
+ pointLight,
38
+ distance(light_position_worldspace, position_worldspace)
39
+ );
40
+ lightColor += lighting_getLightColor(
41
+ surfaceColor,
42
+ light_direction,
43
+ normal_worldspace,
44
+ pointLight.color / light_attenuation
45
+ );
46
+ }
47
+
48
+ for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
49
+ let spotLight: SpotLight = lighting_getSpotLight(i);
50
+ let light_position_worldspace: vec3<f32> = spotLight.position;
51
+ let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
52
+ let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
53
+ lightColor += lighting_getLightColor(
54
+ surfaceColor,
55
+ light_direction,
56
+ normal_worldspace,
57
+ spotLight.color / light_attenuation
58
+ );
59
+ }
60
+
61
+ for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
62
+ let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
63
+ lightColor += lighting_getLightColor(
64
+ surfaceColor,
65
+ -directionalLight.direction,
66
+ normal_worldspace,
67
+ directionalLight.color
68
+ );
69
+ }
70
+
71
+ return lightColor;
72
+ }
73
+ `;
@@ -16,59 +16,51 @@ struct PointLight {
16
16
  vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
17
17
  };
18
18
 
19
+ struct SpotLight {
20
+ vec3 color;
21
+ vec3 position;
22
+ vec3 direction;
23
+ vec3 attenuation;
24
+ vec2 coneCos;
25
+ };
26
+
19
27
  struct DirectionalLight {
20
28
  vec3 color;
21
29
  vec3 direction;
22
30
  };
23
31
 
32
+ struct UniformLight {
33
+ vec3 color;
34
+ vec3 position;
35
+ vec3 direction;
36
+ vec3 attenuation;
37
+ vec2 coneCos;
38
+ };
39
+
24
40
  uniform lightingUniforms {
25
41
  int enabled;
26
- int lightType;
27
-
28
42
  int directionalLightCount;
29
43
  int pointLightCount;
30
-
44
+ int spotLightCount;
31
45
  vec3 ambientColor;
32
-
33
- vec3 lightColor0;
34
- vec3 lightPosition0;
35
- vec3 lightDirection0;
36
- vec3 lightAttenuation0;
37
-
38
- vec3 lightColor1;
39
- vec3 lightPosition1;
40
- vec3 lightDirection1;
41
- vec3 lightAttenuation1;
42
-
43
- vec3 lightColor2;
44
- vec3 lightPosition2;
45
- vec3 lightDirection2;
46
- vec3 lightAttenuation2;
46
+ UniformLight lights[5];
47
47
  } lighting;
48
48
 
49
49
  PointLight lighting_getPointLight(int index) {
50
- switch (index) {
51
- case 0:
52
- return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
53
- case 1:
54
- return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
55
- case 2:
56
- default:
57
- return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
58
- }
50
+ UniformLight light = lighting.lights[index];
51
+ return PointLight(light.color, light.position, light.attenuation);
52
+ }
53
+
54
+ SpotLight lighting_getSpotLight(int index) {
55
+ UniformLight light = lighting.lights[lighting.pointLightCount + index];
56
+ return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
59
57
  }
60
58
 
61
59
  DirectionalLight lighting_getDirectionalLight(int index) {
62
- switch (index) {
63
- case 0:
64
- return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
65
- case 1:
66
- return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
67
- case 2:
68
- default:
69
- return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
70
- }
71
- }
60
+ UniformLight light =
61
+ lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
62
+ return DirectionalLight(light.color, light.direction);
63
+ }
72
64
 
73
65
  float getPointLightAttenuation(PointLight pointLight, float distance) {
74
66
  return pointLight.attenuation.x
@@ -76,5 +68,19 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
76
68
  + pointLight.attenuation.z * distance * distance;
77
69
  }
78
70
 
71
+ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
72
+ vec3 light_direction = normalize(positionWorldspace - spotLight.position);
73
+ float coneFactor = smoothstep(
74
+ spotLight.coneCos.y,
75
+ spotLight.coneCos.x,
76
+ dot(normalize(spotLight.direction), light_direction)
77
+ );
78
+ float distanceAttenuation = getPointLightAttenuation(
79
+ PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
80
+ distance(spotLight.position, positionWorldspace)
81
+ );
82
+ return distanceAttenuation / max(coneFactor, 0.0001);
83
+ }
84
+
79
85
  // #endif
80
86
  `;
@@ -4,6 +4,8 @@
4
4
 
5
5
  export const lightingUniformsWGSL = /* wgsl */ `\
6
6
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
7
+ const MAX_LIGHTS: i32 = 5;
8
+
7
9
  struct AmbientLight {
8
10
  color: vec3<f32>,
9
11
  };
@@ -14,44 +16,70 @@ struct PointLight {
14
16
  attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
15
17
  };
16
18
 
19
+ struct SpotLight {
20
+ color: vec3<f32>,
21
+ position: vec3<f32>,
22
+ direction: vec3<f32>,
23
+ attenuation: vec3<f32>,
24
+ coneCos: vec2<f32>,
25
+ };
26
+
17
27
  struct DirectionalLight {
18
28
  color: vec3<f32>,
19
29
  direction: vec3<f32>,
20
30
  };
21
31
 
32
+ struct UniformLight {
33
+ color: vec3<f32>,
34
+ position: vec3<f32>,
35
+ direction: vec3<f32>,
36
+ attenuation: vec3<f32>,
37
+ coneCos: vec2<f32>,
38
+ };
39
+
22
40
  struct lightingUniforms {
23
41
  enabled: i32,
24
- pointLightCount: i32,
25
42
  directionalLightCount: i32,
26
-
43
+ pointLightCount: i32,
44
+ spotLightCount: i32,
27
45
  ambientColor: vec3<f32>,
28
-
29
- // TODO - support multiple lights by uncommenting arrays below
30
- lightType: i32,
31
- lightColor: vec3<f32>,
32
- lightDirection: vec3<f32>,
33
- lightPosition: vec3<f32>,
34
- lightAttenuation: vec3<f32>,
35
-
36
- // AmbientLight ambientLight;
37
- // PointLight pointLight[MAX_LIGHTS];
38
- // DirectionalLight directionalLight[MAX_LIGHTS];
46
+ lights: array<UniformLight, 5>,
39
47
  };
40
48
 
41
- // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
42
- @binding(1) @group(0) var<uniform> lighting : lightingUniforms;
49
+ @group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
43
50
 
44
51
  fn lighting_getPointLight(index: i32) -> PointLight {
45
- return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
52
+ let light = lighting.lights[index];
53
+ return PointLight(light.color, light.position, light.attenuation);
54
+ }
55
+
56
+ fn lighting_getSpotLight(index: i32) -> SpotLight {
57
+ let light = lighting.lights[lighting.pointLightCount + index];
58
+ return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
46
59
  }
47
60
 
48
61
  fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
49
- return DirectionalLight(lighting.lightColor, lighting.lightDirection);
50
- }
62
+ let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
63
+ return DirectionalLight(light.color, light.direction);
64
+ }
51
65
 
52
66
  fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
53
67
  return pointLight.attenuation.x
54
68
  + pointLight.attenuation.y * distance
55
69
  + pointLight.attenuation.z * distance * distance;
56
70
  }
71
+
72
+ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
73
+ let lightDirection = normalize(positionWorldspace - spotLight.position);
74
+ let coneFactor = smoothstep(
75
+ spotLight.coneCos.y,
76
+ spotLight.coneCos.x,
77
+ dot(normalize(spotLight.direction), lightDirection)
78
+ );
79
+ let distanceAttenuation = getPointLightAttenuation(
80
+ PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
81
+ distance(spotLight.position, positionWorldspace)
82
+ );
83
+ return distanceAttenuation / max(coneFactor, 0.0001);
84
+ }
57
85
  `;