@luma.gl/shaders 0.0.0-stage → 10.0.0-alpha.6

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 (693) hide show
  1. package/LICENSE +38 -0
  2. package/README.md +25 -2
  3. package/dist/dist.dev.js +19686 -0
  4. package/dist/dist.min.js +12180 -0
  5. package/dist/glsl.cjs +33 -0
  6. package/dist/glsl.cjs.map +6 -0
  7. package/dist/glsl.d.ts +6 -0
  8. package/dist/glsl.d.ts.map +1 -0
  9. package/dist/glsl.js +7 -0
  10. package/dist/glsl.js.map +1 -0
  11. package/dist/index.cjs +243 -0
  12. package/dist/index.cjs.map +6 -0
  13. package/dist/index.d.ts +91 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +65 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/lib/color/normalize-byte-colors.cjs +50 -0
  18. package/dist/lib/color/normalize-byte-colors.d.ts +23 -0
  19. package/dist/lib/color/normalize-byte-colors.d.ts.map +1 -0
  20. package/dist/lib/color/normalize-byte-colors.js +42 -0
  21. package/dist/lib/color/normalize-byte-colors.js.map +1 -0
  22. package/dist/lib/filters/prop-types.cjs +90 -0
  23. package/dist/lib/filters/prop-types.d.ts +44 -0
  24. package/dist/lib/filters/prop-types.d.ts.map +1 -0
  25. package/dist/lib/filters/prop-types.js +96 -0
  26. package/dist/lib/filters/prop-types.js.map +1 -0
  27. package/dist/lib/glsl-shader-assembler.cjs +50 -0
  28. package/dist/lib/glsl-shader-assembler.d.ts +19 -0
  29. package/dist/lib/glsl-shader-assembler.d.ts.map +1 -0
  30. package/dist/lib/glsl-shader-assembler.js +29 -0
  31. package/dist/lib/glsl-shader-assembler.js.map +1 -0
  32. package/dist/lib/glsl-utils/get-shader-info.cjs +52 -0
  33. package/dist/lib/glsl-utils/get-shader-info.d.ts +9 -0
  34. package/dist/lib/glsl-utils/get-shader-info.d.ts.map +1 -0
  35. package/dist/lib/glsl-utils/get-shader-info.js +33 -0
  36. package/dist/lib/glsl-utils/get-shader-info.js.map +1 -0
  37. package/dist/lib/glsl-utils/shader-utils.cjs +126 -0
  38. package/dist/lib/glsl-utils/shader-utils.d.ts +23 -0
  39. package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -0
  40. package/dist/lib/glsl-utils/shader-utils.js +92 -0
  41. package/dist/lib/glsl-utils/shader-utils.js.map +1 -0
  42. package/dist/lib/preprocessor/preprocessor.cjs +107 -0
  43. package/dist/lib/preprocessor/preprocessor.d.ts +15 -0
  44. package/dist/lib/preprocessor/preprocessor.d.ts.map +1 -0
  45. package/dist/lib/preprocessor/preprocessor.js +99 -0
  46. package/dist/lib/preprocessor/preprocessor.js.map +1 -0
  47. package/dist/lib/shader-assembler-base.cjs +133 -0
  48. package/dist/lib/shader-assembler-base.d.ts +52 -0
  49. package/dist/lib/shader-assembler-base.d.ts.map +1 -0
  50. package/dist/lib/shader-assembler-base.js +128 -0
  51. package/dist/lib/shader-assembler-base.js.map +1 -0
  52. package/dist/lib/shader-assembler.cjs +33 -0
  53. package/dist/lib/shader-assembler.d.ts +4 -0
  54. package/dist/lib/shader-assembler.d.ts.map +1 -0
  55. package/dist/lib/shader-assembler.js +7 -0
  56. package/dist/lib/shader-assembler.js.map +1 -0
  57. package/dist/lib/shader-assembly/assemble-glsl-shaders.cjs +200 -0
  58. package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts +69 -0
  59. package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts.map +1 -0
  60. package/dist/lib/shader-assembly/assemble-glsl-shaders.js +221 -0
  61. package/dist/lib/shader-assembly/assemble-glsl-shaders.js.map +1 -0
  62. package/dist/lib/shader-assembly/assemble-shaders.cjs +42 -0
  63. package/dist/lib/shader-assembly/assemble-shaders.d.ts +10 -0
  64. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -0
  65. package/dist/lib/shader-assembly/assemble-shaders.js +10 -0
  66. package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -0
  67. package/dist/lib/shader-assembly/assemble-wgsl-shaders.cjs +501 -0
  68. package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts +71 -0
  69. package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts.map +1 -0
  70. package/dist/lib/shader-assembly/assemble-wgsl-shaders.js +473 -0
  71. package/dist/lib/shader-assembly/assemble-wgsl-shaders.js.map +1 -0
  72. package/dist/lib/shader-assembly/platform-defines.cjs +79 -0
  73. package/dist/lib/shader-assembly/platform-defines.d.ts +4 -0
  74. package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -0
  75. package/dist/lib/shader-assembly/platform-defines.js +52 -0
  76. package/dist/lib/shader-assembly/platform-defines.js.map +1 -0
  77. package/dist/lib/shader-assembly/platform-info.cjs +15 -0
  78. package/dist/lib/shader-assembly/platform-info.d.ts +20 -0
  79. package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -0
  80. package/dist/lib/shader-assembly/platform-info.js +5 -0
  81. package/dist/lib/shader-assembly/platform-info.js.map +1 -0
  82. package/dist/lib/shader-assembly/shader-assembly-shared.cjs +96 -0
  83. package/dist/lib/shader-assembly/shader-assembly-shared.d.ts +16 -0
  84. package/dist/lib/shader-assembly/shader-assembly-shared.d.ts.map +1 -0
  85. package/dist/lib/shader-assembly/shader-assembly-shared.js +79 -0
  86. package/dist/lib/shader-assembly/shader-assembly-shared.js.map +1 -0
  87. package/dist/lib/shader-assembly/shader-assembly-types.cjs +15 -0
  88. package/dist/lib/shader-assembly/shader-assembly-types.d.ts +128 -0
  89. package/dist/lib/shader-assembly/shader-assembly-types.d.ts.map +1 -0
  90. package/dist/lib/shader-assembly/shader-assembly-types.js +5 -0
  91. package/dist/lib/shader-assembly/shader-assembly-types.js.map +1 -0
  92. package/dist/lib/shader-assembly/shader-hooks.cjs +103 -0
  93. package/dist/lib/shader-assembly/shader-hooks.d.ts +45 -0
  94. package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -0
  95. package/dist/lib/shader-assembly/shader-hooks.js +84 -0
  96. package/dist/lib/shader-assembly/shader-hooks.js.map +1 -0
  97. package/dist/lib/shader-assembly/shader-injections.cjs +180 -0
  98. package/dist/lib/shader-assembly/shader-injections.d.ts +34 -0
  99. package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -0
  100. package/dist/lib/shader-assembly/shader-injections.js +183 -0
  101. package/dist/lib/shader-assembly/shader-injections.js.map +1 -0
  102. package/dist/lib/shader-assembly/shader-plugin-varyings.cjs +417 -0
  103. package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts +15 -0
  104. package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts.map +1 -0
  105. package/dist/lib/shader-assembly/shader-plugin-varyings.js +412 -0
  106. package/dist/lib/shader-assembly/shader-plugin-varyings.js.map +1 -0
  107. package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.cjs +254 -0
  108. package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.d.ts +12 -0
  109. package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.d.ts.map +1 -0
  110. package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.js +237 -0
  111. package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.js.map +1 -0
  112. package/dist/lib/shader-assembly/wgsl-binding-debug.cjs +166 -0
  113. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts +37 -0
  114. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts.map +1 -0
  115. package/dist/lib/shader-assembly/wgsl-binding-debug.js +144 -0
  116. package/dist/lib/shader-assembly/wgsl-binding-debug.js.map +1 -0
  117. package/dist/lib/shader-assembly/wgsl-binding-scan.cjs +184 -0
  118. package/dist/lib/shader-assembly/wgsl-binding-scan.d.ts +19 -0
  119. package/dist/lib/shader-assembly/wgsl-binding-scan.d.ts.map +1 -0
  120. package/dist/lib/shader-assembly/wgsl-binding-scan.js +151 -0
  121. package/dist/lib/shader-assembly/wgsl-binding-scan.js.map +1 -0
  122. package/dist/lib/shader-assembly/wgsl-interface-scan.cjs +502 -0
  123. package/dist/lib/shader-assembly/wgsl-interface-scan.d.ts +14 -0
  124. package/dist/lib/shader-assembly/wgsl-interface-scan.d.ts.map +1 -0
  125. package/dist/lib/shader-assembly/wgsl-interface-scan.js +498 -0
  126. package/dist/lib/shader-assembly/wgsl-interface-scan.js.map +1 -0
  127. package/dist/lib/shader-generator/generate-shader.cjs +36 -0
  128. package/dist/lib/shader-generator/generate-shader.d.ts +8 -0
  129. package/dist/lib/shader-generator/generate-shader.d.ts.map +1 -0
  130. package/dist/lib/shader-generator/generate-shader.js +15 -0
  131. package/dist/lib/shader-generator/generate-shader.js.map +1 -0
  132. package/dist/lib/shader-generator/glsl/generate-glsl.cjs +94 -0
  133. package/dist/lib/shader-generator/glsl/generate-glsl.d.ts +7 -0
  134. package/dist/lib/shader-generator/glsl/generate-glsl.d.ts.map +1 -0
  135. package/dist/lib/shader-generator/glsl/generate-glsl.js +79 -0
  136. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -0
  137. package/dist/lib/shader-generator/utils/capitalize.cjs +29 -0
  138. package/dist/lib/shader-generator/utils/capitalize.d.ts +7 -0
  139. package/dist/lib/shader-generator/utils/capitalize.d.ts.map +1 -0
  140. package/dist/lib/shader-generator/utils/capitalize.js +12 -0
  141. package/dist/lib/shader-generator/utils/capitalize.js.map +1 -0
  142. package/dist/lib/shader-generator/wgsl/generate-wgsl.cjs +46 -0
  143. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts +7 -0
  144. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -0
  145. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +23 -0
  146. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -0
  147. package/dist/lib/shader-module/composite-shader-pass.cjs +15 -0
  148. package/dist/lib/shader-module/composite-shader-pass.d.ts +41 -0
  149. package/dist/lib/shader-module/composite-shader-pass.d.ts.map +1 -0
  150. package/dist/lib/shader-module/composite-shader-pass.js +5 -0
  151. package/dist/lib/shader-module/composite-shader-pass.js.map +1 -0
  152. package/dist/lib/shader-module/shader-module-dependencies.cjs +83 -0
  153. package/dist/lib/shader-module/shader-module-dependencies.d.ts +39 -0
  154. package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
  155. package/dist/lib/shader-module/shader-module-dependencies.js +103 -0
  156. package/dist/lib/shader-module/shader-module-dependencies.js.map +1 -0
  157. package/dist/lib/shader-module/shader-module-uniform-layout.cjs +224 -0
  158. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts +91 -0
  159. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts.map +1 -0
  160. package/dist/lib/shader-module/shader-module-uniform-layout.js +253 -0
  161. package/dist/lib/shader-module/shader-module-uniform-layout.js.map +1 -0
  162. package/dist/lib/shader-module/shader-module.cjs +105 -0
  163. package/dist/lib/shader-module/shader-module.d.ts +98 -0
  164. package/dist/lib/shader-module/shader-module.d.ts.map +1 -0
  165. package/dist/lib/shader-module/shader-module.js +104 -0
  166. package/dist/lib/shader-module/shader-module.js.map +1 -0
  167. package/dist/lib/shader-module/shader-pass.cjs +15 -0
  168. package/dist/lib/shader-module/shader-pass.d.ts +48 -0
  169. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -0
  170. package/dist/lib/shader-module/shader-pass.js +5 -0
  171. package/dist/lib/shader-module/shader-pass.js.map +1 -0
  172. package/dist/lib/shader-plugin.cjs +117 -0
  173. package/dist/lib/shader-plugin.d.ts +68 -0
  174. package/dist/lib/shader-plugin.d.ts.map +1 -0
  175. package/dist/lib/shader-plugin.js +98 -0
  176. package/dist/lib/shader-plugin.js.map +1 -0
  177. package/dist/lib/shader-transpiler/shader-transpiler.cjs +15 -0
  178. package/dist/lib/shader-transpiler/shader-transpiler.d.ts +27 -0
  179. package/dist/lib/shader-transpiler/shader-transpiler.d.ts.map +1 -0
  180. package/dist/lib/shader-transpiler/shader-transpiler.js +5 -0
  181. package/dist/lib/shader-transpiler/shader-transpiler.js.map +1 -0
  182. package/dist/lib/shader-transpiler/transpile-glsl-shader.cjs +71 -0
  183. package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts +9 -0
  184. package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts.map +1 -0
  185. package/dist/lib/shader-transpiler/transpile-glsl-shader.js +69 -0
  186. package/dist/lib/shader-transpiler/transpile-glsl-shader.js.map +1 -0
  187. package/dist/lib/utils/assert.cjs +34 -0
  188. package/dist/lib/utils/assert.d.ts +2 -0
  189. package/dist/lib/utils/assert.d.ts.map +1 -0
  190. package/dist/lib/utils/assert.js +13 -0
  191. package/dist/lib/utils/assert.js.map +1 -0
  192. package/dist/lib/utils/uniform-types.cjs +15 -0
  193. package/dist/lib/utils/uniform-types.d.ts +18 -0
  194. package/dist/lib/utils/uniform-types.d.ts.map +1 -0
  195. package/dist/lib/utils/uniform-types.js +5 -0
  196. package/dist/lib/utils/uniform-types.js.map +1 -0
  197. package/dist/lib/wgsl-shader-assembler.cjs +99 -0
  198. package/dist/lib/wgsl-shader-assembler.d.ts +34 -0
  199. package/dist/lib/wgsl-shader-assembler.d.ts.map +1 -0
  200. package/dist/lib/wgsl-shader-assembler.js +84 -0
  201. package/dist/lib/wgsl-shader-assembler.js.map +1 -0
  202. package/dist/module-injectors.cjs +59 -0
  203. package/dist/module-injectors.d.ts +3 -0
  204. package/dist/module-injectors.d.ts.map +1 -0
  205. package/dist/module-injectors.js +31 -0
  206. package/dist/module-injectors.js.map +1 -0
  207. package/dist/modules/color/float-colors.cjs +275 -0
  208. package/dist/modules/color/float-colors.d.ts +132 -0
  209. package/dist/modules/color/float-colors.d.ts.map +1 -0
  210. package/dist/modules/color/float-colors.js +248 -0
  211. package/dist/modules/color/float-colors.js.map +1 -0
  212. package/dist/modules/engine/clip/clip.cjs +152 -0
  213. package/dist/modules/engine/clip/clip.d.ts +12 -0
  214. package/dist/modules/engine/clip/clip.d.ts.map +1 -0
  215. package/dist/modules/engine/clip/clip.js +129 -0
  216. package/dist/modules/engine/clip/clip.js.map +1 -0
  217. package/dist/modules/engine/filter/filter.cjs +111 -0
  218. package/dist/modules/engine/filter/filter.d.ts +12 -0
  219. package/dist/modules/engine/filter/filter.d.ts.map +1 -0
  220. package/dist/modules/engine/filter/filter.js +88 -0
  221. package/dist/modules/engine/filter/filter.js.map +1 -0
  222. package/dist/modules/engine/geometry/geometry.cjs +63 -0
  223. package/dist/modules/engine/geometry/geometry.d.ts +9 -0
  224. package/dist/modules/engine/geometry/geometry.d.ts.map +1 -0
  225. package/dist/modules/engine/geometry/geometry.js +42 -0
  226. package/dist/modules/engine/geometry/geometry.js.map +1 -0
  227. package/dist/modules/engine/gpu-animation/gpu-animation.cjs +255 -0
  228. package/dist/modules/engine/gpu-animation/gpu-animation.d.ts +34 -0
  229. package/dist/modules/engine/gpu-animation/gpu-animation.d.ts.map +1 -0
  230. package/dist/modules/engine/gpu-animation/gpu-animation.js +228 -0
  231. package/dist/modules/engine/gpu-animation/gpu-animation.js.map +1 -0
  232. package/dist/modules/engine/picking/picking.cjs +210 -0
  233. package/dist/modules/engine/picking/picking.d.ts +77 -0
  234. package/dist/modules/engine/picking/picking.d.ts.map +1 -0
  235. package/dist/modules/engine/picking/picking.js +198 -0
  236. package/dist/modules/engine/picking/picking.js.map +1 -0
  237. package/dist/modules/engine/project/project.cjs +138 -0
  238. package/dist/modules/engine/project/project.d.ts +39 -0
  239. package/dist/modules/engine/project/project.d.ts.map +1 -0
  240. package/dist/modules/engine/project/project.js +129 -0
  241. package/dist/modules/engine/project/project.js.map +1 -0
  242. package/dist/modules/engine/skin/skin.cjs +212 -0
  243. package/dist/modules/engine/skin/skin.d.ts +52 -0
  244. package/dist/modules/engine/skin/skin.d.ts.map +1 -0
  245. package/dist/modules/engine/skin/skin.js +179 -0
  246. package/dist/modules/engine/skin/skin.js.map +1 -0
  247. package/dist/modules/engine/transform/transform.cjs +72 -0
  248. package/dist/modules/engine/transform/transform.d.ts +6 -0
  249. package/dist/modules/engine/transform/transform.d.ts.map +1 -0
  250. package/dist/modules/engine/transform/transform.js +49 -0
  251. package/dist/modules/engine/transform/transform.js.map +1 -0
  252. package/dist/modules/geometry/path-dash/path-dash.cjs +93 -0
  253. package/dist/modules/geometry/path-dash/path-dash.d.ts +10 -0
  254. package/dist/modules/geometry/path-dash/path-dash.d.ts.map +1 -0
  255. package/dist/modules/geometry/path-dash/path-dash.js +66 -0
  256. package/dist/modules/geometry/path-dash/path-dash.js.map +1 -0
  257. package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.cjs +117 -0
  258. package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.d.ts +3 -0
  259. package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.d.ts.map +1 -0
  260. package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.js +87 -0
  261. package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.js.map +1 -0
  262. package/dist/modules/geometry/pattern-fill/pattern-fill.cjs +64 -0
  263. package/dist/modules/geometry/pattern-fill/pattern-fill.d.ts +14 -0
  264. package/dist/modules/geometry/pattern-fill/pattern-fill.d.ts.map +1 -0
  265. package/dist/modules/geometry/pattern-fill/pattern-fill.js +43 -0
  266. package/dist/modules/geometry/pattern-fill/pattern-fill.js.map +1 -0
  267. package/dist/modules/geometry/point-glow/point-glow.cjs +104 -0
  268. package/dist/modules/geometry/point-glow/point-glow.d.ts +11 -0
  269. package/dist/modules/geometry/point-glow/point-glow.d.ts.map +1 -0
  270. package/dist/modules/geometry/point-glow/point-glow.js +77 -0
  271. package/dist/modules/geometry/point-glow/point-glow.js.map +1 -0
  272. package/dist/modules/geometry/precipitation/precipitation.cjs +122 -0
  273. package/dist/modules/geometry/precipitation/precipitation.d.ts +40 -0
  274. package/dist/modules/geometry/precipitation/precipitation.d.ts.map +1 -0
  275. package/dist/modules/geometry/precipitation/precipitation.js +95 -0
  276. package/dist/modules/geometry/precipitation/precipitation.js.map +1 -0
  277. package/dist/modules/geometry/sketch-stroke/sketch-stroke.cjs +158 -0
  278. package/dist/modules/geometry/sketch-stroke/sketch-stroke.d.ts +60 -0
  279. package/dist/modules/geometry/sketch-stroke/sketch-stroke.d.ts.map +1 -0
  280. package/dist/modules/geometry/sketch-stroke/sketch-stroke.js +137 -0
  281. package/dist/modules/geometry/sketch-stroke/sketch-stroke.js.map +1 -0
  282. package/dist/modules/geospatial/dggs/dggs-wgsl.cjs +2304 -0
  283. package/dist/modules/geospatial/dggs/dggs-wgsl.d.ts +3 -0
  284. package/dist/modules/geospatial/dggs/dggs-wgsl.d.ts.map +1 -0
  285. package/dist/modules/geospatial/dggs/dggs-wgsl.js +2283 -0
  286. package/dist/modules/geospatial/dggs/dggs-wgsl.js.map +1 -0
  287. package/dist/modules/geospatial/dggs/dggs.cjs +31 -0
  288. package/dist/modules/geospatial/dggs/dggs.d.ts +6 -0
  289. package/dist/modules/geospatial/dggs/dggs.d.ts.map +1 -0
  290. package/dist/modules/geospatial/dggs/dggs.js +10 -0
  291. package/dist/modules/geospatial/dggs/dggs.js.map +1 -0
  292. package/dist/modules/lighting/area-lighting/area-light-types.cjs +68 -0
  293. package/dist/modules/lighting/area-lighting/area-light-types.d.ts +34 -0
  294. package/dist/modules/lighting/area-lighting/area-light-types.d.ts.map +1 -0
  295. package/dist/modules/lighting/area-lighting/area-light-types.js +40 -0
  296. package/dist/modules/lighting/area-lighting/area-light-types.js.map +1 -0
  297. package/dist/modules/lighting/area-lighting/area-lighting-shaders.cjs +101 -0
  298. package/dist/modules/lighting/area-lighting/area-lighting-shaders.d.ts +3 -0
  299. package/dist/modules/lighting/area-lighting/area-lighting-shaders.d.ts.map +1 -0
  300. package/dist/modules/lighting/area-lighting/area-lighting-shaders.js +71 -0
  301. package/dist/modules/lighting/area-lighting/area-lighting-shaders.js.map +1 -0
  302. package/dist/modules/lighting/area-lighting/area-lighting.cjs +62 -0
  303. package/dist/modules/lighting/area-lighting/area-lighting.d.ts +89 -0
  304. package/dist/modules/lighting/area-lighting/area-lighting.d.ts.map +1 -0
  305. package/dist/modules/lighting/area-lighting/area-lighting.js +41 -0
  306. package/dist/modules/lighting/area-lighting/area-lighting.js.map +1 -0
  307. package/dist/modules/lighting/area-lighting/ltc-shaders.cjs +192 -0
  308. package/dist/modules/lighting/area-lighting/ltc-shaders.d.ts +3 -0
  309. package/dist/modules/lighting/area-lighting/ltc-shaders.d.ts.map +1 -0
  310. package/dist/modules/lighting/area-lighting/ltc-shaders.js +162 -0
  311. package/dist/modules/lighting/area-lighting/ltc-shaders.js.map +1 -0
  312. package/dist/modules/lighting/atmosphere/atmosphere.cjs +253 -0
  313. package/dist/modules/lighting/atmosphere/atmosphere.d.ts +45 -0
  314. package/dist/modules/lighting/atmosphere/atmosphere.d.ts.map +1 -0
  315. package/dist/modules/lighting/atmosphere/atmosphere.js +228 -0
  316. package/dist/modules/lighting/atmosphere/atmosphere.js.map +1 -0
  317. package/dist/modules/lighting/clouds/clouds.cjs +216 -0
  318. package/dist/modules/lighting/clouds/clouds.d.ts +58 -0
  319. package/dist/modules/lighting/clouds/clouds.d.ts.map +1 -0
  320. package/dist/modules/lighting/clouds/clouds.js +192 -0
  321. package/dist/modules/lighting/clouds/clouds.js.map +1 -0
  322. package/dist/modules/lighting/firefly/firefly.cjs +74 -0
  323. package/dist/modules/lighting/firefly/firefly.d.ts +36 -0
  324. package/dist/modules/lighting/firefly/firefly.d.ts.map +1 -0
  325. package/dist/modules/lighting/firefly/firefly.js +53 -0
  326. package/dist/modules/lighting/firefly/firefly.js.map +1 -0
  327. package/dist/modules/lighting/globe-clouds/globe-clouds.cjs +143 -0
  328. package/dist/modules/lighting/globe-clouds/globe-clouds.d.ts +53 -0
  329. package/dist/modules/lighting/globe-clouds/globe-clouds.d.ts.map +1 -0
  330. package/dist/modules/lighting/globe-clouds/globe-clouds.js +119 -0
  331. package/dist/modules/lighting/globe-clouds/globe-clouds.js.map +1 -0
  332. package/dist/modules/lighting/gouraud-material/gouraud-material.cjs +61 -0
  333. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +12 -0
  334. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -0
  335. package/dist/modules/lighting/gouraud-material/gouraud-material.js +40 -0
  336. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -0
  337. package/dist/modules/lighting/height-fog/height-fog-functions.cjs +139 -0
  338. package/dist/modules/lighting/height-fog/height-fog-functions.d.ts +14 -0
  339. package/dist/modules/lighting/height-fog/height-fog-functions.d.ts.map +1 -0
  340. package/dist/modules/lighting/height-fog/height-fog-functions.js +114 -0
  341. package/dist/modules/lighting/height-fog/height-fog-functions.js.map +1 -0
  342. package/dist/modules/lighting/height-fog/height-fog.cjs +104 -0
  343. package/dist/modules/lighting/height-fog/height-fog.d.ts +60 -0
  344. package/dist/modules/lighting/height-fog/height-fog.d.ts.map +1 -0
  345. package/dist/modules/lighting/height-fog/height-fog.js +77 -0
  346. package/dist/modules/lighting/height-fog/height-fog.js.map +1 -0
  347. package/dist/modules/lighting/ibl/ibl.cjs +63 -0
  348. package/dist/modules/lighting/ibl/ibl.d.ts +25 -0
  349. package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
  350. package/dist/modules/lighting/ibl/ibl.js +33 -0
  351. package/dist/modules/lighting/ibl/ibl.js.map +1 -0
  352. package/dist/modules/lighting/lambert-material/lambert-material.cjs +54 -0
  353. package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
  354. package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
  355. package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
  356. package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
  357. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.cjs +88 -0
  358. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
  359. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
  360. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
  361. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
  362. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.cjs +97 -0
  363. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
  364. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
  365. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
  366. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
  367. package/dist/modules/lighting/lights/lighting-glsl.cjs +116 -0
  368. package/dist/modules/lighting/lights/lighting-glsl.d.ts +2 -0
  369. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -0
  370. package/dist/modules/lighting/lights/lighting-glsl.js +92 -0
  371. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -0
  372. package/dist/modules/lighting/lights/lighting-wgsl.cjs +115 -0
  373. package/dist/modules/lighting/lights/lighting-wgsl.d.ts +2 -0
  374. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -0
  375. package/dist/modules/lighting/lights/lighting-wgsl.js +91 -0
  376. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -0
  377. package/dist/modules/lighting/lights/lighting.cjs +210 -0
  378. package/dist/modules/lighting/lights/lighting.d.ts +163 -0
  379. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -0
  380. package/dist/modules/lighting/lights/lighting.js +208 -0
  381. package/dist/modules/lighting/lights/lighting.js.map +1 -0
  382. package/dist/modules/lighting/no-material/dirlight.cjs +112 -0
  383. package/dist/modules/lighting/no-material/dirlight.d.ts +33 -0
  384. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -0
  385. package/dist/modules/lighting/no-material/dirlight.js +86 -0
  386. package/dist/modules/lighting/no-material/dirlight.js.map +1 -0
  387. package/dist/modules/lighting/pbr-material/pbr-material-glsl.cjs +1767 -0
  388. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +3 -0
  389. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -0
  390. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +1745 -0
  391. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -0
  392. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.cjs +2062 -0
  393. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +3 -0
  394. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -0
  395. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +2040 -0
  396. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -0
  397. package/dist/modules/lighting/pbr-material/pbr-material.cjs +315 -0
  398. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +516 -0
  399. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -0
  400. package/dist/modules/lighting/pbr-material/pbr-material.js +292 -0
  401. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -0
  402. package/dist/modules/lighting/pbr-material/pbr-projection.cjs +63 -0
  403. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
  404. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
  405. package/dist/modules/lighting/pbr-material/pbr-projection.js +37 -0
  406. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -0
  407. package/dist/modules/lighting/pbr-material/pbr-scene.cjs +109 -0
  408. package/dist/modules/lighting/pbr-material/pbr-scene.d.ts +52 -0
  409. package/dist/modules/lighting/pbr-material/pbr-scene.d.ts.map +1 -0
  410. package/dist/modules/lighting/pbr-material/pbr-scene.js +83 -0
  411. package/dist/modules/lighting/pbr-material/pbr-scene.js.map +1 -0
  412. package/dist/modules/lighting/phong-material/phong-material.cjs +61 -0
  413. package/dist/modules/lighting/phong-material/phong-material.d.ts +13 -0
  414. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -0
  415. package/dist/modules/lighting/phong-material/phong-material.js +40 -0
  416. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -0
  417. package/dist/modules/lighting/phong-material/phong-shaders-glsl.cjs +100 -0
  418. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +3 -0
  419. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -0
  420. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +72 -0
  421. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -0
  422. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.cjs +153 -0
  423. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +2 -0
  424. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -0
  425. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +129 -0
  426. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -0
  427. package/dist/modules/lighting/surface-weather/surface-weather.cjs +199 -0
  428. package/dist/modules/lighting/surface-weather/surface-weather.d.ts +54 -0
  429. package/dist/modules/lighting/surface-weather/surface-weather.d.ts.map +1 -0
  430. package/dist/modules/lighting/surface-weather/surface-weather.js +175 -0
  431. package/dist/modules/lighting/surface-weather/surface-weather.js.map +1 -0
  432. package/dist/modules/lighting/water-material/river-water-material.cjs +56 -0
  433. package/dist/modules/lighting/water-material/river-water-material.d.ts +21 -0
  434. package/dist/modules/lighting/water-material/river-water-material.d.ts.map +1 -0
  435. package/dist/modules/lighting/water-material/river-water-material.js +36 -0
  436. package/dist/modules/lighting/water-material/river-water-material.js.map +1 -0
  437. package/dist/modules/lighting/water-material/river-water-shaders.cjs +261 -0
  438. package/dist/modules/lighting/water-material/river-water-shaders.d.ts +3 -0
  439. package/dist/modules/lighting/water-material/river-water-shaders.d.ts.map +1 -0
  440. package/dist/modules/lighting/water-material/river-water-shaders.js +233 -0
  441. package/dist/modules/lighting/water-material/river-water-shaders.js.map +1 -0
  442. package/dist/modules/lighting/water-material/water-material.cjs +188 -0
  443. package/dist/modules/lighting/water-material/water-material.d.ts +28 -0
  444. package/dist/modules/lighting/water-material/water-material.d.ts.map +1 -0
  445. package/dist/modules/lighting/water-material/water-material.js +179 -0
  446. package/dist/modules/lighting/water-material/water-material.js.map +1 -0
  447. package/dist/modules/lighting/water-material/water-shaders-glsl.cjs +260 -0
  448. package/dist/modules/lighting/water-material/water-shaders-glsl.d.ts +3 -0
  449. package/dist/modules/lighting/water-material/water-shaders-glsl.d.ts.map +1 -0
  450. package/dist/modules/lighting/water-material/water-shaders-glsl.js +232 -0
  451. package/dist/modules/lighting/water-material/water-shaders-glsl.js.map +1 -0
  452. package/dist/modules/lighting/water-material/water-shaders-wgsl.cjs +254 -0
  453. package/dist/modules/lighting/water-material/water-shaders-wgsl.d.ts +2 -0
  454. package/dist/modules/lighting/water-material/water-shaders-wgsl.d.ts.map +1 -0
  455. package/dist/modules/lighting/water-material/water-shaders-wgsl.js +230 -0
  456. package/dist/modules/lighting/water-material/water-shaders-wgsl.js.map +1 -0
  457. package/dist/modules/math/fp16/fp16-utils.cjs +112 -0
  458. package/dist/modules/math/fp16/fp16-utils.d.ts +13 -0
  459. package/dist/modules/math/fp16/fp16-utils.d.ts.map +1 -0
  460. package/dist/modules/math/fp16/fp16-utils.js +118 -0
  461. package/dist/modules/math/fp16/fp16-utils.js.map +1 -0
  462. package/dist/modules/math/fp32/fp32.cjs +310 -0
  463. package/dist/modules/math/fp32/fp32.d.ts +9 -0
  464. package/dist/modules/math/fp32/fp32.d.ts.map +1 -0
  465. package/dist/modules/math/fp32/fp32.js +288 -0
  466. package/dist/modules/math/fp32/fp32.js.map +1 -0
  467. package/dist/modules/math/fp64/fp64-arithmetic-glsl.cjs +229 -0
  468. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +2 -0
  469. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -0
  470. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +205 -0
  471. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -0
  472. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.cjs +144 -0
  473. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.d.ts +10 -0
  474. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.d.ts.map +1 -0
  475. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.js +128 -0
  476. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.js.map +1 -0
  477. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.cjs +583 -0
  478. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.d.ts +11 -0
  479. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.d.ts.map +1 -0
  480. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.js +563 -0
  481. package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.js.map +1 -0
  482. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.cjs +946 -0
  483. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +3 -0
  484. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
  485. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +923 -0
  486. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
  487. package/dist/modules/math/fp64/fp64-functions-glsl.cjs +699 -0
  488. package/dist/modules/math/fp64/fp64-functions-glsl.d.ts +2 -0
  489. package/dist/modules/math/fp64/fp64-functions-glsl.d.ts.map +1 -0
  490. package/dist/modules/math/fp64/fp64-functions-glsl.js +675 -0
  491. package/dist/modules/math/fp64/fp64-functions-glsl.js.map +1 -0
  492. package/dist/modules/math/fp64/fp64-functions-wgsl.cjs +180 -0
  493. package/dist/modules/math/fp64/fp64-functions-wgsl.d.ts +3 -0
  494. package/dist/modules/math/fp64/fp64-functions-wgsl.d.ts.map +1 -0
  495. package/dist/modules/math/fp64/fp64-functions-wgsl.js +157 -0
  496. package/dist/modules/math/fp64/fp64-functions-wgsl.js.map +1 -0
  497. package/dist/modules/math/fp64/fp64-utils.cjs +50 -0
  498. package/dist/modules/math/fp64/fp64-utils.d.ts +22 -0
  499. package/dist/modules/math/fp64/fp64-utils.d.ts.map +1 -0
  500. package/dist/modules/math/fp64/fp64-utils.js +42 -0
  501. package/dist/modules/math/fp64/fp64-utils.js.map +1 -0
  502. package/dist/modules/math/fp64/fp64.cjs +68 -0
  503. package/dist/modules/math/fp64/fp64.d.ts +24 -0
  504. package/dist/modules/math/fp64/fp64.d.ts.map +1 -0
  505. package/dist/modules/math/fp64/fp64.js +46 -0
  506. package/dist/modules/math/fp64/fp64.js.map +1 -0
  507. package/dist/modules/math/random/random.cjs +46 -0
  508. package/dist/modules/math/random/random.d.ts +7 -0
  509. package/dist/modules/math/random/random.d.ts.map +1 -0
  510. package/dist/modules/math/random/random.js +21 -0
  511. package/dist/modules/math/random/random.js.map +1 -0
  512. package/dist/modules/math/value-noise/value-noise.cjs +95 -0
  513. package/dist/modules/math/value-noise/value-noise.d.ts +7 -0
  514. package/dist/modules/math/value-noise/value-noise.d.ts.map +1 -0
  515. package/dist/modules/math/value-noise/value-noise.js +68 -0
  516. package/dist/modules/math/value-noise/value-noise.js.map +1 -0
  517. package/dist/modules/volume/volume-raymarch.cjs +107 -0
  518. package/dist/modules/volume/volume-raymarch.d.ts +6 -0
  519. package/dist/modules/volume/volume-raymarch.d.ts.map +1 -0
  520. package/dist/modules/volume/volume-raymarch.js +84 -0
  521. package/dist/modules/volume/volume-raymarch.js.map +1 -0
  522. package/dist/types/align-to.cjs +38 -0
  523. package/dist/types/align-to.d.ts +3 -0
  524. package/dist/types/align-to.d.ts.map +1 -0
  525. package/dist/types/align-to.js +13 -0
  526. package/dist/types/align-to.js.map +1 -0
  527. package/dist/types/primitive-data-types.cjs +15 -0
  528. package/dist/types/primitive-data-types.d.ts +7 -0
  529. package/dist/types/primitive-data-types.d.ts.map +1 -0
  530. package/dist/types/primitive-data-types.js +5 -0
  531. package/dist/types/primitive-data-types.js.map +1 -0
  532. package/dist/types/sampler-props.cjs +15 -0
  533. package/dist/types/sampler-props.d.ts +26 -0
  534. package/dist/types/sampler-props.d.ts.map +1 -0
  535. package/dist/types/sampler-props.js +5 -0
  536. package/dist/types/sampler-props.js.map +1 -0
  537. package/dist/types/shader-block-layout.cjs +184 -0
  538. package/dist/types/shader-block-layout.d.ts +72 -0
  539. package/dist/types/shader-block-layout.d.ts.map +1 -0
  540. package/dist/types/shader-block-layout.js +209 -0
  541. package/dist/types/shader-block-layout.js.map +1 -0
  542. package/dist/types/shader-layout.cjs +15 -0
  543. package/dist/types/shader-layout.d.ts +178 -0
  544. package/dist/types/shader-layout.d.ts.map +1 -0
  545. package/dist/types/shader-layout.js +5 -0
  546. package/dist/types/shader-layout.js.map +1 -0
  547. package/dist/types/shader-type-decoder.cjs +240 -0
  548. package/dist/types/shader-type-decoder.d.ts +41 -0
  549. package/dist/types/shader-type-decoder.d.ts.map +1 -0
  550. package/dist/types/shader-type-decoder.js +210 -0
  551. package/dist/types/shader-type-decoder.js.map +1 -0
  552. package/dist/types/shader-types.cjs +15 -0
  553. package/dist/types/shader-types.d.ts +101 -0
  554. package/dist/types/shader-types.d.ts.map +1 -0
  555. package/dist/types/shader-types.js +30 -0
  556. package/dist/types/shader-types.js.map +1 -0
  557. package/dist/types/texture-formats.cjs +15 -0
  558. package/dist/types/texture-formats.d.ts +24 -0
  559. package/dist/types/texture-formats.d.ts.map +1 -0
  560. package/dist/types/texture-formats.js +5 -0
  561. package/dist/types/texture-formats.js.map +1 -0
  562. package/dist/types.cjs +42 -0
  563. package/dist/types.cjs.map +6 -0
  564. package/dist/types.d.ts +14 -0
  565. package/dist/types.d.ts.map +1 -0
  566. package/dist/types.js +12 -0
  567. package/dist/types.js.map +1 -0
  568. package/dist/wgsl.cjs +39 -0
  569. package/dist/wgsl.cjs.map +6 -0
  570. package/dist/wgsl.d.ts +8 -0
  571. package/dist/wgsl.d.ts.map +1 -0
  572. package/dist/wgsl.js +9 -0
  573. package/dist/wgsl.js.map +1 -0
  574. package/package.json +65 -4
  575. package/src/glsl.ts +13 -0
  576. package/src/index.ts +259 -0
  577. package/src/lib/color/normalize-byte-colors.ts +57 -0
  578. package/src/lib/filters/prop-types.ts +150 -0
  579. package/src/lib/glsl-shader-assembler.ts +39 -0
  580. package/src/lib/glsl-utils/get-shader-info.ts +42 -0
  581. package/src/lib/glsl-utils/shader-utils.ts +110 -0
  582. package/src/lib/preprocessor/preprocessor.ts +132 -0
  583. package/src/lib/shader-assembler-base.ts +170 -0
  584. package/src/lib/shader-assembler.ts +7 -0
  585. package/src/lib/shader-assembly/assemble-glsl-shaders.ts +305 -0
  586. package/src/lib/shader-assembly/assemble-shaders.ts +13 -0
  587. package/src/lib/shader-assembly/assemble-wgsl-shaders.ts +801 -0
  588. package/src/lib/shader-assembly/platform-defines.ts +58 -0
  589. package/src/lib/shader-assembly/platform-info.ts +23 -0
  590. package/src/lib/shader-assembly/shader-assembly-shared.ts +95 -0
  591. package/src/lib/shader-assembly/shader-assembly-types.ts +142 -0
  592. package/src/lib/shader-assembly/shader-hooks.ts +141 -0
  593. package/src/lib/shader-assembly/shader-injections.ts +250 -0
  594. package/src/lib/shader-assembly/shader-plugin-varyings.ts +524 -0
  595. package/src/lib/shader-assembly/shader-plugin-vertex-inputs.ts +279 -0
  596. package/src/lib/shader-assembly/wgsl-binding-debug.ts +227 -0
  597. package/src/lib/shader-assembly/wgsl-binding-scan.ts +228 -0
  598. package/src/lib/shader-assembly/wgsl-interface-scan.ts +676 -0
  599. package/src/lib/shader-generator/generate-shader.ts +27 -0
  600. package/src/lib/shader-generator/glsl/generate-glsl.ts +101 -0
  601. package/src/lib/shader-generator/utils/capitalize.ts +12 -0
  602. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +40 -0
  603. package/src/lib/shader-module/composite-shader-pass.ts +47 -0
  604. package/src/lib/shader-module/shader-module-dependencies.ts +128 -0
  605. package/src/lib/shader-module/shader-module-uniform-layout.ts +420 -0
  606. package/src/lib/shader-module/shader-module.ts +244 -0
  607. package/src/lib/shader-module/shader-pass.ts +69 -0
  608. package/src/lib/shader-plugin.ts +214 -0
  609. package/src/lib/shader-transpiler/shader-transpiler.ts +34 -0
  610. package/src/lib/shader-transpiler/transpile-glsl-shader.ts +78 -0
  611. package/src/lib/utils/assert.ts +13 -0
  612. package/src/lib/utils/uniform-types.ts +89 -0
  613. package/src/lib/wgsl-shader-assembler.ts +122 -0
  614. package/src/module-injectors.ts +32 -0
  615. package/src/modules/color/float-colors.ts +334 -0
  616. package/src/modules/engine/clip/clip.ts +149 -0
  617. package/src/modules/engine/filter/filter.ts +107 -0
  618. package/src/modules/engine/geometry/geometry.ts +45 -0
  619. package/src/modules/engine/gpu-animation/gpu-animation.ts +244 -0
  620. package/src/modules/engine/picking/README.md +88 -0
  621. package/src/modules/engine/picking/picking.ts +252 -0
  622. package/src/modules/engine/project/project.ts +166 -0
  623. package/src/modules/engine/skin/skin.ts +233 -0
  624. package/src/modules/engine/transform/transform.ts +50 -0
  625. package/src/modules/geometry/path-dash/path-dash.ts +68 -0
  626. package/src/modules/geometry/pattern-fill/pattern-fill-shaders.ts +88 -0
  627. package/src/modules/geometry/pattern-fill/pattern-fill.ts +54 -0
  628. package/src/modules/geometry/point-glow/point-glow.ts +87 -0
  629. package/src/modules/geometry/precipitation/README.md +19 -0
  630. package/src/modules/geometry/precipitation/precipitation.ts +108 -0
  631. package/src/modules/geometry/sketch-stroke/sketch-stroke.ts +160 -0
  632. package/src/modules/geospatial/dggs/dggs-wgsl.ts +2284 -0
  633. package/src/modules/geospatial/dggs/dggs.ts +12 -0
  634. package/src/modules/lighting/area-lighting/area-light-types.ts +71 -0
  635. package/src/modules/lighting/area-lighting/area-lighting-shaders.ts +72 -0
  636. package/src/modules/lighting/area-lighting/area-lighting.ts +63 -0
  637. package/src/modules/lighting/area-lighting/ltc-shaders.ts +163 -0
  638. package/src/modules/lighting/atmosphere/README.md +25 -0
  639. package/src/modules/lighting/atmosphere/atmosphere.ts +246 -0
  640. package/src/modules/lighting/clouds/README.md +24 -0
  641. package/src/modules/lighting/clouds/clouds.ts +216 -0
  642. package/src/modules/lighting/firefly/firefly.ts +64 -0
  643. package/src/modules/lighting/globe-clouds/globe-clouds.ts +124 -0
  644. package/src/modules/lighting/gouraud-material/gouraud-material.ts +55 -0
  645. package/src/modules/lighting/height-fog/README.md +36 -0
  646. package/src/modules/lighting/height-fog/height-fog-functions.ts +116 -0
  647. package/src/modules/lighting/height-fog/height-fog.ts +96 -0
  648. package/src/modules/lighting/ibl/ibl.ts +43 -0
  649. package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
  650. package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
  651. package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
  652. package/src/modules/lighting/lights/lighting-glsl.ts +92 -0
  653. package/src/modules/lighting/lights/lighting-wgsl.ts +91 -0
  654. package/src/modules/lighting/lights/lighting.ts +385 -0
  655. package/src/modules/lighting/no-material/dirlight.ts +101 -0
  656. package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +1748 -0
  657. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +2043 -0
  658. package/src/modules/lighting/pbr-material/pbr-material.ts +517 -0
  659. package/src/modules/lighting/pbr-material/pbr-projection.ts +50 -0
  660. package/src/modules/lighting/pbr-material/pbr-scene.ts +112 -0
  661. package/src/modules/lighting/phong-material/phong-material.ts +53 -0
  662. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +73 -0
  663. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +129 -0
  664. package/src/modules/lighting/surface-weather/README.md +28 -0
  665. package/src/modules/lighting/surface-weather/surface-weather.ts +198 -0
  666. package/src/modules/lighting/water-material/river-water-material.ts +58 -0
  667. package/src/modules/lighting/water-material/river-water-shaders.ts +234 -0
  668. package/src/modules/lighting/water-material/water-material.ts +234 -0
  669. package/src/modules/lighting/water-material/water-shaders-glsl.ts +233 -0
  670. package/src/modules/lighting/water-material/water-shaders-wgsl.ts +230 -0
  671. package/src/modules/math/fp16/fp16-utils.ts +156 -0
  672. package/src/modules/math/fp32/fp32.ts +291 -0
  673. package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +205 -0
  674. package/src/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.ts +129 -0
  675. package/src/modules/math/fp64/fp64-arithmetic-wgsl-integer.ts +564 -0
  676. package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +924 -0
  677. package/src/modules/math/fp64/fp64-functions-glsl.ts +675 -0
  678. package/src/modules/math/fp64/fp64-functions-wgsl.ts +157 -0
  679. package/src/modules/math/fp64/fp64-utils.ts +46 -0
  680. package/src/modules/math/fp64/fp64.ts +64 -0
  681. package/src/modules/math/random/random.ts +25 -0
  682. package/src/modules/math/value-noise/value-noise.ts +70 -0
  683. package/src/modules/volume/volume-raymarch.ts +87 -0
  684. package/src/types/align-to.ts +13 -0
  685. package/src/types/primitive-data-types.ts +10 -0
  686. package/src/types/sampler-props.ts +39 -0
  687. package/src/types/shader-block-layout.ts +340 -0
  688. package/src/types/shader-layout.ts +208 -0
  689. package/src/types/shader-type-decoder.ts +285 -0
  690. package/src/types/shader-types.ts +207 -0
  691. package/src/types/texture-formats.ts +155 -0
  692. package/src/types.ts +48 -0
  693. package/src/wgsl.ts +23 -0
@@ -0,0 +1,801 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {type ShaderBindingDebugRow, getShaderBindingDebugRowsFromWGSL} from './wgsl-binding-debug';
6
+ import {type ShaderLayout} from '../../types';
7
+ import {scanWGSLInterface} from './wgsl-interface-scan';
8
+ import {
9
+ type AssembleWGSLShaderOptions,
10
+ type GetUniformsFunc,
11
+ type WGSLBindingAssignment,
12
+ type AssembleStageOptions,
13
+ type WGSLApplicationRelocationState,
14
+ type BindingRelocationContext,
15
+ type WGSLRelocationState,
16
+ type WGSLRelocationParams
17
+ } from './shader-assembly-types';
18
+ import {getShaderModuleDependencies} from '../shader-module/shader-module-dependencies';
19
+ import {
20
+ assembleGetUniforms,
21
+ appendInjections,
22
+ getShaderModuleSource,
23
+ INJECT_SHADER_DECLARATIONS
24
+ } from './shader-assembly-shared';
25
+ import {PlatformInfo} from './platform-info';
26
+ import {assert} from '../utils/assert';
27
+ import {preprocess} from '../preprocessor/preprocessor';
28
+ import {assembleShaderPluginVertexInputsWGSL} from './shader-plugin-vertex-inputs';
29
+ import {assembleShaderPluginVaryingsWGSL} from './shader-plugin-varyings';
30
+ import {
31
+ normalizeShaderHooks,
32
+ validateShaderHookInjections,
33
+ isShaderHookRegistered,
34
+ getShaderHooks
35
+ } from './shader-hooks';
36
+ import {type ShaderInjection, injectShader} from './shader-injections';
37
+ import {checkShaderModuleDeprecations, type ShaderModule} from '../shader-module/shader-module';
38
+ import {
39
+ getWGSLBindingDeclarationMatches,
40
+ WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES,
41
+ WGSL_BINDING_DECLARATION_REGEXES,
42
+ replaceWGSLBindingDeclarationMatches,
43
+ hasWGSLAutoBinding,
44
+ MODULE_WGSL_BINDING_DECLARATION_REGEXES,
45
+ type WGSLBindingDeclarationMatch,
46
+ getFirstWGSLAutoBindingDeclarationMatch
47
+ } from './wgsl-binding-scan';
48
+
49
+ export const RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT = 100;
50
+
51
+ /** Inject shader modules and compute metadata for the resulting WGSL source. */
52
+ export function assembleWGSLShader(options: AssembleWGSLShaderOptions): {
53
+ source: string;
54
+ getUniforms: GetUniformsFunc;
55
+ bindingAssignments: WGSLBindingAssignment[];
56
+ bindingTable: ShaderBindingDebugRow[];
57
+ shaderLayout: ShaderLayout | null;
58
+ } {
59
+ const assembledShader = assembleWGSLSource(options);
60
+ return {
61
+ ...assembledShader,
62
+ bindingTable: getShaderBindingDebugRowsFromWGSL(
63
+ assembledShader.source,
64
+ assembledShader.bindingAssignments
65
+ ),
66
+ shaderLayout: scanWGSLInterface(assembledShader.source, {
67
+ vertexEntryPoint: options.vertexEntryPoint,
68
+ scanVertexAttributes: options.scanVertexAttributes
69
+ })
70
+ };
71
+ }
72
+
73
+ /** @internal Assemble source without scanning metadata that subsequent preprocessing invalidates. */
74
+ export function assembleWGSLSource(options: AssembleWGSLShaderOptions): {
75
+ source: string;
76
+ getUniforms: GetUniformsFunc;
77
+ bindingAssignments: WGSLBindingAssignment[];
78
+ } {
79
+ const modules = getShaderModuleDependencies(options.modules || []);
80
+ const {source, bindingAssignments} = assembleShaderWGSL(options.platformInfo, {
81
+ ...options,
82
+ source: options.source,
83
+ stage: 'vertex',
84
+ modules
85
+ });
86
+
87
+ return {
88
+ source,
89
+ getUniforms: assembleGetUniforms(modules),
90
+ bindingAssignments
91
+ };
92
+ }
93
+
94
+ /**
95
+ * Pulls together complete source code for either a vertex or a fragment shader
96
+ * adding prologues, requested module chunks, and any final injections.
97
+ * @param gl
98
+ * @param options
99
+ * @returns
100
+ */
101
+ export function assembleShaderWGSL(
102
+ platformInfo: PlatformInfo,
103
+ options: AssembleStageOptions
104
+ ): {source: string; bindingAssignments: WGSLBindingAssignment[]} {
105
+ const {
106
+ // id,
107
+ source,
108
+ stage,
109
+ modules,
110
+ // defines = {},
111
+ defines = {},
112
+ hookFunctions = [],
113
+ inject = {},
114
+ pluginInjections = {},
115
+ pluginVertexInputs = {},
116
+ pluginVaryings = {},
117
+ vertexEntryPoint = 'vertexMain',
118
+ fragmentEntryPoint = 'fragmentMain',
119
+ log
120
+ } = options;
121
+
122
+ assert(typeof source === 'string', 'shader source must be a string');
123
+
124
+ // const isVertex = type === 'vs';
125
+ // const sourceLines = source.split('\n');
126
+
127
+ const preprocessedSource = preprocess(source, {defines});
128
+ const pluginVertexInputAssembly = assembleShaderPluginVertexInputsWGSL(
129
+ preprocessedSource,
130
+ vertexEntryPoint,
131
+ pluginVertexInputs
132
+ );
133
+ const pluginVaryingAssembly = assembleShaderPluginVaryingsWGSL(
134
+ pluginVertexInputAssembly.source,
135
+ vertexEntryPoint,
136
+ fragmentEntryPoint,
137
+ pluginVaryings
138
+ );
139
+ const coreSource = pluginVaryingAssembly.source;
140
+
141
+ // Combine Module and Application Defines
142
+ // const allDefines = {};
143
+ // modules.forEach(module => {
144
+ // Object.assign(allDefines, module.getDefines());
145
+ // });
146
+ // Object.assign(allDefines, defines);
147
+
148
+ // Add platform defines (use these to work around platform-specific bugs and limitations)
149
+ // Add common defines (GLSL version compatibility, feature detection)
150
+ // Add precision declaration for fragment shaders
151
+ let assembledSource = '';
152
+ // prologue
153
+ // ? `\
154
+ // ${getShaderNameDefine({id, source, type})}
155
+ // ${getShaderType(type)}
156
+ // ${getPlatformShaderDefines(platformInfo)}
157
+ // ${getApplicationDefines(allDefines)}
158
+ // ${isVertex ? '' : FRAGMENT_SHADER_PROLOGUE}
159
+ // `
160
+ // `;
161
+
162
+ const hookFunctionMap = normalizeShaderHooks(hookFunctions);
163
+
164
+ // Add source of dependent modules in resolved order
165
+ const hookInjections: Record<string, ShaderInjection[]> = {};
166
+ const declInjections: Record<string, ShaderInjection[]> = {};
167
+ const mainInjections: Record<string, ShaderInjection[]> = {};
168
+
169
+ appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
170
+
171
+ for (const key in inject) {
172
+ const injection: ShaderInjection =
173
+ typeof inject[key] === 'string' ? {injection: inject[key], order: 0} : inject[key];
174
+ const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
175
+ if (match) {
176
+ const hash = match[2];
177
+ const name = match[3];
178
+ if (hash) {
179
+ if (name === 'decl') {
180
+ declInjections[key] = [injection];
181
+ } else {
182
+ mainInjections[key] = [injection];
183
+ }
184
+ } else {
185
+ hookInjections[key] = [injection];
186
+ }
187
+ } else {
188
+ // Regex injection
189
+ mainInjections[key] = [injection];
190
+ }
191
+ }
192
+ appendGeneratedVertexInputInjections(
193
+ pluginVertexInputAssembly.declarations,
194
+ pluginVertexInputAssembly.initialization,
195
+ declInjections,
196
+ mainInjections
197
+ );
198
+ appendGeneratedVaryingInjections(pluginVaryingAssembly, declInjections, mainInjections);
199
+
200
+ // Application and plugin injections are WGSL-specific, so every named hook they target must exist.
201
+ validateShaderHookInjections(hookFunctionMap, hookInjections);
202
+
203
+ // TODO - hack until shadertool modules support WebGPU
204
+ const modulesToInject = modules.map(module => ({
205
+ module,
206
+ source: preprocess(getShaderModuleSource(module, 'wgsl', log), {defines})
207
+ }));
208
+ const applicationRelocation = relocateWGSLApplicationBindings(coreSource);
209
+ const usedBindingsByGroup = getUsedBindingsByGroupFromApplicationWGSL(
210
+ applicationRelocation.source
211
+ );
212
+ const reservedBindingKeysByGroup = reserveModuleBindings(
213
+ modulesToInject,
214
+ options._bindingRegistry,
215
+ usedBindingsByGroup
216
+ );
217
+ const bindingAssignments: WGSLBindingAssignment[] = [];
218
+
219
+ // Resolve all bindings before emitting source, preserving module and declaration order.
220
+ const relocatedModules = modulesToInject.map(({module, source: moduleSource}) => {
221
+ const relocation = relocateWGSLModuleBindings(moduleSource, module, {
222
+ usedBindingsByGroup,
223
+ bindingRegistry: options._bindingRegistry,
224
+ reservedBindingKeysByGroup
225
+ });
226
+ bindingAssignments.push(...relocation.bindingAssignments);
227
+ return {module, source: relocation.source};
228
+ });
229
+
230
+ for (const {module, source: moduleSource} of relocatedModules) {
231
+ if (log) {
232
+ checkShaderModuleDeprecations(module, coreSource, log);
233
+ }
234
+ assembledSource += moduleSource;
235
+
236
+ const injections = getWGSLModuleInjections(module);
237
+ for (const key in injections) {
238
+ const match = /^(v|f)s:#([\w-]+)$/.exec(key);
239
+ if (match) {
240
+ const name = match[2];
241
+ const injectionType = name === 'decl' ? declInjections : mainInjections;
242
+ injectionType[key] = injectionType[key] || [];
243
+ injectionType[key].push(injections[key]);
244
+ } else if (isShaderHookRegistered(hookFunctionMap, key)) {
245
+ // `ShaderModule.inject` is not language-specific and often carries GLSL-only hook
246
+ // injections, so WGSL silently skips module injections into hooks it has not declared.
247
+ hookInjections[key] = hookInjections[key] || [];
248
+ hookInjections[key].push(injections[key]);
249
+ }
250
+ }
251
+ }
252
+
253
+ // For injectShader
254
+ assembledSource += INJECT_SHADER_DECLARATIONS;
255
+
256
+ assembledSource = injectShader(
257
+ assembledSource,
258
+ stage,
259
+ getWGSLDeclarationInjections(declInjections),
260
+ false,
261
+ 'wgsl',
262
+ {vertex: vertexEntryPoint, fragment: fragmentEntryPoint}
263
+ );
264
+
265
+ assembledSource += getWGSLShaderHooks(hookFunctionMap, hookInjections);
266
+ assembledSource += formatWGSLBindingAssignmentComments(bindingAssignments);
267
+
268
+ // Add the version directive and actual source of this shader
269
+ assembledSource += applicationRelocation.source;
270
+
271
+ // Apply any requested shader injections
272
+ assembledSource = injectShader(assembledSource, stage, mainInjections, false, 'wgsl', {
273
+ vertex: vertexEntryPoint,
274
+ fragment: fragmentEntryPoint
275
+ });
276
+
277
+ assertNoUnresolvedAutoBindings(assembledSource);
278
+
279
+ return {source: assembledSource, bindingAssignments};
280
+ }
281
+
282
+ export function appendGeneratedVertexInputInjections(
283
+ declarations: string,
284
+ initialization: string,
285
+ declarationInjections: Record<string, ShaderInjection[]>,
286
+ mainInjections: Record<string, ShaderInjection[]>
287
+ ): void {
288
+ if (declarations) {
289
+ declarationInjections['vs:#decl'] = declarationInjections['vs:#decl'] || [];
290
+ declarationInjections['vs:#decl'].push({
291
+ injection: declarations,
292
+ order: Number.MIN_SAFE_INTEGER
293
+ });
294
+ }
295
+ if (initialization) {
296
+ mainInjections['vs:#main-start'] = mainInjections['vs:#main-start'] || [];
297
+ mainInjections['vs:#main-start'].push({
298
+ injection: initialization,
299
+ order: Number.MIN_SAFE_INTEGER
300
+ });
301
+ }
302
+ }
303
+
304
+ export function appendGeneratedVaryingInjections(
305
+ assembly: {
306
+ declarations: string;
307
+ vertexInitialization: string;
308
+ fragmentInitialization: string;
309
+ },
310
+ declarationInjections: Record<string, ShaderInjection[]>,
311
+ mainInjections: Record<string, ShaderInjection[]>
312
+ ): void {
313
+ if (assembly.declarations) {
314
+ declarationInjections['vs:#decl'] = declarationInjections['vs:#decl'] || [];
315
+ declarationInjections['vs:#decl'].push({
316
+ injection: assembly.declarations,
317
+ order: Number.MIN_SAFE_INTEGER
318
+ });
319
+ }
320
+ if (assembly.vertexInitialization) {
321
+ mainInjections['vs:#main-start'] = mainInjections['vs:#main-start'] || [];
322
+ mainInjections['vs:#main-start'].push({
323
+ injection: assembly.vertexInitialization,
324
+ order: Number.MIN_SAFE_INTEGER
325
+ });
326
+ }
327
+ if (assembly.fragmentInitialization) {
328
+ mainInjections['fs:#main-start'] = mainInjections['fs:#main-start'] || [];
329
+ mainInjections['fs:#main-start'].push({
330
+ injection: assembly.fragmentInitialization,
331
+ order: Number.MIN_SAFE_INTEGER
332
+ });
333
+ }
334
+ }
335
+
336
+ export function getWGSLModuleInjections(module: ShaderModule): Record<string, ShaderInjection> {
337
+ return {
338
+ ...(module.instance?.normalizedInjections.vertex || {}),
339
+ ...(module.instance?.normalizedInjections.fragment || {})
340
+ };
341
+ }
342
+
343
+ export function getWGSLDeclarationInjections(
344
+ declarationInjections: Record<string, ShaderInjection[]>
345
+ ): Record<string, ShaderInjection[]> {
346
+ const unifiedDeclarations = [
347
+ ...(declarationInjections['vs:#decl'] || []),
348
+ ...(declarationInjections['fs:#decl'] || [])
349
+ ];
350
+
351
+ return unifiedDeclarations.length ? {'vs:#decl': unifiedDeclarations} : {};
352
+ }
353
+
354
+ export function getWGSLShaderHooks(
355
+ hookFunctionMap: ReturnType<typeof normalizeShaderHooks>,
356
+ hookInjections: Record<string, ShaderInjection[]>
357
+ ): string {
358
+ return (
359
+ getShaderHooks(hookFunctionMap.vertex, hookInjections, 'wgsl') +
360
+ getShaderHooks(hookFunctionMap.fragment, hookInjections, 'wgsl')
361
+ );
362
+ }
363
+
364
+ export function getUsedBindingsByGroupFromApplicationWGSL(
365
+ source: string
366
+ ): Map<number, Set<number>> {
367
+ const usedBindingsByGroup = new Map<number, Set<number>>();
368
+
369
+ for (const match of getWGSLBindingDeclarationMatches(
370
+ source,
371
+ WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES
372
+ )) {
373
+ const location = Number(match.bindingToken);
374
+ const group = Number(match.groupToken);
375
+
376
+ validateApplicationWGSLBinding(group, location, match.name);
377
+ registerUsedBindingLocation(
378
+ usedBindingsByGroup,
379
+ group,
380
+ location,
381
+ `application binding "${match.name}"`
382
+ );
383
+ }
384
+
385
+ return usedBindingsByGroup;
386
+ }
387
+
388
+ export function relocateWGSLApplicationBindings(source: string): {source: string} {
389
+ const declarationMatches = getWGSLBindingDeclarationMatches(
390
+ source,
391
+ WGSL_BINDING_DECLARATION_REGEXES
392
+ );
393
+ const usedBindingsByGroup = new Map<number, Set<number>>();
394
+
395
+ for (const declarationMatch of declarationMatches) {
396
+ if (declarationMatch.bindingToken === 'auto') {
397
+ continue;
398
+ }
399
+
400
+ const location = Number(declarationMatch.bindingToken);
401
+ const group = Number(declarationMatch.groupToken);
402
+
403
+ validateApplicationWGSLBinding(group, location, declarationMatch.name);
404
+ registerUsedBindingLocation(
405
+ usedBindingsByGroup,
406
+ group,
407
+ location,
408
+ `application binding "${declarationMatch.name}"`
409
+ );
410
+ }
411
+
412
+ const relocationState: WGSLApplicationRelocationState = {
413
+ sawSupportedBindingDeclaration: declarationMatches.length > 0
414
+ };
415
+
416
+ const relocatedSource = replaceWGSLBindingDeclarationMatches(
417
+ source,
418
+ WGSL_BINDING_DECLARATION_REGEXES,
419
+ declarationMatch =>
420
+ relocateWGSLApplicationBindingMatch(declarationMatch, usedBindingsByGroup, relocationState)
421
+ );
422
+
423
+ if (hasWGSLAutoBinding(source) && !relocationState.sawSupportedBindingDeclaration) {
424
+ throw new Error(
425
+ 'Unsupported @binding(auto) declaration form in application WGSL. ' +
426
+ 'Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.'
427
+ );
428
+ }
429
+
430
+ return {source: relocatedSource};
431
+ }
432
+
433
+ export function relocateWGSLModuleBindings(
434
+ moduleSource: string,
435
+ module: ShaderModule,
436
+ context: BindingRelocationContext
437
+ ): {source: string; bindingAssignments: WGSLBindingAssignment[]} {
438
+ const bindingAssignments: WGSLBindingAssignment[] = [];
439
+ const declarationMatches = getWGSLBindingDeclarationMatches(
440
+ moduleSource,
441
+ MODULE_WGSL_BINDING_DECLARATION_REGEXES
442
+ );
443
+ const relocationState: WGSLRelocationState = {
444
+ sawSupportedBindingDeclaration: declarationMatches.length > 0,
445
+ nextHintedBindingLocation:
446
+ typeof module.firstBindingSlot === 'number' ? module.firstBindingSlot : null
447
+ };
448
+
449
+ const relocatedSource = replaceWGSLBindingDeclarationMatches(
450
+ moduleSource,
451
+ MODULE_WGSL_BINDING_DECLARATION_REGEXES,
452
+ declarationMatch =>
453
+ relocateWGSLModuleBindingMatch(declarationMatch, {
454
+ module,
455
+ context,
456
+ bindingAssignments,
457
+ relocationState
458
+ })
459
+ );
460
+
461
+ if (hasWGSLAutoBinding(moduleSource) && !relocationState.sawSupportedBindingDeclaration) {
462
+ throw new Error(
463
+ `Unsupported @binding(auto) declaration form in module "${module.name}". ` +
464
+ 'Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.'
465
+ );
466
+ }
467
+
468
+ return {source: relocatedSource, bindingAssignments};
469
+ }
470
+
471
+ export function relocateWGSLModuleBindingMatch(
472
+ declarationMatch: WGSLBindingDeclarationMatch,
473
+ params: WGSLRelocationParams
474
+ ): string {
475
+ const {module, context, bindingAssignments, relocationState} = params;
476
+
477
+ const {match, bindingToken, groupToken, name} = declarationMatch;
478
+ const group = Number(groupToken);
479
+
480
+ if (bindingToken === 'auto') {
481
+ const registryKey = getBindingRegistryKey(group, module.name, name);
482
+ const registryLocation = context.bindingRegistry?.get(registryKey);
483
+ const location =
484
+ registryLocation !== undefined
485
+ ? registryLocation
486
+ : allocateAutoBindingLocation(
487
+ group,
488
+ context.usedBindingsByGroup,
489
+ module.name,
490
+ relocationState.nextHintedBindingLocation ?? undefined,
491
+ context.bindingRegistry
492
+ );
493
+ validateModuleWGSLBinding(module.name, group, location, name);
494
+ if (
495
+ registryLocation !== undefined &&
496
+ claimReservedBindingLocation(context.reservedBindingKeysByGroup, group, location, registryKey)
497
+ ) {
498
+ bindingAssignments.push({moduleName: module.name, name, group, location});
499
+ return match.replace(/@binding\(\s*auto\s*\)/, `@binding(${location})`);
500
+ }
501
+ registerUsedBindingLocation(
502
+ context.usedBindingsByGroup,
503
+ group,
504
+ location,
505
+ `module "${module.name}" binding "${name}"`
506
+ );
507
+ context.bindingRegistry?.set(registryKey, location);
508
+ bindingAssignments.push({moduleName: module.name, name, group, location});
509
+ if (relocationState.nextHintedBindingLocation !== null && registryLocation === undefined) {
510
+ relocationState.nextHintedBindingLocation = location + 1;
511
+ }
512
+ return match.replace(/@binding\(\s*auto\s*\)/, `@binding(${location})`);
513
+ }
514
+
515
+ const location = Number(bindingToken);
516
+ validateModuleWGSLBinding(module.name, group, location, name);
517
+ const registryKey = getBindingRegistryKey(group, module.name, name);
518
+ if (
519
+ !claimReservedBindingLocation(context.reservedBindingKeysByGroup, group, location, registryKey)
520
+ ) {
521
+ registerUsedBindingLocation(
522
+ context.usedBindingsByGroup,
523
+ group,
524
+ location,
525
+ `module "${module.name}" binding "${name}"`
526
+ );
527
+ }
528
+ bindingAssignments.push({moduleName: module.name, name, group, location});
529
+ return match;
530
+ }
531
+
532
+ export function relocateWGSLApplicationBindingMatch(
533
+ declarationMatch: WGSLBindingDeclarationMatch,
534
+ usedBindingsByGroup: Map<number, Set<number>>,
535
+ relocationState: WGSLApplicationRelocationState
536
+ ): string {
537
+ const {match, bindingToken, groupToken, name} = declarationMatch;
538
+ const group = Number(groupToken);
539
+
540
+ if (bindingToken === 'auto') {
541
+ const location = allocateApplicationAutoBindingLocation(group, usedBindingsByGroup);
542
+ validateApplicationWGSLBinding(group, location, name);
543
+ registerUsedBindingLocation(
544
+ usedBindingsByGroup,
545
+ group,
546
+ location,
547
+ `application binding "${name}"`
548
+ );
549
+ return match.replace(/@binding\(\s*auto\s*\)/, `@binding(${location})`);
550
+ }
551
+
552
+ relocationState.sawSupportedBindingDeclaration = true;
553
+ return match;
554
+ }
555
+
556
+ /** Reserve declared locations before reusing registry assignments or allocating new bindings. */
557
+ export function reserveModuleBindings(
558
+ modules: {module: ShaderModule; source: string}[],
559
+ bindingRegistry: Map<string, number> | undefined,
560
+ usedBindingsByGroup: Map<number, Set<number>>
561
+ ): Map<number, Map<number, string>> {
562
+ const reservedBindingKeysByGroup = new Map<number, Map<number, string>>();
563
+ const autoBindings: {module: ShaderModule; name: string; group: number}[] = [];
564
+
565
+ function reserveBinding(
566
+ group: number,
567
+ location: number,
568
+ registryKey: string,
569
+ label: string
570
+ ): void {
571
+ registerUsedBindingLocation(usedBindingsByGroup, group, location, label);
572
+ const reservedBindingKeys = reservedBindingKeysByGroup.get(group) || new Map<number, string>();
573
+ reservedBindingKeys.set(location, registryKey);
574
+ reservedBindingKeysByGroup.set(group, reservedBindingKeys);
575
+ }
576
+
577
+ for (const {module, source} of modules) {
578
+ for (const binding of getWGSLBindingDeclarationMatches(
579
+ source,
580
+ MODULE_WGSL_BINDING_DECLARATION_REGEXES
581
+ )) {
582
+ const group = Number(binding.groupToken);
583
+ if (binding.bindingToken === 'auto') {
584
+ autoBindings.push({module, name: binding.name, group});
585
+ continue;
586
+ }
587
+ const location = Number(binding.bindingToken);
588
+ validateModuleWGSLBinding(module.name, group, location, binding.name);
589
+ reserveBinding(
590
+ group,
591
+ location,
592
+ getBindingRegistryKey(group, module.name, binding.name),
593
+ `module "${module.name}" binding "${binding.name}"`
594
+ );
595
+ }
596
+ }
597
+
598
+ // Only auto declarations reuse registry entries. Explicit declarations already own their slots.
599
+ // Conflicting active assignments remain errors so previously assembled shaders keep their layout.
600
+ for (const {module, name, group} of autoBindings) {
601
+ const registryKey = getBindingRegistryKey(group, module.name, name);
602
+ const location = bindingRegistry?.get(registryKey);
603
+ if (location !== undefined) {
604
+ reserveBinding(group, location, registryKey, `registered module binding "${registryKey}"`);
605
+ }
606
+ }
607
+
608
+ return reservedBindingKeysByGroup;
609
+ }
610
+
611
+ export function claimReservedBindingLocation(
612
+ reservedBindingKeysByGroup: Map<number, Map<number, string>>,
613
+ group: number,
614
+ location: number,
615
+ registryKey: string
616
+ ): boolean {
617
+ const reservedBindingKeys = reservedBindingKeysByGroup.get(group);
618
+ if (!reservedBindingKeys) {
619
+ return false;
620
+ }
621
+
622
+ const reservedKey = reservedBindingKeys.get(location);
623
+ if (!reservedKey) {
624
+ return false;
625
+ }
626
+ if (reservedKey !== registryKey) {
627
+ throw new Error(
628
+ `Registered module binding "${registryKey}" collided with "${reservedKey}": group ${group}, binding ${location}.`
629
+ );
630
+ }
631
+ reservedBindingKeys.delete(location);
632
+ return true;
633
+ }
634
+
635
+ export function validateApplicationWGSLBinding(
636
+ group: number,
637
+ location: number,
638
+ name: string
639
+ ): void {
640
+ if (group === 0 && location >= RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT) {
641
+ throw new Error(
642
+ `Application binding "${name}" in group 0 uses reserved binding ${location}. ` +
643
+ `Application-owned explicit group-0 bindings must stay below ${RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT}.`
644
+ );
645
+ }
646
+ }
647
+
648
+ export function validateModuleWGSLBinding(
649
+ moduleName: string,
650
+ group: number,
651
+ location: number,
652
+ name: string
653
+ ): void {
654
+ if (group === 0 && location < RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT) {
655
+ throw new Error(
656
+ `Module "${moduleName}" binding "${name}" in group 0 uses reserved application binding ${location}. ` +
657
+ `Module-owned explicit group-0 bindings must be ${RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT} or higher.`
658
+ );
659
+ }
660
+ }
661
+
662
+ export function registerUsedBindingLocation(
663
+ usedBindingsByGroup: Map<number, Set<number>>,
664
+ group: number,
665
+ location: number,
666
+ label: string
667
+ ): void {
668
+ const usedBindings = usedBindingsByGroup.get(group) || new Set<number>();
669
+ if (usedBindings.has(location)) {
670
+ throw new Error(
671
+ `Duplicate WGSL binding assignment for ${label}: group ${group}, binding ${location}.`
672
+ );
673
+ }
674
+ usedBindings.add(location);
675
+ usedBindingsByGroup.set(group, usedBindings);
676
+ }
677
+
678
+ export function allocateAutoBindingLocation(
679
+ group: number,
680
+ usedBindingsByGroup: Map<number, Set<number>>,
681
+ moduleName: string,
682
+ preferredBindingLocation?: number,
683
+ bindingRegistry?: Map<string, number>
684
+ ): number {
685
+ const usedBindings = usedBindingsByGroup.get(group) || new Set<number>();
686
+ const registeredBindingLocations = new Set<number>();
687
+ const registryGroupPrefix = `${group}:`;
688
+ const registryModulePrefix = `${registryGroupPrefix}${moduleName}:`;
689
+ for (const [registryKey, location] of bindingRegistry || []) {
690
+ if (registryKey.startsWith(registryModulePrefix)) {
691
+ registeredBindingLocations.add(location);
692
+ }
693
+ }
694
+ let nextBinding =
695
+ preferredBindingLocation ??
696
+ (group === 0
697
+ ? RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT
698
+ : usedBindings.size > 0
699
+ ? Math.max(...usedBindings) + 1
700
+ : 0);
701
+
702
+ while (usedBindings.has(nextBinding) || registeredBindingLocations.has(nextBinding)) {
703
+ nextBinding++;
704
+ }
705
+
706
+ // Active modules were reserved above; only stale, inactive modules can own this free slot.
707
+ for (const [registryKey, location] of bindingRegistry || []) {
708
+ if (location === nextBinding && registryKey.startsWith(registryGroupPrefix)) {
709
+ bindingRegistry?.delete(registryKey);
710
+ }
711
+ }
712
+
713
+ return nextBinding;
714
+ }
715
+
716
+ export function allocateApplicationAutoBindingLocation(
717
+ group: number,
718
+ usedBindingsByGroup: Map<number, Set<number>>
719
+ ): number {
720
+ const usedBindings = usedBindingsByGroup.get(group) || new Set<number>();
721
+ let nextBinding = 0;
722
+
723
+ while (usedBindings.has(nextBinding)) {
724
+ nextBinding++;
725
+ }
726
+
727
+ return nextBinding;
728
+ }
729
+
730
+ export function assertNoUnresolvedAutoBindings(source: string): void {
731
+ const unresolvedBinding = getFirstWGSLAutoBindingDeclarationMatch(
732
+ source,
733
+ MODULE_WGSL_BINDING_DECLARATION_REGEXES
734
+ );
735
+ if (!unresolvedBinding) {
736
+ return;
737
+ }
738
+
739
+ const moduleName = getWGSLModuleNameAtIndex(source, unresolvedBinding.index);
740
+ if (moduleName) {
741
+ throw new Error(
742
+ `Unresolved @binding(auto) for module "${moduleName}" binding "${unresolvedBinding.name}" remained in assembled WGSL source.`
743
+ );
744
+ }
745
+
746
+ if (isInApplicationWGSLSection(source, unresolvedBinding.index)) {
747
+ throw new Error(
748
+ `Unresolved @binding(auto) for application binding "${unresolvedBinding.name}" remained in assembled WGSL source.`
749
+ );
750
+ }
751
+
752
+ throw new Error(
753
+ `Unresolved @binding(auto) remained in assembled WGSL source near "${formatWGSLSourceSnippet(unresolvedBinding.match)}".`
754
+ );
755
+ }
756
+
757
+ export function formatWGSLBindingAssignmentComments(
758
+ bindingAssignments: WGSLBindingAssignment[]
759
+ ): string {
760
+ if (bindingAssignments.length === 0) {
761
+ return '';
762
+ }
763
+
764
+ let source = '// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------\n';
765
+ for (const bindingAssignment of bindingAssignments) {
766
+ source += `// ${bindingAssignment.moduleName}.${bindingAssignment.name} -> @group(${bindingAssignment.group}) @binding(${bindingAssignment.location})\n`;
767
+ }
768
+ source += '\n';
769
+ return source;
770
+ }
771
+
772
+ export function getBindingRegistryKey(
773
+ group: number,
774
+ moduleName: string,
775
+ bindingName: string
776
+ ): string {
777
+ return `${group}:${moduleName}:${bindingName}`;
778
+ }
779
+
780
+ export function getWGSLModuleNameAtIndex(source: string, index: number): string | undefined {
781
+ const moduleHeaderRegex = /^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;
782
+ let moduleName: string | undefined;
783
+ let match: RegExpExecArray | null;
784
+
785
+ match = moduleHeaderRegex.exec(source);
786
+ while (match && match.index <= index) {
787
+ moduleName = match[1];
788
+ match = moduleHeaderRegex.exec(source);
789
+ }
790
+
791
+ return moduleName;
792
+ }
793
+
794
+ export function isInApplicationWGSLSection(source: string, index: number): boolean {
795
+ const injectionMarkerIndex = source.indexOf(INJECT_SHADER_DECLARATIONS);
796
+ return injectionMarkerIndex >= 0 ? index > injectionMarkerIndex : true;
797
+ }
798
+
799
+ export function formatWGSLSourceSnippet(source: string): string {
800
+ return source.replace(/\s+/g, ' ').trim();
801
+ }