@luma.gl/shadertools 9.1.0-alpha.1 → 9.1.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 (232) hide show
  1. package/dist/dist.dev.js +816 -483
  2. package/dist/dist.min.js +2325 -1622
  3. package/dist/index.cjs +2669 -1808
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +29 -28
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +8 -12
  8. package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
  9. package/dist/lib/glsl-utils/shader-utils.js +2 -3
  10. package/dist/lib/shader-assembler.d.ts +3 -4
  11. package/dist/lib/shader-assembler.d.ts.map +1 -1
  12. package/dist/lib/shader-assembler.js +3 -2
  13. package/dist/lib/shader-assembly/assemble-shaders.d.ts +4 -3
  14. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  15. package/dist/lib/shader-assembly/assemble-shaders.js +43 -16
  16. package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -1
  17. package/dist/lib/shader-assembly/platform-defines.js +14 -6
  18. package/dist/lib/shader-module/shader-module-dependencies.d.ts +53 -0
  19. package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
  20. package/dist/lib/{shader-assembly/resolve-modules.js → shader-module/shader-module-dependencies.js} +38 -14
  21. package/dist/lib/shader-module/shader-module.d.ts +29 -11
  22. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  23. package/dist/lib/shader-module/shader-module.js +76 -6
  24. package/dist/lib/shader-module/shader-pass.d.ts +3 -2
  25. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  26. package/dist/module-injectors.d.ts +2 -2
  27. package/dist/module-injectors.d.ts.map +1 -1
  28. package/dist/module-injectors.js +13 -10
  29. package/dist/modules/engine/geometry/geometry.d.ts.map +1 -1
  30. package/dist/modules/engine/geometry/geometry.js +12 -8
  31. package/dist/modules/engine/picking/picking.d.ts +4 -4
  32. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  33. package/dist/modules/engine/picking/picking.js +103 -66
  34. package/dist/modules/engine/project/project.d.ts +2 -2
  35. package/dist/modules/engine/project/project.d.ts.map +1 -1
  36. package/dist/modules/engine/project/project.js +36 -22
  37. package/dist/modules/engine/transform/transform.d.ts.map +1 -1
  38. package/dist/modules/engine/transform/transform.js +28 -16
  39. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +9 -7
  40. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  41. package/dist/modules/lighting/gouraud-material/gouraud-material.js +2 -0
  42. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +2 -2
  43. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
  44. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +79 -53
  45. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  46. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  47. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +38 -23
  48. package/dist/modules/lighting/lights/lighting.d.ts +4 -4
  49. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  50. package/dist/modules/lighting/lights/lighting.js +2 -2
  51. package/dist/modules/lighting/no-material/dirlight.d.ts +4 -4
  52. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  53. package/dist/modules/lighting/no-material/dirlight.js +12 -9
  54. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
  55. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  56. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +304 -181
  57. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +71 -69
  58. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  59. package/dist/modules/lighting/pbr-material/pbr-material.js +4 -2
  60. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +1 -1
  61. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -1
  62. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +38 -20
  63. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
  64. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  65. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +21 -16
  66. package/dist/modules/lighting/phong-material/phong-material.d.ts +12 -12
  67. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  68. package/dist/modules/lighting/phong-material/phong-material.js +3 -3
  69. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  70. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  71. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +82 -54
  72. package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
  73. package/dist/modules/math/fp32/fp32.js +127 -100
  74. package/dist/modules/math/random/random.d.ts +1 -1
  75. package/dist/modules/math/random/random.d.ts.map +1 -1
  76. package/dist/modules/math/random/random.js +3 -3
  77. package/dist/modules/module-injectors.d.ts +2 -2
  78. package/dist/modules/module-injectors.d.ts.map +1 -1
  79. package/dist/modules/module-injectors.js +13 -10
  80. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +4 -1
  81. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  82. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +16 -12
  83. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +4 -1
  84. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  85. package/dist/modules/postprocessing/image-adjust-filters/denoise.js +21 -17
  86. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +5 -2
  87. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  88. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +29 -22
  89. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +4 -1
  90. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  91. package/dist/modules/postprocessing/image-adjust-filters/noise.js +14 -10
  92. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +4 -1
  93. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  94. package/dist/modules/postprocessing/image-adjust-filters/sepia.js +17 -12
  95. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +4 -1
  96. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  97. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +12 -9
  98. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +4 -1
  99. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  100. package/dist/modules/postprocessing/image-adjust-filters/vignette.js +13 -10
  101. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +5 -2
  102. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  103. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +40 -26
  104. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +5 -2
  105. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  106. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +32 -19
  107. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +4 -1
  108. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  109. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +2 -0
  110. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +4 -1
  111. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  112. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +31 -27
  113. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +4 -1
  114. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  115. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +19 -15
  116. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +8 -5
  117. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  118. package/dist/modules/postprocessing/image-fun-filters/edgework.js +53 -42
  119. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +4 -1
  120. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  121. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +41 -33
  122. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +4 -1
  123. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
  124. package/dist/modules/postprocessing/image-fun-filters/ink.js +27 -25
  125. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -1
  126. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  127. package/dist/modules/postprocessing/image-fun-filters/magnify.js +17 -16
  128. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -2
  129. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  130. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +24 -20
  131. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +5 -2
  132. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
  133. package/dist/modules/postprocessing/image-warp-filters/swirl.js +26 -22
  134. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +2 -1
  135. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
  136. package/dist/modules/postprocessing/image-warp-filters/warp.js +9 -8
  137. package/dist/modules-webgl1/geometry/geometry.d.ts.map +1 -1
  138. package/dist/modules-webgl1/geometry/geometry.js +12 -8
  139. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
  140. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +8 -5
  141. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +1 -1
  142. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -1
  143. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +19 -11
  144. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +1 -1
  145. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -1
  146. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +268 -157
  147. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +1 -1
  148. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -1
  149. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +16 -12
  150. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +1 -1
  151. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -1
  152. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +64 -55
  153. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  154. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  155. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +113 -81
  156. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +1 -1
  157. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -1
  158. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +588 -433
  159. package/dist/modules-webgl1/project/project.d.ts +2 -2
  160. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  161. package/dist/modules-webgl1/project/project.js +5 -4
  162. package/package.json +2 -2
  163. package/src/index.ts +78 -32
  164. package/src/lib/glsl-utils/shader-utils.ts +1 -3
  165. package/src/lib/shader-assembler.ts +7 -8
  166. package/src/lib/shader-assembly/assemble-shaders.ts +52 -20
  167. package/src/lib/shader-assembly/platform-defines.ts +5 -6
  168. package/src/lib/shader-module/shader-module-dependencies.ts +112 -0
  169. package/src/lib/shader-module/shader-module.ts +129 -18
  170. package/src/lib/shader-module/shader-pass.ts +3 -2
  171. package/src/module-injectors.ts +2 -4
  172. package/src/modules/engine/geometry/geometry.ts +2 -3
  173. package/src/modules/engine/picking/picking.ts +7 -5
  174. package/src/modules/engine/project/project.ts +2 -3
  175. package/src/modules/engine/transform/transform.ts +1 -3
  176. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  177. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +2 -4
  178. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +1 -3
  179. package/src/modules/lighting/lights/lighting.ts +4 -2
  180. package/src/modules/lighting/no-material/dirlight.ts +6 -5
  181. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +1 -2
  182. package/src/modules/lighting/pbr-material/pbr-material.ts +44 -38
  183. package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +1 -3
  184. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +1 -3
  185. package/src/modules/lighting/phong-material/phong-material.ts +4 -3
  186. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -4
  187. package/src/modules/math/fp32/fp32.ts +1 -2
  188. package/src/modules/math/random/random.ts +1 -2
  189. package/src/modules/module-injectors.ts +2 -4
  190. package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -2
  191. package/src/modules/postprocessing/image-adjust-filters/denoise.ts +7 -3
  192. package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +9 -4
  193. package/src/modules/postprocessing/image-adjust-filters/noise.ts +6 -2
  194. package/src/modules/postprocessing/image-adjust-filters/sepia.ts +6 -2
  195. package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +5 -2
  196. package/src/modules/postprocessing/image-adjust-filters/vignette.ts +11 -4
  197. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +6 -2
  198. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +6 -2
  199. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +5 -0
  200. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +6 -2
  201. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +6 -2
  202. package/src/modules/postprocessing/image-fun-filters/edgework.ts +10 -4
  203. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +6 -2
  204. package/src/modules/postprocessing/image-fun-filters/ink.ts +8 -3
  205. package/src/modules/postprocessing/image-fun-filters/magnify.ts +3 -2
  206. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +6 -2
  207. package/src/modules/postprocessing/image-warp-filters/swirl.ts +8 -2
  208. package/src/modules/postprocessing/image-warp-filters/warp.ts +3 -2
  209. package/src/modules-webgl1/geometry/geometry.ts +2 -3
  210. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +1 -2
  211. package/src/modules-webgl1/lighting/lights/lights-glsl.ts +1 -3
  212. package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +1 -2
  213. package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +1 -3
  214. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +1 -3
  215. package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +1 -3
  216. package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +1 -3
  217. package/src/modules-webgl1/project/project.ts +1 -2
  218. package/dist/lib/glsl-utils/highlight.d.ts +0 -6
  219. package/dist/lib/glsl-utils/highlight.d.ts.map +0 -1
  220. package/dist/lib/glsl-utils/highlight.js +0 -9
  221. package/dist/lib/shader-assembly/resolve-modules.d.ts +0 -40
  222. package/dist/lib/shader-assembly/resolve-modules.d.ts.map +0 -1
  223. package/dist/lib/shader-module/normalize-shader-module.d.ts +0 -3
  224. package/dist/lib/shader-module/normalize-shader-module.d.ts.map +0 -1
  225. package/dist/lib/shader-module/normalize-shader-module.js +0 -14
  226. package/dist/lib/shader-module/shader-module-instance.d.ts +0 -28
  227. package/dist/lib/shader-module/shader-module-instance.d.ts.map +0 -1
  228. package/dist/lib/shader-module/shader-module-instance.js +0 -126
  229. package/src/lib/glsl-utils/highlight.ts +0 -11
  230. package/src/lib/shader-assembly/resolve-modules.ts +0 -81
  231. package/src/lib/shader-module/normalize-shader-module.ts +0 -17
  232. package/src/lib/shader-module/shader-module-instance.ts +0 -167
@@ -3,9 +3,8 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {ShaderPass} from '../../../lib/shader-module/shader-pass';
6
- import {glsl} from '../../../lib/glsl-utils/highlight';
7
6
 
8
- const fs = glsl`\
7
+ const fs = /* glsl */ `\
9
8
  vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
10
9
  vec4 color = texture(source, coord / texSize);
11
10
  vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
@@ -20,6 +19,8 @@ vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
20
19
 
21
20
  export type WarpProps = {};
22
21
 
22
+ export type WarpUniforms = WarpProps;
23
+
23
24
  export const warp = {
24
25
  name: 'warp',
25
26
  passes: [],
@@ -1,8 +1,7 @@
1
1
  // import {ShaderModule} from '../../types';
2
- import {glsl} from '../../lib/glsl-utils/highlight';
3
2
 
4
3
  // TODO - reuse normal from geometry module
5
- const vs = glsl`\
4
+ const vs = /* glsl */ `\
6
5
  varying vec4 geometry_vPosition;
7
6
  varying vec3 geometry_vNormal;
8
7
 
@@ -19,7 +18,7 @@ void geometry_setPosition(vec3 position) {
19
18
  }
20
19
  `;
21
20
 
22
- const fs = glsl`\
21
+ const fs = /* glsl */ `\
23
22
  varying vec4 geometry_vPosition;
24
23
  varying vec3 geometry_vNormal;
25
24
 
@@ -3,7 +3,6 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
6
- import {glsl} from '../../../lib/glsl-utils/highlight';
7
6
  import type {NumberArray} from '../../../types';
8
7
  import {project} from '../../project/project';
9
8
 
@@ -26,7 +25,7 @@ function getUniforms(opts: DirlightOptions = DEFAULT_MODULE_OPTIONS): Record<str
26
25
  return uniforms;
27
26
  }
28
27
 
29
- const fs = glsl`\
28
+ const fs = /* glsl */ `\
30
29
  uniform vec3 dirlight_uLightDirection;
31
30
 
32
31
  /*
@@ -2,9 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {glsl} from '../../../lib/glsl-utils/highlight';
6
-
7
- export const lightingShader = glsl`\
5
+ export const lightingShader = /* glsl */ `\
8
6
  #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
9
7
 
10
8
  struct AmbientLight {
@@ -10,9 +10,8 @@
10
10
  //
11
11
 
12
12
  // TODO - better do the checks outside of shader
13
- import {glsl} from '../../../lib/glsl-utils/highlight';
14
13
 
15
- export const fs = glsl`\
14
+ export const fs = /* glsl */ `\
16
15
  precision highp float;
17
16
 
18
17
  uniform bool pbr_uUnlit;
@@ -2,9 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {glsl} from '../../../lib/glsl-utils/highlight';
6
-
7
- export const vs = glsl`\
5
+ export const vs = /* glsl */ `\
8
6
  uniform mat4 u_MVPMatrix;
9
7
  uniform mat4 u_ModelMatrix;
10
8
  uniform mat4 u_NormalMatrix;
@@ -2,9 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {glsl} from '../../../lib/glsl-utils/highlight';
6
-
7
- export const lightingShader = glsl`\
5
+ export const lightingShader = /* glsl */ `\
8
6
 
9
7
  uniform float lighting_uAmbient;
10
8
  uniform float lighting_uDiffuse;
@@ -2,9 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {glsl} from '../../../lib/glsl-utils/highlight';
6
-
7
- export const fp64arithmeticShader = glsl`\
5
+ export const fp64arithmeticShader = /* glsl */ `\
8
6
  uniform float ONE;
9
7
 
10
8
  /*
@@ -2,9 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {glsl} from '../../../lib/glsl-utils/highlight';
6
-
7
- export const fp64functionShader = glsl`\
5
+ export const fp64functionShader = /* glsl */ `\
8
6
  const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
9
7
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
10
8
  const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
@@ -3,7 +3,6 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Matrix4} from '@math.gl/core';
6
- import {glsl} from '../../lib/glsl-utils/highlight';
7
6
  import {ShaderModule} from '../../lib/shader-module/shader-module';
8
7
 
9
8
  type ProjectionProps = {
@@ -51,7 +50,7 @@ function getUniforms(opts: ProjectionProps = DEFAULT_MODULE_OPTIONS, prevUniform
51
50
  return uniforms;
52
51
  }
53
52
 
54
- const common = glsl`\
53
+ const common = /* glsl */ `\
55
54
  varying vec4 project_vPositionWorld;
56
55
  varying vec3 project_vNormalWorld;
57
56
 
@@ -1,6 +0,0 @@
1
- /**
2
- * Marks GLSL shaders for syntax highlighting: glsl`...`
3
- * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
4
- */
5
- export declare const glsl: (x: TemplateStringsArray) => string;
6
- //# sourceMappingURL=highlight.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../src/lib/glsl-utils/highlight.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,IAAI,MAAO,oBAAoB,WAAW,CAAC"}
@@ -1,9 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- // SHADER HELPERS
5
- /**
6
- * Marks GLSL shaders for syntax highlighting: glsl`...`
7
- * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
8
- */
9
- export const glsl = (x) => `${x}`;
@@ -1,40 +0,0 @@
1
- import type { ShaderModule } from "../shader-module/shader-module.js";
2
- import { ShaderModuleInstance } from "../shader-module/shader-module-instance.js";
3
- /**
4
- * Instantiate shader modules and esolve any dependencies
5
- */
6
- export declare function resolveModules(modules: (ShaderModule | ShaderModuleInstance)[]): ShaderModuleInstance[];
7
- /**
8
- * Takes a list of shader module names and returns a new list of
9
- * shader module names that includes all dependencies, sorted so
10
- * that modules that are dependencies of other modules come first.
11
- *
12
- * If the shader glsl code from the returned modules is concatenated
13
- * in the reverse order, it is guaranteed that all functions be resolved and
14
- * that all function and variable definitions come before use.
15
- *
16
- * @param modules - Array of modules (inline modules or module names)
17
- * @return - Array of modules
18
- */
19
- declare function getShaderDependencies(modules: ShaderModuleInstance[]): ShaderModuleInstance[];
20
- /**
21
- * Recursively checks module dependencies to calculate dependency level of each module.
22
- *
23
- * @param options.modules - Array of modules
24
- * @param options.level - Current level
25
- * @param options.moduleMap -
26
- * @param options.moduleDepth - Current level
27
- * @return - Map of module name to its level
28
- */
29
- export declare function getDependencyGraph(options: {
30
- modules: ShaderModuleInstance[];
31
- level: number;
32
- moduleMap: Record<string, ShaderModuleInstance>;
33
- moduleDepth: Record<string, number>;
34
- }): void;
35
- export declare const TEST_EXPORTS: {
36
- getShaderDependencies: typeof getShaderDependencies;
37
- getDependencyGraph: typeof getDependencyGraph;
38
- };
39
- export {};
40
- //# sourceMappingURL=resolve-modules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-modules.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-assembly/resolve-modules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,0CAAuC;AACjE,OAAO,EAAC,oBAAoB,EAAC,mDAAgD;AAE7E;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,YAAY,GAAG,oBAAoB,CAAC,EAAE,GAC/C,oBAAoB,EAAE,CAGxB;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CAStF;AAED;;;;;;;;GAQG;AAEH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,QAoBA;AAED,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
@@ -1,3 +0,0 @@
1
- import { ShaderModule } from "./shader-module.js";
2
- export declare function normalizeShaderModule(module: ShaderModule): ShaderModule;
3
- //# sourceMappingURL=normalize-shader-module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/normalize-shader-module.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAG7C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CASxE"}
@@ -1,14 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { ShaderModuleInstance } from "./shader-module-instance.js";
5
- export function normalizeShaderModule(module) {
6
- if (!module.normalized) {
7
- module.normalized = true;
8
- if (module.uniformPropTypes && !module.getUniforms) {
9
- const shaderModule = new ShaderModuleInstance(module);
10
- module.getUniforms = shaderModule.getUniforms.bind(shaderModule);
11
- }
12
- }
13
- return module;
14
- }
@@ -1,28 +0,0 @@
1
- import { PropValidator } from "../filters/prop-types.js";
2
- import { ShaderModule, ShaderModuleDeprecation } from "./shader-module.js";
3
- import { ShaderInjection } from "../shader-assembly/shader-injections.js";
4
- /** An initialized ShaderModule, ready to use with `assembleShaders()` */
5
- export declare class ShaderModuleInstance {
6
- name: string;
7
- vs?: string;
8
- fs?: string;
9
- getModuleUniforms: Function;
10
- dependencies: ShaderModuleInstance[];
11
- deprecations: ShaderModuleDeprecation[];
12
- defines: Record<string, string | number>;
13
- injections: {
14
- vertex: Record<string, ShaderInjection>;
15
- fragment: Record<string, ShaderInjection>;
16
- };
17
- uniforms: Record<string, PropValidator>;
18
- uniformTypes: Record<string, PropValidator>;
19
- static instantiateModules(modules: (ShaderModule | ShaderModuleInstance)[]): ShaderModuleInstance[];
20
- constructor(props: ShaderModule);
21
- getModuleSource(stage: 'vertex' | 'fragment'): string;
22
- getUniforms(userProps: Record<string, any>, uniforms: Record<string, any>): Record<string, any>;
23
- getDefines(): Record<string, string | number>;
24
- checkDeprecations(shaderSource: string, log: any): void;
25
- _parseDeprecationDefinitions(deprecations: ShaderModuleDeprecation[]): ShaderModuleDeprecation[];
26
- _defaultGetUniforms(opts?: Record<string, any>): Record<string, any>;
27
- }
28
- //# sourceMappingURL=shader-module-instance.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader-module-instance.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module-instance.ts"],"names":[],"mappings":"AAKA,OAAO,EAA6C,aAAa,EAAC,iCAA8B;AAChG,OAAO,EAAC,YAAY,EAAE,uBAAuB,EAAC,2BAAwB;AACtE,OAAO,EAAC,eAAe,EAAsB,gDAA6C;AAI1F,yEAAyE;AACzE,qBAAa,oBAAoB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,YAAY,EAAE,uBAAuB,EAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;KAC3C,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAM;IAC7C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAM;IAEjD,MAAM,CAAC,kBAAkB,CACvB,OAAO,EAAE,CAAC,YAAY,GAAG,oBAAoB,CAAC,EAAE,GAC/C,oBAAoB,EAAE;gBA2Bb,KAAK,EAAE,YAAY;IA6B/B,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM;IAwBrD,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAQ/F,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAK7C,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI;IAYvD,4BAA4B,CAAC,YAAY,EAAE,uBAAuB,EAAE;IAcpE,mBAAmB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAkBzE"}
@@ -1,126 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { assert } from "../utils/assert.js";
5
- import { makePropValidators, getValidatedProperties } from "../filters/prop-types.js";
6
- import { normalizeInjections } from "../shader-assembly/shader-injections.js";
7
- let index = 1;
8
- /** An initialized ShaderModule, ready to use with `assembleShaders()` */
9
- export class ShaderModuleInstance {
10
- name;
11
- vs;
12
- fs;
13
- getModuleUniforms;
14
- dependencies;
15
- deprecations;
16
- defines;
17
- injections;
18
- uniforms = {};
19
- uniformTypes = {};
20
- static instantiateModules(modules) {
21
- return modules.map((module) => {
22
- if (module instanceof ShaderModuleInstance) {
23
- return module;
24
- }
25
- assert(typeof module !== 'string', `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
26
- if (!module.name) {
27
- // eslint-disable-next-line no-console
28
- console.warn('shader module has no name');
29
- module.name = `shader-module-${index++}`;
30
- }
31
- const moduleObject = new ShaderModuleInstance(module);
32
- moduleObject.dependencies = ShaderModuleInstance.instantiateModules(module.dependencies || []);
33
- return moduleObject;
34
- });
35
- }
36
- constructor(props) {
37
- const { name, vs, fs, dependencies = [], uniformPropTypes = {}, getUniforms, deprecations = [], defines = {}, inject = {} } = props;
38
- assert(typeof name === 'string');
39
- this.name = name;
40
- this.vs = vs;
41
- this.fs = fs;
42
- this.getModuleUniforms = getUniforms;
43
- this.dependencies = ShaderModuleInstance.instantiateModules(dependencies);
44
- this.deprecations = this._parseDeprecationDefinitions(deprecations);
45
- this.defines = defines;
46
- this.injections = normalizeInjections(inject);
47
- if (uniformPropTypes) {
48
- this.uniforms = makePropValidators(uniformPropTypes);
49
- }
50
- }
51
- // Extracts the source code chunk for the specified shader type from the named shader module
52
- getModuleSource(stage) {
53
- let moduleSource;
54
- switch (stage) {
55
- case 'vertex':
56
- moduleSource = this.vs || '';
57
- break;
58
- case 'fragment':
59
- moduleSource = this.fs || '';
60
- break;
61
- default:
62
- assert(false);
63
- }
64
- const moduleName = this.name.toUpperCase().replace(/[^0-9a-z]/gi, '_');
65
- return `\
66
- // ----- MODULE ${this.name} ---------------
67
-
68
- #define MODULE_${moduleName}
69
- ${moduleSource}\
70
-
71
-
72
- `;
73
- }
74
- getUniforms(userProps, uniforms) {
75
- if (this.getModuleUniforms) {
76
- return this.getModuleUniforms(userProps, uniforms);
77
- }
78
- // Build uniforms from the uniforms array
79
- return getValidatedProperties(userProps, this.uniforms, this.name);
80
- }
81
- getDefines() {
82
- return this.defines;
83
- }
84
- // Warn about deprecated uniforms or functions
85
- checkDeprecations(shaderSource, log) {
86
- this.deprecations.forEach(def => {
87
- if (def.regex?.test(shaderSource)) {
88
- if (def.deprecated) {
89
- log.deprecated(def.old, def.new)();
90
- }
91
- else {
92
- log.removed(def.old, def.new)();
93
- }
94
- }
95
- });
96
- }
97
- _parseDeprecationDefinitions(deprecations) {
98
- deprecations.forEach(def => {
99
- switch (def.type) {
100
- case 'function':
101
- def.regex = new RegExp(`\\b${def.old}\\(`);
102
- break;
103
- default:
104
- def.regex = new RegExp(`${def.type} ${def.old};`);
105
- }
106
- });
107
- return deprecations;
108
- }
109
- _defaultGetUniforms(opts = {}) {
110
- const uniforms = {};
111
- const propTypes = this.uniforms;
112
- for (const key in propTypes) {
113
- const propDef = propTypes[key];
114
- if (key in opts && !propDef.private) {
115
- if (propDef.validate) {
116
- assert(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
117
- }
118
- uniforms[key] = opts[key];
119
- }
120
- else {
121
- uniforms[key] = propDef.value;
122
- }
123
- }
124
- return uniforms;
125
- }
126
- }
@@ -1,11 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- // SHADER HELPERS
6
-
7
- /**
8
- * Marks GLSL shaders for syntax highlighting: glsl`...`
9
- * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
10
- */
11
- export const glsl = (x: TemplateStringsArray) => `${x}`;
@@ -1,81 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import type {ShaderModule} from '../shader-module/shader-module';
6
- import {ShaderModuleInstance} from '../shader-module/shader-module-instance';
7
-
8
- /**
9
- * Instantiate shader modules and esolve any dependencies
10
- */
11
- export function resolveModules(
12
- modules: (ShaderModule | ShaderModuleInstance)[]
13
- ): ShaderModuleInstance[] {
14
- const instances = ShaderModuleInstance.instantiateModules(modules);
15
- return getShaderDependencies(instances);
16
- }
17
-
18
- /**
19
- * Takes a list of shader module names and returns a new list of
20
- * shader module names that includes all dependencies, sorted so
21
- * that modules that are dependencies of other modules come first.
22
- *
23
- * If the shader glsl code from the returned modules is concatenated
24
- * in the reverse order, it is guaranteed that all functions be resolved and
25
- * that all function and variable definitions come before use.
26
- *
27
- * @param modules - Array of modules (inline modules or module names)
28
- * @return - Array of modules
29
- */
30
- function getShaderDependencies(modules: ShaderModuleInstance[]): ShaderModuleInstance[] {
31
- const moduleMap: Record<string, ShaderModuleInstance> = {};
32
- const moduleDepth: Record<string, number> = {};
33
- getDependencyGraph({modules, level: 0, moduleMap, moduleDepth});
34
-
35
- // Return a reverse sort so that dependencies come before the modules that use them
36
- return Object.keys(moduleDepth)
37
- .sort((a, b) => moduleDepth[b] - moduleDepth[a])
38
- .map(name => moduleMap[name]);
39
- }
40
-
41
- /**
42
- * Recursively checks module dependencies to calculate dependency level of each module.
43
- *
44
- * @param options.modules - Array of modules
45
- * @param options.level - Current level
46
- * @param options.moduleMap -
47
- * @param options.moduleDepth - Current level
48
- * @return - Map of module name to its level
49
- */
50
- // Adds another level of dependencies to the result map
51
- export function getDependencyGraph(options: {
52
- modules: ShaderModuleInstance[];
53
- level: number;
54
- moduleMap: Record<string, ShaderModuleInstance>;
55
- moduleDepth: Record<string, number>;
56
- }) {
57
- const {modules, level, moduleMap, moduleDepth} = options;
58
- if (level >= 5) {
59
- throw new Error('Possible loop in shader dependency graph');
60
- }
61
-
62
- // Update level on all current modules
63
- for (const module of modules) {
64
- moduleMap[module.name] = module;
65
- if (moduleDepth[module.name] === undefined || moduleDepth[module.name] < level) {
66
- moduleDepth[module.name] = level;
67
- }
68
- }
69
-
70
- // Recurse
71
- for (const module of modules) {
72
- if (module.dependencies) {
73
- getDependencyGraph({modules: module.dependencies, level: level + 1, moduleMap, moduleDepth});
74
- }
75
- }
76
- }
77
-
78
- export const TEST_EXPORTS = {
79
- getShaderDependencies,
80
- getDependencyGraph
81
- };
@@ -1,17 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import {ShaderModule} from './shader-module';
6
- import {ShaderModuleInstance} from './shader-module-instance';
7
-
8
- export function normalizeShaderModule(module: ShaderModule): ShaderModule {
9
- if (!module.normalized) {
10
- module.normalized = true;
11
- if (module.uniformPropTypes && !module.getUniforms) {
12
- const shaderModule = new ShaderModuleInstance(module);
13
- module.getUniforms = shaderModule.getUniforms.bind(shaderModule);
14
- }
15
- }
16
- return module;
17
- }