@luma.gl/shadertools 9.0.0-beta.3 → 9.0.0-beta.5

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 (294) hide show
  1. package/dist/dist.dev.js +586 -776
  2. package/dist/index.cjs +206 -307
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/index.js +69 -50
  5. package/dist/lib/filters/prop-types.js +80 -67
  6. package/dist/lib/glsl-utils/get-shader-info.js +25 -22
  7. package/dist/lib/glsl-utils/highlight.js +8 -2
  8. package/dist/lib/glsl-utils/shader-utils.d.ts +1 -2
  9. package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
  10. package/dist/lib/glsl-utils/shader-utils.js +67 -90
  11. package/dist/lib/shader-assembler.js +82 -63
  12. package/dist/lib/shader-assembly/assemble-shaders.js +320 -223
  13. package/dist/lib/shader-assembly/platform-defines.js +39 -32
  14. package/dist/lib/shader-assembly/platform-info.js +2 -1
  15. package/dist/lib/shader-assembly/resolve-modules.js +54 -38
  16. package/dist/lib/shader-assembly/select-shaders.js +35 -29
  17. package/dist/lib/shader-assembly/shader-hooks.js +53 -51
  18. package/dist/lib/shader-assembly/shader-injections.js +107 -87
  19. package/dist/lib/shader-generator/generate-shader.js +11 -9
  20. package/dist/lib/shader-generator/glsl/generate-glsl.js +66 -58
  21. package/dist/lib/shader-generator/utils/capitalize.js +8 -2
  22. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +14 -12
  23. package/dist/lib/shader-module/normalize-shader-module.js +10 -9
  24. package/dist/lib/shader-module/shader-module-instance.js +109 -113
  25. package/dist/lib/shader-module/shader-module.js +2 -1
  26. package/dist/lib/shader-module/shader-pass.d.ts +1 -1
  27. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  28. package/dist/lib/shader-module/shader-pass.js +2 -1
  29. package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts +1 -1
  30. package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts.map +1 -1
  31. package/dist/lib/shader-transpiler/transpile-glsl-shader.js +59 -53
  32. package/dist/lib/utils/assert.js +7 -4
  33. package/dist/lib/wgsl/get-shader-layout-wgsl.js +56 -50
  34. package/dist/libs/wgsl-reflect/wgsl_reflect.module.js +3207 -2414
  35. package/dist/module-injectors.js +5 -4
  36. package/dist/modules/engine/geometry/geometry.js +13 -7
  37. package/dist/modules/engine/picking/picking.js +60 -49
  38. package/dist/modules/engine/project/project.js +52 -35
  39. package/dist/modules/engine/transform/transform.js +7 -5
  40. package/dist/modules/lighting/gouraud-material/gouraud-material.js +28 -28
  41. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +42 -0
  42. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -0
  43. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +134 -0
  44. package/dist/modules/lighting/gouraud-material/gouraud-shaders.glsl.js +45 -4
  45. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +2 -0
  46. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -0
  47. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +56 -0
  48. package/dist/modules/lighting/lights/lighting-uniforms.glsl.js +4 -3
  49. package/dist/modules/lighting/lights/lighting-uniforms.js +128 -128
  50. package/dist/modules/lighting/no-material/dirlight.js +38 -24
  51. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +2 -0
  52. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -0
  53. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +425 -0
  54. package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.d.ts.map +1 -1
  55. package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.js +10 -11
  56. package/dist/modules/lighting/pbr-material/pbr-material.js +56 -69
  57. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +2 -0
  58. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -0
  59. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +66 -0
  60. package/dist/modules/lighting/pbr-material/pbr-uniforms.glsl.js +4 -3
  61. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +2 -0
  62. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -0
  63. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +46 -0
  64. package/dist/modules/lighting/pbr-material/pbr-vertex.glsl.js +4 -3
  65. package/dist/modules/lighting/phong-material/phong-material.js +28 -28
  66. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +42 -0
  67. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -0
  68. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +137 -0
  69. package/dist/modules/lighting/phong-material/phong-shaders.glsl.js +45 -4
  70. package/dist/modules/math/fp32/fp32.js +10 -5
  71. package/dist/modules/math/random/random.js +7 -5
  72. package/dist/modules/module-injectors.js +5 -4
  73. package/dist/modules/postprocessing/fxaa/fxaa.js +74 -11
  74. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +2 -2
  75. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  76. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +22 -27
  77. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +1 -1
  78. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  79. package/dist/modules/postprocessing/image-adjust-filters/denoise.js +26 -27
  80. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +2 -2
  81. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  82. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +28 -28
  83. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +1 -1
  84. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  85. package/dist/modules/postprocessing/image-adjust-filters/noise.js +18 -19
  86. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +1 -1
  87. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  88. package/dist/modules/postprocessing/image-adjust-filters/sepia.js +19 -19
  89. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +1 -1
  90. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  91. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +12 -16
  92. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +2 -2
  93. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  94. package/dist/modules/postprocessing/image-adjust-filters/vignette.js +19 -24
  95. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +5 -5
  96. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  97. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +67 -52
  98. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +2 -2
  99. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  100. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +35 -40
  101. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +2 -2
  102. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  103. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +27 -28
  104. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +3 -3
  105. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  106. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +35 -40
  107. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +3 -3
  108. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  109. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +21 -28
  110. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +2 -2
  111. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  112. package/dist/modules/postprocessing/image-fun-filters/edgework.js +31 -31
  113. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +2 -2
  114. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  115. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +22 -26
  116. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +1 -1
  117. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
  118. package/dist/modules/postprocessing/image-fun-filters/ink.js +25 -24
  119. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +5 -5
  120. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  121. package/dist/modules/postprocessing/image-fun-filters/magnify.js +28 -29
  122. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +3 -3
  123. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  124. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +25 -32
  125. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +3 -3
  126. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
  127. package/dist/modules/postprocessing/image-warp-filters/swirl.js +23 -31
  128. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
  129. package/dist/modules/postprocessing/image-warp-filters/warp.js +9 -7
  130. package/dist/modules-webgl1/geometry/geometry.js +11 -7
  131. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +19 -16
  132. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +2 -0
  133. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -0
  134. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +37 -0
  135. package/dist/modules-webgl1/lighting/lights/lights.glsl.js +2 -3
  136. package/dist/modules-webgl1/lighting/lights/lights.js +80 -86
  137. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +2 -0
  138. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -0
  139. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +401 -0
  140. package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.d.ts.map +1 -1
  141. package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.js +10 -11
  142. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +2 -0
  143. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -0
  144. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +40 -0
  145. package/dist/modules-webgl1/lighting/pbr/pbr-vertex.glsl.js +2 -3
  146. package/dist/modules-webgl1/lighting/pbr/pbr.js +14 -11
  147. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +2 -0
  148. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -0
  149. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +76 -0
  150. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.js +2 -3
  151. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +31 -42
  152. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +2 -0
  153. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -0
  154. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +169 -0
  155. package/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js +3 -3
  156. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +2 -0
  157. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -0
  158. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +673 -0
  159. package/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js +3 -3
  160. package/dist/modules-webgl1/math/fp64/fp64-utils.js +32 -17
  161. package/dist/modules-webgl1/math/fp64/fp64.js +25 -18
  162. package/dist/modules-webgl1/project/project.js +35 -31
  163. package/dist/types.js +3 -2
  164. package/dist.min.js +1982 -4977
  165. package/package.json +8 -6
  166. package/src/lib/glsl-utils/shader-utils.ts +6 -24
  167. package/src/lib/shader-assembly/assemble-shaders.ts +1 -1
  168. package/src/lib/shader-module/shader-pass.ts +1 -1
  169. package/src/lib/shader-transpiler/transpile-glsl-shader.ts +9 -78
  170. package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
  171. package/src/modules/lighting/lights/lighting-uniforms.ts +1 -1
  172. package/src/modules/lighting/pbr-material/{pbr-fragment.glsl.ts → pbr-fragment-glsl.ts} +2 -8
  173. package/src/modules/lighting/pbr-material/pbr-material.ts +2 -2
  174. package/src/modules/lighting/phong-material/phong-material.ts +1 -1
  175. package/src/modules/postprocessing/fxaa/fxaa.ts +4 -4
  176. package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +4 -4
  177. package/src/modules/postprocessing/image-adjust-filters/denoise.ts +8 -8
  178. package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +7 -7
  179. package/src/modules/postprocessing/image-adjust-filters/noise.ts +2 -2
  180. package/src/modules/postprocessing/image-adjust-filters/sepia.ts +2 -2
  181. package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +2 -2
  182. package/src/modules/postprocessing/image-adjust-filters/vignette.ts +3 -3
  183. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +12 -12
  184. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +11 -9
  185. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +11 -9
  186. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +16 -16
  187. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +4 -4
  188. package/src/modules/postprocessing/image-fun-filters/edgework.ts +5 -5
  189. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +5 -5
  190. package/src/modules/postprocessing/image-fun-filters/ink.ts +7 -7
  191. package/src/modules/postprocessing/image-fun-filters/magnify.ts +9 -9
  192. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +7 -7
  193. package/src/modules/postprocessing/image-warp-filters/swirl.ts +6 -6
  194. package/src/modules/postprocessing/image-warp-filters/warp.ts +3 -2
  195. package/src/modules-webgl1/lighting/lights/lights.ts +1 -1
  196. package/src/modules-webgl1/lighting/pbr/{pbr-fragment.glsl.ts → pbr-fragment-glsl.ts} +2 -8
  197. package/src/modules-webgl1/lighting/pbr/pbr.ts +2 -2
  198. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts +1 -1
  199. package/src/modules-webgl1/math/fp64/fp64-utils.ts +1 -1
  200. package/src/modules-webgl1/math/fp64/fp64.ts +2 -2
  201. package/dist/index.js.map +0 -1
  202. package/dist/lib/filters/prop-types.js.map +0 -1
  203. package/dist/lib/glsl-utils/get-shader-info.js.map +0 -1
  204. package/dist/lib/glsl-utils/highlight.js.map +0 -1
  205. package/dist/lib/glsl-utils/shader-utils.js.map +0 -1
  206. package/dist/lib/shader-assembler.js.map +0 -1
  207. package/dist/lib/shader-assembly/assemble-shaders.js.map +0 -1
  208. package/dist/lib/shader-assembly/platform-defines.js.map +0 -1
  209. package/dist/lib/shader-assembly/platform-info.js.map +0 -1
  210. package/dist/lib/shader-assembly/resolve-modules.js.map +0 -1
  211. package/dist/lib/shader-assembly/select-shaders.js.map +0 -1
  212. package/dist/lib/shader-assembly/shader-hooks.js.map +0 -1
  213. package/dist/lib/shader-assembly/shader-injections.js.map +0 -1
  214. package/dist/lib/shader-generator/generate-shader.js.map +0 -1
  215. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +0 -1
  216. package/dist/lib/shader-generator/utils/capitalize.js.map +0 -1
  217. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +0 -1
  218. package/dist/lib/shader-module/normalize-shader-module.js.map +0 -1
  219. package/dist/lib/shader-module/shader-module-instance.js.map +0 -1
  220. package/dist/lib/shader-module/shader-module.js.map +0 -1
  221. package/dist/lib/shader-module/shader-pass.js.map +0 -1
  222. package/dist/lib/shader-transpiler/transpile-glsl-shader.js.map +0 -1
  223. package/dist/lib/utils/assert.js.map +0 -1
  224. package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +0 -1
  225. package/dist/libs/wgsl-reflect/wgsl_reflect.module.js.map +0 -1
  226. package/dist/module-injectors.js.map +0 -1
  227. package/dist/modules/engine/geometry/geometry.js.map +0 -1
  228. package/dist/modules/engine/picking/README.md +0 -88
  229. package/dist/modules/engine/picking/picking.js.map +0 -1
  230. package/dist/modules/engine/project/project.js.map +0 -1
  231. package/dist/modules/engine/transform/transform.js.map +0 -1
  232. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +0 -1
  233. package/dist/modules/lighting/gouraud-material/gouraud-shaders.glsl.js.map +0 -1
  234. package/dist/modules/lighting/lights/lighting-uniforms.glsl.js.map +0 -1
  235. package/dist/modules/lighting/lights/lighting-uniforms.js.map +0 -1
  236. package/dist/modules/lighting/no-material/dirlight.js.map +0 -1
  237. package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.js.map +0 -1
  238. package/dist/modules/lighting/pbr-material/pbr-material.js.map +0 -1
  239. package/dist/modules/lighting/pbr-material/pbr-uniforms.glsl.js.map +0 -1
  240. package/dist/modules/lighting/pbr-material/pbr-vertex.glsl.js.map +0 -1
  241. package/dist/modules/lighting/phong-material/phong-material.js.map +0 -1
  242. package/dist/modules/lighting/phong-material/phong-shaders.glsl.js.map +0 -1
  243. package/dist/modules/math/fp32/fp32.js.map +0 -1
  244. package/dist/modules/math/random/random.js.map +0 -1
  245. package/dist/modules/module-injectors.js.map +0 -1
  246. package/dist/modules/postprocessing/fxaa/fxaa.js.map +0 -1
  247. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js.map +0 -1
  248. package/dist/modules/postprocessing/image-adjust-filters/denoise.js.map +0 -1
  249. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js.map +0 -1
  250. package/dist/modules/postprocessing/image-adjust-filters/noise.js.map +0 -1
  251. package/dist/modules/postprocessing/image-adjust-filters/sepia.js.map +0 -1
  252. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js.map +0 -1
  253. package/dist/modules/postprocessing/image-adjust-filters/vignette.js.map +0 -1
  254. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js.map +0 -1
  255. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js.map +0 -1
  256. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js.map +0 -1
  257. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js.map +0 -1
  258. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js.map +0 -1
  259. package/dist/modules/postprocessing/image-fun-filters/edgework.js.map +0 -1
  260. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js.map +0 -1
  261. package/dist/modules/postprocessing/image-fun-filters/ink.js.map +0 -1
  262. package/dist/modules/postprocessing/image-fun-filters/magnify.js.map +0 -1
  263. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js.map +0 -1
  264. package/dist/modules/postprocessing/image-warp-filters/swirl.js.map +0 -1
  265. package/dist/modules/postprocessing/image-warp-filters/warp.js.map +0 -1
  266. package/dist/modules-webgl1/geometry/geometry.js.map +0 -1
  267. package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +0 -1
  268. package/dist/modules-webgl1/lighting/lights/lights.glsl.js.map +0 -1
  269. package/dist/modules-webgl1/lighting/lights/lights.js.map +0 -1
  270. package/dist/modules-webgl1/lighting/pbr/README.md +0 -12
  271. package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.js.map +0 -1
  272. package/dist/modules-webgl1/lighting/pbr/pbr-vertex.glsl.js.map +0 -1
  273. package/dist/modules-webgl1/lighting/pbr/pbr.js.map +0 -1
  274. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.js.map +0 -1
  275. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +0 -1
  276. package/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js.map +0 -1
  277. package/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js.map +0 -1
  278. package/dist/modules-webgl1/math/fp64/fp64-utils.js.map +0 -1
  279. package/dist/modules-webgl1/math/fp64/fp64.js.map +0 -1
  280. package/dist/modules-webgl1/project/README.md +0 -52
  281. package/dist/modules-webgl1/project/project.js.map +0 -1
  282. package/dist/types.js.map +0 -1
  283. package/src/.DS_Store +0 -0
  284. package/src/libs/.DS_Store +0 -0
  285. /package/src/modules/lighting/gouraud-material/{gouraud-shaders.glsl.ts → gouraud-shaders-glsl.ts} +0 -0
  286. /package/src/modules/lighting/lights/{lighting-uniforms.glsl.ts → lighting-uniforms-glsl.ts} +0 -0
  287. /package/src/modules/lighting/pbr-material/{pbr-uniforms.glsl.ts → pbr-uniforms-glsl.ts} +0 -0
  288. /package/src/modules/lighting/pbr-material/{pbr-vertex.glsl.ts → pbr-vertex-glsl.ts} +0 -0
  289. /package/src/modules/lighting/phong-material/{phong-shaders.glsl.ts → phong-shaders-glsl.ts} +0 -0
  290. /package/src/modules-webgl1/lighting/lights/{lights.glsl.ts → lights-glsl.ts} +0 -0
  291. /package/src/modules-webgl1/lighting/pbr/{pbr-vertex.glsl.ts → pbr-vertex-glsl.ts} +0 -0
  292. /package/src/modules-webgl1/lighting/phong-lighting/{phong-lighting.glsl.ts → phong-lighting-glsl.ts} +0 -0
  293. /package/src/modules-webgl1/math/fp64/{fp64-arithmetic.glsl.ts → fp64-arithmetic-glsl.ts} +0 -0
  294. /package/src/modules-webgl1/math/fp64/{fp64-functions.glsl.ts → fp64-functions-glsl.ts} +0 -0
package/dist/dist.dev.js CHANGED
@@ -10,6 +10,7 @@ var __exports__ = (() => {
10
10
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
11
  var __getOwnPropNames = Object.getOwnPropertyNames;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
14
  var __export = (target, all) => {
14
15
  for (var name in all)
15
16
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -23,6 +24,10 @@ var __exports__ = (() => {
23
24
  return to;
24
25
  };
25
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var __publicField = (obj, key, value) => {
28
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
29
+ return value;
30
+ };
26
31
 
27
32
  // src/index.ts
28
33
  var src_exports = {};
@@ -133,38 +138,20 @@ var __exports__ = (() => {
133
138
  function makePropValidator(propType) {
134
139
  let type = getTypeOf(propType);
135
140
  if (type !== "object") {
136
- return {
137
- value: propType,
138
- ...DEFAULT_PROP_VALIDATORS[type],
139
- type
140
- };
141
+ return { value: propType, ...DEFAULT_PROP_VALIDATORS[type], type };
141
142
  }
142
143
  if (typeof propType === "object") {
143
144
  if (!propType) {
144
- return {
145
- type: "object",
146
- value: null
147
- };
145
+ return { type: "object", value: null };
148
146
  }
149
147
  if (propType.type !== void 0) {
150
- return {
151
- ...propType,
152
- ...DEFAULT_PROP_VALIDATORS[propType.type],
153
- type: propType.type
154
- };
148
+ return { ...propType, ...DEFAULT_PROP_VALIDATORS[propType.type], type: propType.type };
155
149
  }
156
150
  if (propType.value === void 0) {
157
- return {
158
- type: "object",
159
- value: propType
160
- };
151
+ return { type: "object", value: propType };
161
152
  }
162
153
  type = getTypeOf(propType.value);
163
- return {
164
- ...propType,
165
- ...DEFAULT_PROP_VALIDATORS[type],
166
- type
167
- };
154
+ return { ...propType, ...DEFAULT_PROP_VALIDATORS[type], type };
168
155
  }
169
156
  throw new Error("props");
170
157
  }
@@ -214,10 +201,7 @@ var __exports__ = (() => {
214
201
  var fragments = [];
215
202
  var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
216
203
  function normalizeInjections(injections) {
217
- const result = {
218
- vertex: {},
219
- fragment: {}
220
- };
204
+ const result = { vertex: {}, fragment: {} };
221
205
  for (const hook in injections) {
222
206
  let injection = injections[hook];
223
207
  const stage = getHookStage(hook);
@@ -309,6 +293,14 @@ ${inject[key]}` : inject[key];
309
293
  // src/lib/shader-module/shader-module-instance.ts
310
294
  var index = 1;
311
295
  var ShaderModuleInstance = class {
296
+ name;
297
+ vs;
298
+ fs;
299
+ getModuleUniforms;
300
+ dependencies;
301
+ deprecations;
302
+ defines;
303
+ injections;
312
304
  uniforms = {};
313
305
  uniformTypes = {};
314
306
  static instantiateModules(modules) {
@@ -316,7 +308,10 @@ ${inject[key]}` : inject[key];
316
308
  if (module instanceof ShaderModuleInstance) {
317
309
  return module;
318
310
  }
319
- assert(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
311
+ assert(
312
+ typeof module !== "string",
313
+ `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`
314
+ );
320
315
  if (!module.name) {
321
316
  console.warn("shader module has no name");
322
317
  module.name = `shader-module-${index++}`;
@@ -351,6 +346,7 @@ ${inject[key]}` : inject[key];
351
346
  this.uniforms = makePropValidators(uniformPropTypes);
352
347
  }
353
348
  }
349
+ // Extracts the source code chunk for the specified shader type from the named shader module
354
350
  getModuleSource(stage) {
355
351
  let moduleSource;
356
352
  switch (stage) {
@@ -380,6 +376,7 @@ ${moduleSource}
380
376
  getDefines() {
381
377
  return this.defines;
382
378
  }
379
+ // Warn about deprecated uniforms or functions
383
380
  checkDeprecations(shaderSource, log) {
384
381
  this.deprecations.forEach((def) => {
385
382
  if (def.regex?.test(shaderSource)) {
@@ -429,21 +426,11 @@ ${moduleSource}
429
426
  function getShaderDependencies(modules) {
430
427
  const moduleMap = {};
431
428
  const moduleDepth = {};
432
- getDependencyGraph({
433
- modules,
434
- level: 0,
435
- moduleMap,
436
- moduleDepth
437
- });
429
+ getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
438
430
  return Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map((name) => moduleMap[name]);
439
431
  }
440
432
  function getDependencyGraph(options) {
441
- const {
442
- modules,
443
- level,
444
- moduleMap,
445
- moduleDepth
446
- } = options;
433
+ const { modules, level, moduleMap, moduleDepth } = options;
447
434
  if (level >= 5) {
448
435
  throw new Error("Possible loop in shader dependency graph");
449
436
  }
@@ -455,12 +442,7 @@ ${moduleSource}
455
442
  }
456
443
  for (const module of modules) {
457
444
  if (module.dependencies) {
458
- getDependencyGraph({
459
- modules: module.dependencies,
460
- level: level + 1,
461
- moduleMap,
462
- moduleDepth
463
- });
445
+ getDependencyGraph({ modules: module.dependencies, level: level + 1, moduleMap, moduleDepth });
464
446
  }
465
447
  }
466
448
  }
@@ -567,62 +549,47 @@ ${moduleSource}
567
549
  }
568
550
 
569
551
  // src/lib/shader-transpiler/transpile-glsl-shader.ts
570
- function transpileGLSLShader(source, targetGLSLVersion, stage) {
552
+ function transpileGLSLShader(source, stage) {
571
553
  const sourceGLSLVersion = Number(source.match(/^#version[ \t]+(\d+)/m)?.[1] || 100);
572
554
  if (sourceGLSLVersion !== 300) {
573
555
  throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");
574
556
  }
575
- switch (targetGLSLVersion) {
576
- case 300:
577
- switch (stage) {
578
- case "vertex":
579
- source = convertShader(source, ES300_VERTEX_REPLACEMENTS);
580
- return source;
581
- case "fragment":
582
- source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
583
- return source;
584
- default:
585
- throw new Error(stage);
586
- }
587
- case 100:
588
- switch (stage) {
589
- case "vertex":
590
- source = convertShader(source, ES100_VERTEX_REPLACEMENTS);
591
- return source;
592
- case "fragment":
593
- source = convertShader(source, ES100_FRAGMENT_REPLACEMENTS);
594
- source = convertFragmentShaderTo100(source);
595
- return source;
596
- default:
597
- throw new Error(stage);
598
- }
557
+ switch (stage) {
558
+ case "vertex":
559
+ source = convertShader(source, ES300_VERTEX_REPLACEMENTS);
560
+ return source;
561
+ case "fragment":
562
+ source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
563
+ return source;
599
564
  default:
600
- throw new Error(String(targetGLSLVersion));
601
- }
602
- }
603
- var ES300_REPLACEMENTS = [[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/, "#version 300 es\n"], [/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g, "textureLod("], [/\btexture(2D|2DProj|Cube)(EXT)?\(/g, "texture("]];
604
- var ES300_VERTEX_REPLACEMENTS = [...ES300_REPLACEMENTS, [makeVariableTextRegExp("attribute"), "in $1"], [makeVariableTextRegExp("varying"), "out $1"]];
605
- var ES300_FRAGMENT_REPLACEMENTS = [...ES300_REPLACEMENTS, [makeVariableTextRegExp("varying"), "in $1"]];
606
- var ES100_REPLACEMENTS = [[/^#version[ \t]+300[ \t]+es/, "#version 100"], [/\btexture(2D|2DProj|Cube)Lod\(/g, "texture$1LodEXT("], [/\btexture\(/g, "texture2D("], [/\btextureLod\(/g, "texture2DLodEXT("]];
607
- var ES100_VERTEX_REPLACEMENTS = [...ES100_REPLACEMENTS, [makeVariableTextRegExp("in"), "attribute $1"], [makeVariableTextRegExp("out"), "varying $1"]];
608
- var ES100_FRAGMENT_REPLACEMENTS = [...ES100_REPLACEMENTS, [makeVariableTextRegExp("in"), "varying $1"]];
609
- var ES100_FRAGMENT_OUTPUT_NAME = "gl_FragColor";
610
- var ES300_FRAGMENT_OUTPUT_REGEX = /\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/;
565
+ throw new Error(stage);
566
+ }
567
+ }
568
+ var ES300_REPLACEMENTS = [
569
+ // Fix poorly formatted version directive
570
+ [/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/, "#version 300 es\n"],
571
+ // The individual `texture...()` functions were replaced with `texture()` overloads
572
+ [/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g, "textureLod("],
573
+ [/\btexture(2D|2DProj|Cube)(EXT)?\(/g, "texture("]
574
+ ];
575
+ var ES300_VERTEX_REPLACEMENTS = [
576
+ ...ES300_REPLACEMENTS,
577
+ // `attribute` keyword replaced with `in`
578
+ [makeVariableTextRegExp("attribute"), "in $1"],
579
+ // `varying` keyword replaced with `out`
580
+ [makeVariableTextRegExp("varying"), "out $1"]
581
+ ];
582
+ var ES300_FRAGMENT_REPLACEMENTS = [
583
+ ...ES300_REPLACEMENTS,
584
+ // `varying` keyword replaced with `in`
585
+ [makeVariableTextRegExp("varying"), "in $1"]
586
+ ];
611
587
  function convertShader(source, replacements) {
612
588
  for (const [pattern, replacement] of replacements) {
613
589
  source = source.replace(pattern, replacement);
614
590
  }
615
591
  return source;
616
592
  }
617
- function convertFragmentShaderTo100(source) {
618
- source = convertShader(source, ES100_FRAGMENT_REPLACEMENTS);
619
- const outputMatch = ES300_FRAGMENT_OUTPUT_REGEX.exec(source);
620
- if (outputMatch) {
621
- const outputName = outputMatch[1];
622
- source = source.replace(ES300_FRAGMENT_OUTPUT_REGEX, "").replace(new RegExp(`\\b${outputName}\\b`, "g"), ES100_FRAGMENT_OUTPUT_NAME);
623
- }
624
- return source;
625
- }
626
593
  function makeVariableTextRegExp(qualifier) {
627
594
  return new RegExp(`\\b${qualifier}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`, "g");
628
595
  }
@@ -653,10 +620,7 @@ ${moduleSource}
653
620
  return result;
654
621
  }
655
622
  function normalizeShaderHooks(hookFunctions) {
656
- const result = {
657
- vertex: {},
658
- fragment: {}
659
- };
623
+ const result = { vertex: {}, fragment: {} };
660
624
  for (const hookFunction of hookFunctions) {
661
625
  let opts;
662
626
  let hook;
@@ -670,9 +634,7 @@ ${moduleSource}
670
634
  hook = hook.trim();
671
635
  const [shaderStage, signature] = hook.split(":");
672
636
  const name = hook.replace(/\(.+/, "");
673
- const normalizedHook = Object.assign(opts, {
674
- signature
675
- });
637
+ const normalizedHook = Object.assign(opts, { signature });
676
638
  switch (shaderStage) {
677
639
  case "vs":
678
640
  result.vertex[name] = normalizedHook;
@@ -724,51 +686,30 @@ ${DECLARATION_INJECT_MARKER}
724
686
  precision highp float;
725
687
  `;
726
688
  function assembleShaders(options) {
727
- const {
728
- vs: vs6,
729
- fs: fs28
730
- } = options;
689
+ const { vs: vs6, fs: fs28 } = options;
731
690
  const modules = resolveModules(options.modules || []);
732
691
  switch (options.platformInfo.shaderLanguage) {
733
692
  case "glsl":
734
693
  return {
735
- vs: assembleGLSLShader(options.platformInfo, {
736
- ...options,
737
- source: vs6,
738
- stage: "vertex",
739
- modules
740
- }),
741
- fs: assembleGLSLShader(options.platformInfo, {
742
- ...options,
743
- source: fs28,
744
- stage: "fragment",
745
- modules
746
- }),
694
+ vs: assembleGLSLShader(options.platformInfo, { ...options, source: vs6, stage: "vertex", modules }),
695
+ fs: assembleGLSLShader(options.platformInfo, { ...options, source: fs28, stage: "fragment", modules }),
747
696
  getUniforms: assembleGetUniforms(modules)
748
697
  };
749
698
  case "wgsl":
750
699
  return {
751
- vs: assembleWGSLShader(options.platformInfo, {
752
- ...options,
753
- source: vs6,
754
- stage: "vertex",
755
- modules
756
- }),
757
- fs: assembleWGSLShader(options.platformInfo, {
758
- ...options,
759
- source: fs28,
760
- stage: "fragment",
761
- modules
762
- }),
700
+ vs: assembleWGSLShader(options.platformInfo, { ...options, source: vs6, stage: "vertex", modules }),
701
+ fs: assembleWGSLShader(options.platformInfo, { ...options, source: fs28, stage: "fragment", modules }),
763
702
  getUniforms: assembleGetUniforms(modules)
764
703
  };
765
704
  }
766
705
  }
767
706
  function assembleWGSLShader(platformInfo, options) {
768
707
  const {
708
+ // id,
769
709
  source,
770
710
  stage,
771
711
  modules,
712
+ // defines = {},
772
713
  hookFunctions = [],
773
714
  inject = {},
774
715
  log
@@ -781,10 +722,7 @@ precision highp float;
781
722
  const declInjections = {};
782
723
  const mainInjections = {};
783
724
  for (const key in inject) {
784
- const injection = typeof inject[key] === "string" ? {
785
- injection: inject[key],
786
- order: 0
787
- } : inject[key];
725
+ const injection = typeof inject[key] === "string" ? { injection: inject[key], order: 0 } : inject[key];
788
726
  const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
789
727
  if (match) {
790
728
  const hash = match[2];
@@ -862,11 +800,7 @@ precision highp float;
862
800
  assembledSource = prologue ? `${sourceVersionDirective}
863
801
 
864
802
  // ----- PROLOGUE -------------------------
865
- ${getShaderNameDefine({
866
- id,
867
- source,
868
- stage
869
- })}
803
+ ${getShaderNameDefine({ id, source, stage })}
870
804
  ${`#define SHADER_TYPE_${stage.toUpperCase()}`}
871
805
  ${getPlatformShaderDefines(platformInfo)}
872
806
  ${getVersionDefines(platformInfo)}
@@ -885,10 +819,7 @@ ${getApplicationDefines(allDefines)}
885
819
  const declInjections = {};
886
820
  const mainInjections = {};
887
821
  for (const key in inject) {
888
- const injection = typeof inject[key] === "string" ? {
889
- injection: inject[key],
890
- order: 0
891
- } : inject[key];
822
+ const injection = typeof inject[key] === "string" ? { injection: inject[key], order: 0 } : inject[key];
892
823
  const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
893
824
  if (match) {
894
825
  const hash = match[2];
@@ -933,7 +864,7 @@ ${getApplicationDefines(allDefines)}
933
864
  assembledSource += coreSource;
934
865
  assembledSource = injectShader(assembledSource, stage, mainInjections);
935
866
  if (language === "glsl" && sourceVersion !== targetVersion) {
936
- assembledSource = transpileGLSLShader(assembledSource, targetVersion, stage);
867
+ assembledSource = transpileGLSLShader(assembledSource, stage);
937
868
  }
938
869
  return assembledSource.trim();
939
870
  }
@@ -948,11 +879,7 @@ ${getApplicationDefines(allDefines)}
948
879
  };
949
880
  }
950
881
  function getShaderNameDefine(options) {
951
- const {
952
- id,
953
- source,
954
- stage
955
- } = options;
882
+ const { id, source, stage } = options;
956
883
  const injectShaderName = id && source.indexOf("SHADER_NAME") === -1;
957
884
  return injectShaderName ? `
958
885
  #define SHADER_NAME ${id}_${stage}
@@ -981,11 +908,7 @@ ${getApplicationDefines(allDefines)}
981
908
  if (props.fs) {
982
909
  fs28 = getShaderSource(props.platformInfo, props.fs);
983
910
  }
984
- return {
985
- ...props,
986
- vs: vs6,
987
- fs: fs28
988
- };
911
+ return { ...props, vs: vs6, fs: fs28 };
989
912
  }
990
913
  function getShaderSource(platformInfo, shader) {
991
914
  if (typeof shader === "string") {
@@ -1006,45 +929,63 @@ ${getApplicationDefines(allDefines)}
1006
929
  }
1007
930
 
1008
931
  // src/lib/shader-assembler.ts
1009
- var ShaderAssembler = class {
932
+ var _ShaderAssembler = class {
933
+ /** Hook functions */
1010
934
  _hookFunctions = [];
935
+ /** Shader modules */
1011
936
  _defaultModules = [];
937
+ /**
938
+ * A default shader assembler instance - the natural place to register default modules and hooks
939
+ * @returns
940
+ */
1012
941
  static getDefaultShaderAssembler() {
1013
- ShaderAssembler.defaultShaderAssembler = ShaderAssembler.defaultShaderAssembler || new ShaderAssembler();
1014
- return ShaderAssembler.defaultShaderAssembler;
942
+ _ShaderAssembler.defaultShaderAssembler = _ShaderAssembler.defaultShaderAssembler || new _ShaderAssembler();
943
+ return _ShaderAssembler.defaultShaderAssembler;
1015
944
  }
945
+ /**
946
+ * Add a default module that does not have to be provided with every call to assembleShaders()
947
+ */
1016
948
  addDefaultModule(module) {
1017
- if (!this._defaultModules.find((m) => m.name === (typeof module === "string" ? module : module.name))) {
949
+ if (!this._defaultModules.find(
950
+ (m) => m.name === (typeof module === "string" ? module : module.name)
951
+ )) {
1018
952
  this._defaultModules.push(module);
1019
953
  }
1020
954
  }
955
+ /**
956
+ * Remove a default module
957
+ */
1021
958
  removeDefaultModule(module) {
1022
959
  const moduleName = typeof module === "string" ? module : module.name;
1023
960
  this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
1024
961
  }
962
+ /**
963
+ * Register a shader hook
964
+ * @param hook
965
+ * @param opts
966
+ */
1025
967
  addShaderHook(hook, opts) {
1026
968
  if (opts) {
1027
- hook = Object.assign(opts, {
1028
- hook
1029
- });
969
+ hook = Object.assign(opts, { hook });
1030
970
  }
1031
971
  this._hookFunctions.push(hook);
1032
972
  }
973
+ /**
974
+ * Assemble a pair of shaders into a single shader program
975
+ * @param platformInfo
976
+ * @param props
977
+ * @returns
978
+ */
1033
979
  assembleShaders(props) {
1034
980
  const modules = this._getModuleList(props.modules);
1035
981
  const hookFunctions = this._hookFunctions;
1036
982
  const options = selectShaders(props);
1037
- const assembled = assembleShaders({
1038
- platformInfo: props.platformInfo,
1039
- ...options,
1040
- modules,
1041
- hookFunctions
1042
- });
1043
- return {
1044
- ...assembled,
1045
- modules
1046
- };
983
+ const assembled = assembleShaders({ platformInfo: props.platformInfo, ...options, modules, hookFunctions });
984
+ return { ...assembled, modules };
1047
985
  }
986
+ /**
987
+ * Dedupe and combine with default modules
988
+ */
1048
989
  _getModuleList(appModules = []) {
1049
990
  const modules = new Array(this._defaultModules.length + appModules.length);
1050
991
  const seen = {};
@@ -1067,6 +1008,9 @@ ${getApplicationDefines(allDefines)}
1067
1008
  return ShaderModuleInstance.instantiateModules(modules);
1068
1009
  }
1069
1010
  };
1011
+ var ShaderAssembler = _ShaderAssembler;
1012
+ /** Default ShaderAssembler instance */
1013
+ __publicField(ShaderAssembler, "defaultShaderAssembler");
1070
1014
 
1071
1015
  // src/lib/shader-module/normalize-shader-module.ts
1072
1016
  function normalizeShaderModule(module) {
@@ -1081,7 +1025,6 @@ ${getApplicationDefines(allDefines)}
1081
1025
  }
1082
1026
 
1083
1027
  // src/lib/glsl-utils/shader-utils.ts
1084
- var FS100 = glsl`void main() {gl_FragColor = vec4(0);}`;
1085
1028
  var FS_GLES = glsl`\
1086
1029
  out vec4 transform_output;
1087
1030
  void main() {
@@ -1097,44 +1040,23 @@ ${FS_GLES}`;
1097
1040
  return null;
1098
1041
  }
1099
1042
  const name = definition.split(";")[0];
1100
- return {
1101
- qualifier,
1102
- type,
1103
- name
1104
- };
1043
+ return { qualifier, type, name };
1105
1044
  }
1106
1045
  function getPassthroughFS(options) {
1107
- const {
1108
- version = 100,
1109
- input,
1110
- inputChannels,
1111
- output
1112
- } = options || {};
1046
+ const { input, inputChannels, output } = options || {};
1113
1047
  if (!input) {
1114
- if (version === 300) {
1115
- return FS300;
1116
- } else if (version > 300) {
1117
- return `#version ${version}
1118
- ${FS_GLES}`;
1119
- }
1120
- return FS100;
1048
+ return FS300;
1121
1049
  }
1122
1050
  if (!inputChannels) {
1123
1051
  throw new Error("inputChannels");
1124
1052
  }
1125
1053
  const inputType = channelCountToType(inputChannels);
1126
1054
  const outputValue = convertToVec4(input, inputChannels);
1127
- if (version >= 300) {
1128
- return `#version ${version} ${version === 300 ? "es" : ""}
1055
+ return `#version 300 es
1129
1056
  in ${inputType} ${input};
1130
1057
  out vec4 ${output};
1131
1058
  void main() {
1132
1059
  ${output} = ${outputValue};
1133
- }`;
1134
- }
1135
- return `varying ${inputType} ${input};
1136
- void main() {
1137
- gl_FragColor = ${outputValue};
1138
1060
  }`;
1139
1061
  }
1140
1062
  function typeToChannelSuffix(type) {
@@ -1603,6 +1525,7 @@ void main() {
1603
1525
  get isStruct() {
1604
1526
  return true;
1605
1527
  }
1528
+ /// Return the index of the member with the given name, or -1 if not found.
1606
1529
  getMemberIndex(name) {
1607
1530
  for (let i = 0; i < this.members.length; i++) {
1608
1531
  if (this.members[i].name == name)
@@ -2153,6 +2076,12 @@ void main() {
2153
2076
  rgba32sint: new TokenType("rgba32sint", TokenClass.keyword, "rgba32sint"),
2154
2077
  rgba32float: new TokenType("rgba32float", TokenClass.keyword, "rgba32float"),
2155
2078
  static_assert: new TokenType("static_assert", TokenClass.keyword, "static_assert")
2079
+ // WGSL grammar has a few keywords that have different token names than the strings they
2080
+ // represent. Aliasing them here.
2081
+ /*int32: new TokenType("i32", TokenClass.keyword, "i32"),
2082
+ uint32: new TokenType("u32", TokenClass.keyword, "u32"),
2083
+ float32: new TokenType("f32", TokenClass.keyword, "f32"),
2084
+ pointer: new TokenType("ptr", TokenClass.keyword, "ptr"),*/
2156
2085
  };
2157
2086
  TokenTypes.tokens = {
2158
2087
  decimal_float_literal: new TokenType("decimal_float_literal", TokenClass.token, /((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),
@@ -2209,23 +2138,146 @@ void main() {
2209
2138
  shift_right_equal: new TokenType("shift_right_equal", TokenClass.token, ">>="),
2210
2139
  shift_left_equal: new TokenType("shift_left_equal", TokenClass.token, "<<=")
2211
2140
  };
2212
- TokenTypes.storage_class = [_a.keywords.function, _a.keywords.private, _a.keywords.workgroup, _a.keywords.uniform, _a.keywords.storage];
2213
- TokenTypes.access_mode = [_a.keywords.read, _a.keywords.write, _a.keywords.read_write];
2214
- TokenTypes.sampler_type = [_a.keywords.sampler, _a.keywords.sampler_comparison];
2215
- TokenTypes.sampled_texture_type = [_a.keywords.texture_1d, _a.keywords.texture_2d, _a.keywords.texture_2d_array, _a.keywords.texture_3d, _a.keywords.texture_cube, _a.keywords.texture_cube_array];
2216
- TokenTypes.multisampled_texture_type = [_a.keywords.texture_multisampled_2d];
2217
- TokenTypes.storage_texture_type = [_a.keywords.texture_storage_1d, _a.keywords.texture_storage_2d, _a.keywords.texture_storage_2d_array, _a.keywords.texture_storage_3d];
2218
- TokenTypes.depth_texture_type = [_a.keywords.texture_depth_2d, _a.keywords.texture_depth_2d_array, _a.keywords.texture_depth_cube, _a.keywords.texture_depth_cube_array, _a.keywords.texture_depth_multisampled_2d];
2141
+ TokenTypes.storage_class = [
2142
+ _a.keywords.function,
2143
+ _a.keywords.private,
2144
+ _a.keywords.workgroup,
2145
+ _a.keywords.uniform,
2146
+ _a.keywords.storage
2147
+ ];
2148
+ TokenTypes.access_mode = [
2149
+ _a.keywords.read,
2150
+ _a.keywords.write,
2151
+ _a.keywords.read_write
2152
+ ];
2153
+ TokenTypes.sampler_type = [
2154
+ _a.keywords.sampler,
2155
+ _a.keywords.sampler_comparison
2156
+ ];
2157
+ TokenTypes.sampled_texture_type = [
2158
+ _a.keywords.texture_1d,
2159
+ _a.keywords.texture_2d,
2160
+ _a.keywords.texture_2d_array,
2161
+ _a.keywords.texture_3d,
2162
+ _a.keywords.texture_cube,
2163
+ _a.keywords.texture_cube_array
2164
+ ];
2165
+ TokenTypes.multisampled_texture_type = [
2166
+ _a.keywords.texture_multisampled_2d
2167
+ ];
2168
+ TokenTypes.storage_texture_type = [
2169
+ _a.keywords.texture_storage_1d,
2170
+ _a.keywords.texture_storage_2d,
2171
+ _a.keywords.texture_storage_2d_array,
2172
+ _a.keywords.texture_storage_3d
2173
+ ];
2174
+ TokenTypes.depth_texture_type = [
2175
+ _a.keywords.texture_depth_2d,
2176
+ _a.keywords.texture_depth_2d_array,
2177
+ _a.keywords.texture_depth_cube,
2178
+ _a.keywords.texture_depth_cube_array,
2179
+ _a.keywords.texture_depth_multisampled_2d
2180
+ ];
2219
2181
  TokenTypes.texture_external_type = [_a.keywords.texture_external];
2220
- TokenTypes.any_texture_type = [..._a.sampled_texture_type, ..._a.multisampled_texture_type, ..._a.storage_texture_type, ..._a.depth_texture_type, ..._a.texture_external_type];
2221
- TokenTypes.texel_format = [_a.keywords.r8unorm, _a.keywords.r8snorm, _a.keywords.r8uint, _a.keywords.r8sint, _a.keywords.r16uint, _a.keywords.r16sint, _a.keywords.r16float, _a.keywords.rg8unorm, _a.keywords.rg8snorm, _a.keywords.rg8uint, _a.keywords.rg8sint, _a.keywords.r32uint, _a.keywords.r32sint, _a.keywords.r32float, _a.keywords.rg16uint, _a.keywords.rg16sint, _a.keywords.rg16float, _a.keywords.rgba8unorm, _a.keywords.rgba8unorm_srgb, _a.keywords.rgba8snorm, _a.keywords.rgba8uint, _a.keywords.rgba8sint, _a.keywords.bgra8unorm, _a.keywords.bgra8unorm_srgb, _a.keywords.rgb10a2unorm, _a.keywords.rg11b10float, _a.keywords.rg32uint, _a.keywords.rg32sint, _a.keywords.rg32float, _a.keywords.rgba16uint, _a.keywords.rgba16sint, _a.keywords.rgba16float, _a.keywords.rgba32uint, _a.keywords.rgba32sint, _a.keywords.rgba32float];
2222
- TokenTypes.const_literal = [_a.tokens.int_literal, _a.tokens.uint_literal, _a.tokens.decimal_float_literal, _a.tokens.hex_float_literal, _a.keywords.true, _a.keywords.false];
2223
- TokenTypes.literal_or_ident = [_a.tokens.ident, _a.tokens.int_literal, _a.tokens.uint_literal, _a.tokens.decimal_float_literal, _a.tokens.hex_float_literal];
2224
- TokenTypes.element_count_expression = [_a.tokens.int_literal, _a.tokens.uint_literal, _a.tokens.ident];
2225
- TokenTypes.template_types = [_a.keywords.vec2, _a.keywords.vec3, _a.keywords.vec4, _a.keywords.mat2x2, _a.keywords.mat2x3, _a.keywords.mat2x4, _a.keywords.mat3x2, _a.keywords.mat3x3, _a.keywords.mat3x4, _a.keywords.mat4x2, _a.keywords.mat4x3, _a.keywords.mat4x4, _a.keywords.atomic, _a.keywords.bitcast, ..._a.any_texture_type];
2182
+ TokenTypes.any_texture_type = [
2183
+ ..._a.sampled_texture_type,
2184
+ ..._a.multisampled_texture_type,
2185
+ ..._a.storage_texture_type,
2186
+ ..._a.depth_texture_type,
2187
+ ..._a.texture_external_type
2188
+ ];
2189
+ TokenTypes.texel_format = [
2190
+ _a.keywords.r8unorm,
2191
+ _a.keywords.r8snorm,
2192
+ _a.keywords.r8uint,
2193
+ _a.keywords.r8sint,
2194
+ _a.keywords.r16uint,
2195
+ _a.keywords.r16sint,
2196
+ _a.keywords.r16float,
2197
+ _a.keywords.rg8unorm,
2198
+ _a.keywords.rg8snorm,
2199
+ _a.keywords.rg8uint,
2200
+ _a.keywords.rg8sint,
2201
+ _a.keywords.r32uint,
2202
+ _a.keywords.r32sint,
2203
+ _a.keywords.r32float,
2204
+ _a.keywords.rg16uint,
2205
+ _a.keywords.rg16sint,
2206
+ _a.keywords.rg16float,
2207
+ _a.keywords.rgba8unorm,
2208
+ _a.keywords.rgba8unorm_srgb,
2209
+ _a.keywords.rgba8snorm,
2210
+ _a.keywords.rgba8uint,
2211
+ _a.keywords.rgba8sint,
2212
+ _a.keywords.bgra8unorm,
2213
+ _a.keywords.bgra8unorm_srgb,
2214
+ _a.keywords.rgb10a2unorm,
2215
+ _a.keywords.rg11b10float,
2216
+ _a.keywords.rg32uint,
2217
+ _a.keywords.rg32sint,
2218
+ _a.keywords.rg32float,
2219
+ _a.keywords.rgba16uint,
2220
+ _a.keywords.rgba16sint,
2221
+ _a.keywords.rgba16float,
2222
+ _a.keywords.rgba32uint,
2223
+ _a.keywords.rgba32sint,
2224
+ _a.keywords.rgba32float
2225
+ ];
2226
+ TokenTypes.const_literal = [
2227
+ _a.tokens.int_literal,
2228
+ _a.tokens.uint_literal,
2229
+ _a.tokens.decimal_float_literal,
2230
+ _a.tokens.hex_float_literal,
2231
+ _a.keywords.true,
2232
+ _a.keywords.false
2233
+ ];
2234
+ TokenTypes.literal_or_ident = [
2235
+ _a.tokens.ident,
2236
+ _a.tokens.int_literal,
2237
+ _a.tokens.uint_literal,
2238
+ _a.tokens.decimal_float_literal,
2239
+ _a.tokens.hex_float_literal
2240
+ ];
2241
+ TokenTypes.element_count_expression = [
2242
+ _a.tokens.int_literal,
2243
+ _a.tokens.uint_literal,
2244
+ _a.tokens.ident
2245
+ ];
2246
+ TokenTypes.template_types = [
2247
+ _a.keywords.vec2,
2248
+ _a.keywords.vec3,
2249
+ _a.keywords.vec4,
2250
+ _a.keywords.mat2x2,
2251
+ _a.keywords.mat2x3,
2252
+ _a.keywords.mat2x4,
2253
+ _a.keywords.mat3x2,
2254
+ _a.keywords.mat3x3,
2255
+ _a.keywords.mat3x4,
2256
+ _a.keywords.mat4x2,
2257
+ _a.keywords.mat4x3,
2258
+ _a.keywords.mat4x4,
2259
+ _a.keywords.atomic,
2260
+ _a.keywords.bitcast,
2261
+ ..._a.any_texture_type
2262
+ ];
2226
2263
  TokenTypes.attribute_name = [_a.tokens.ident, _a.keywords.block];
2227
- TokenTypes.assignment_operators = [_a.tokens.equal, _a.tokens.plus_equal, _a.tokens.minus_equal, _a.tokens.times_equal, _a.tokens.division_equal, _a.tokens.modulo_equal, _a.tokens.and_equal, _a.tokens.or_equal, _a.tokens.xor_equal, _a.tokens.shift_right_equal, _a.tokens.shift_left_equal];
2228
- TokenTypes.increment_operators = [_a.tokens.plus_plus, _a.tokens.minus_minus];
2264
+ TokenTypes.assignment_operators = [
2265
+ _a.tokens.equal,
2266
+ _a.tokens.plus_equal,
2267
+ _a.tokens.minus_equal,
2268
+ _a.tokens.times_equal,
2269
+ _a.tokens.division_equal,
2270
+ _a.tokens.modulo_equal,
2271
+ _a.tokens.and_equal,
2272
+ _a.tokens.or_equal,
2273
+ _a.tokens.xor_equal,
2274
+ _a.tokens.shift_right_equal,
2275
+ _a.tokens.shift_left_equal
2276
+ ];
2277
+ TokenTypes.increment_operators = [
2278
+ _a.tokens.plus_plus,
2279
+ _a.tokens.minus_minus
2280
+ ];
2229
2281
  var Token = class {
2230
2282
  constructor(type, lexeme, line) {
2231
2283
  this.type = type;
@@ -2253,6 +2305,7 @@ void main() {
2253
2305
  this._line = 1;
2254
2306
  this._source = source !== null && source !== void 0 ? source : "";
2255
2307
  }
2308
+ /// Scan all tokens from the source.
2256
2309
  scanTokens() {
2257
2310
  while (!this._isAtEnd()) {
2258
2311
  this._start = this._current;
@@ -2262,6 +2315,7 @@ void main() {
2262
2315
  this._tokens.push(new Token(TokenTypes.eof, "", this._line));
2263
2316
  return this._tokens;
2264
2317
  }
2318
+ /// Scan a single token from the source.
2265
2319
  scanToken() {
2266
2320
  let lexeme = this._advance();
2267
2321
  if (lexeme == "\n") {
@@ -2618,7 +2672,11 @@ void main() {
2618
2672
  let result = null;
2619
2673
  if (this._check(TokenTypes.keywords.return))
2620
2674
  result = this._return_statement();
2621
- else if (this._check([TokenTypes.keywords.var, TokenTypes.keywords.let, TokenTypes.keywords.const]))
2675
+ else if (this._check([
2676
+ TokenTypes.keywords.var,
2677
+ TokenTypes.keywords.let,
2678
+ TokenTypes.keywords.const
2679
+ ]))
2622
2680
  result = this._variable_statement();
2623
2681
  else if (this._match(TokenTypes.keywords.discard))
2624
2682
  result = new Discard();
@@ -2803,7 +2861,9 @@ void main() {
2803
2861
  }
2804
2862
  _case_selectors() {
2805
2863
  var _a2, _b, _c, _d;
2806
- const selectors = [(_b = (_a2 = this._shift_expression()) === null || _a2 === void 0 ? void 0 : _a2.evaluate(this._context).toString()) !== null && _b !== void 0 ? _b : ""];
2864
+ const selectors = [
2865
+ (_b = (_a2 = this._shift_expression()) === null || _a2 === void 0 ? void 0 : _a2.evaluate(this._context).toString()) !== null && _b !== void 0 ? _b : ""
2866
+ ];
2807
2867
  while (this._match(TokenTypes.tokens.comma)) {
2808
2868
  selectors.push((_d = (_c = this._shift_expression()) === null || _c === void 0 ? void 0 : _c.evaluate(this._context).toString()) !== null && _d !== void 0 ? _d : "");
2809
2869
  }
@@ -2906,7 +2966,12 @@ void main() {
2906
2966
  }
2907
2967
  _relational_expression() {
2908
2968
  let expr = this._shift_expression();
2909
- while (this._match([TokenTypes.tokens.less_than, TokenTypes.tokens.greater_than, TokenTypes.tokens.less_than_equal, TokenTypes.tokens.greater_than_equal])) {
2969
+ while (this._match([
2970
+ TokenTypes.tokens.less_than,
2971
+ TokenTypes.tokens.greater_than,
2972
+ TokenTypes.tokens.less_than_equal,
2973
+ TokenTypes.tokens.greater_than_equal
2974
+ ])) {
2910
2975
  expr = new BinaryOperator(this._previous().toString(), expr, this._shift_expression());
2911
2976
  }
2912
2977
  return expr;
@@ -2927,13 +2992,23 @@ void main() {
2927
2992
  }
2928
2993
  _multiplicative_expression() {
2929
2994
  let expr = this._unary_expression();
2930
- while (this._match([TokenTypes.tokens.star, TokenTypes.tokens.forward_slash, TokenTypes.tokens.modulo])) {
2995
+ while (this._match([
2996
+ TokenTypes.tokens.star,
2997
+ TokenTypes.tokens.forward_slash,
2998
+ TokenTypes.tokens.modulo
2999
+ ])) {
2931
3000
  expr = new BinaryOperator(this._previous().toString(), expr, this._unary_expression());
2932
3001
  }
2933
3002
  return expr;
2934
3003
  }
2935
3004
  _unary_expression() {
2936
- if (this._match([TokenTypes.tokens.minus, TokenTypes.tokens.bang, TokenTypes.tokens.tilde, TokenTypes.tokens.star, TokenTypes.tokens.and])) {
3005
+ if (this._match([
3006
+ TokenTypes.tokens.minus,
3007
+ TokenTypes.tokens.bang,
3008
+ TokenTypes.tokens.tilde,
3009
+ TokenTypes.tokens.star,
3010
+ TokenTypes.tokens.and
3011
+ ])) {
2937
3012
  return new UnaryOperator(this._previous().toString(), this._unary_expression());
2938
3013
  }
2939
3014
  return this._singular_expression();
@@ -3187,7 +3262,14 @@ void main() {
3187
3262
  return aliasNode;
3188
3263
  }
3189
3264
  _type_decl() {
3190
- if (this._check([TokenTypes.tokens.ident, ...TokenTypes.texel_format, TokenTypes.keywords.bool, TokenTypes.keywords.f32, TokenTypes.keywords.i32, TokenTypes.keywords.u32])) {
3265
+ if (this._check([
3266
+ TokenTypes.tokens.ident,
3267
+ ...TokenTypes.texel_format,
3268
+ TokenTypes.keywords.bool,
3269
+ TokenTypes.keywords.f32,
3270
+ TokenTypes.keywords.i32,
3271
+ TokenTypes.keywords.u32
3272
+ ])) {
3191
3273
  const type2 = this._advance();
3192
3274
  const typeName = type2.toString();
3193
3275
  if (this._context.structs.has(typeName)) {
@@ -3298,7 +3380,9 @@ void main() {
3298
3380
  const name = this._consume(TokenTypes.attribute_name, "Expected attribute name");
3299
3381
  const attr = new Attribute(name.toString(), null);
3300
3382
  if (this._match(TokenTypes.tokens.paren_left)) {
3301
- attr.value = [this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString()];
3383
+ attr.value = [
3384
+ this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString()
3385
+ ];
3302
3386
  if (this._check(TokenTypes.tokens.comma)) {
3303
3387
  this._advance();
3304
3388
  do {
@@ -3921,74 +4005,23 @@ void main() {
3921
4005
  }
3922
4006
  };
3923
4007
  WgslReflect._typeInfo = {
3924
- f16: {
3925
- align: 2,
3926
- size: 2
3927
- },
3928
- i32: {
3929
- align: 4,
3930
- size: 4
3931
- },
3932
- u32: {
3933
- align: 4,
3934
- size: 4
3935
- },
3936
- f32: {
3937
- align: 4,
3938
- size: 4
3939
- },
3940
- atomic: {
3941
- align: 4,
3942
- size: 4
3943
- },
3944
- vec2: {
3945
- align: 8,
3946
- size: 8
3947
- },
3948
- vec3: {
3949
- align: 16,
3950
- size: 12
3951
- },
3952
- vec4: {
3953
- align: 16,
3954
- size: 16
3955
- },
3956
- mat2x2: {
3957
- align: 8,
3958
- size: 16
3959
- },
3960
- mat3x2: {
3961
- align: 8,
3962
- size: 24
3963
- },
3964
- mat4x2: {
3965
- align: 8,
3966
- size: 32
3967
- },
3968
- mat2x3: {
3969
- align: 16,
3970
- size: 32
3971
- },
3972
- mat3x3: {
3973
- align: 16,
3974
- size: 48
3975
- },
3976
- mat4x3: {
3977
- align: 16,
3978
- size: 64
3979
- },
3980
- mat2x4: {
3981
- align: 16,
3982
- size: 32
3983
- },
3984
- mat3x4: {
3985
- align: 16,
3986
- size: 48
3987
- },
3988
- mat4x4: {
3989
- align: 16,
3990
- size: 64
3991
- }
4008
+ f16: { align: 2, size: 2 },
4009
+ i32: { align: 4, size: 4 },
4010
+ u32: { align: 4, size: 4 },
4011
+ f32: { align: 4, size: 4 },
4012
+ atomic: { align: 4, size: 4 },
4013
+ vec2: { align: 8, size: 8 },
4014
+ vec3: { align: 16, size: 12 },
4015
+ vec4: { align: 16, size: 16 },
4016
+ mat2x2: { align: 8, size: 16 },
4017
+ mat3x2: { align: 8, size: 24 },
4018
+ mat4x2: { align: 8, size: 32 },
4019
+ mat2x3: { align: 16, size: 32 },
4020
+ mat3x3: { align: 16, size: 48 },
4021
+ mat4x3: { align: 16, size: 64 },
4022
+ mat2x4: { align: 16, size: 32 },
4023
+ mat3x4: { align: 16, size: 48 },
4024
+ mat4x4: { align: 16, size: 64 }
3992
4025
  };
3993
4026
  WgslReflect._textureTypes = TokenTypes.any_texture_type.map((t) => {
3994
4027
  return t.name;
@@ -3999,10 +4032,7 @@ void main() {
3999
4032
 
4000
4033
  // src/lib/wgsl/get-shader-layout-wgsl.ts
4001
4034
  function getShaderLayoutFromWGSL(source) {
4002
- const shaderLayout = {
4003
- attributes: [],
4004
- bindings: []
4005
- };
4035
+ const shaderLayout = { attributes: [], bindings: [] };
4006
4036
  const parsedWGSL = parseWGSL(source);
4007
4037
  for (const uniform of parsedWGSL.uniforms) {
4008
4038
  const members = [];
@@ -4016,6 +4046,7 @@ void main() {
4016
4046
  type: "uniform",
4017
4047
  name: uniform.name,
4018
4048
  location: uniform.binding,
4049
+ // @ts-expect-error
4019
4050
  group: uniform.group,
4020
4051
  members
4021
4052
  });
@@ -4052,9 +4083,7 @@ void main() {
4052
4083
  if (typeof error === "object" && error?.token) {
4053
4084
  message += error.token.line || "";
4054
4085
  }
4055
- throw new Error(message, {
4056
- cause: error
4057
- });
4086
+ throw new Error(message, { cause: error });
4058
4087
  }
4059
4088
  }
4060
4089
 
@@ -4410,7 +4439,7 @@ vec4 picking_filterColor(vec4 color) {
4410
4439
  return uniforms;
4411
4440
  }
4412
4441
 
4413
- // src/modules/lighting/lights/lighting-uniforms.glsl.ts
4442
+ // src/modules/lighting/lights/lighting-uniforms-glsl.ts
4414
4443
  var lightingUniforms = glsl`\
4415
4444
  precision highp int;
4416
4445
 
@@ -4468,11 +4497,6 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4468
4497
  // src/modules/lighting/lights/lighting-uniforms.ts
4469
4498
  var MAX_LIGHTS = 5;
4470
4499
  var COLOR_FACTOR = 255;
4471
- var LIGHT_TYPE = function(LIGHT_TYPE2) {
4472
- LIGHT_TYPE2[LIGHT_TYPE2["POINT"] = 0] = "POINT";
4473
- LIGHT_TYPE2[LIGHT_TYPE2["DIRECTIONAL"] = 1] = "DIRECTIONAL";
4474
- return LIGHT_TYPE2;
4475
- }(LIGHT_TYPE || {});
4476
4500
  var lighting = {
4477
4501
  name: "lighting",
4478
4502
  vs: lightingUniforms,
@@ -4487,59 +4511,48 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4487
4511
  enabled: "i32",
4488
4512
  ambientLightColor: "vec3<f32>",
4489
4513
  numberOfLights: "i32",
4514
+ // , array: MAX_LIGHTS,
4490
4515
  lightType: "i32",
4516
+ // , array: MAX_LIGHTS,
4491
4517
  lightColor: "vec3<f32>",
4518
+ // , array: MAX_LIGHTS,
4492
4519
  lightPosition: "vec3<f32>",
4520
+ // , array: MAX_LIGHTS,
4521
+ // TODO - could combine direction and attenuation
4493
4522
  lightDirection: "vec3<f32>",
4523
+ // , array: MAX_LIGHTS,
4494
4524
  lightAttenuation: "vec3<f32>"
4525
+ // , array: MAX_LIGHTS},
4495
4526
  },
4496
4527
  defaultUniforms: {
4497
4528
  enabled: 1,
4498
4529
  ambientLightColor: [0.1, 0.1, 0.1],
4499
4530
  numberOfLights: 0,
4500
- lightType: LIGHT_TYPE.POINT,
4531
+ lightType: 0 /* POINT */,
4501
4532
  lightColor: [1, 1, 1],
4502
4533
  lightPosition: [1, 1, 2],
4534
+ // TODO - could combine direction and attenuation
4503
4535
  lightDirection: [1, 1, 1],
4504
4536
  lightAttenuation: [1, 1, 1]
4505
4537
  }
4506
4538
  };
4507
4539
  function getUniforms2(props, prevUniforms = {}) {
4508
- props = props ? {
4509
- ...props
4510
- } : props;
4540
+ props = props ? { ...props } : props;
4511
4541
  if (!props) {
4512
- return {
4513
- ...lighting.defaultUniforms
4514
- };
4542
+ return { ...lighting.defaultUniforms };
4515
4543
  }
4516
4544
  if (props.lights) {
4517
- props = {
4518
- ...props,
4519
- ...extractLightTypes(props.lights),
4520
- lights: void 0
4521
- };
4545
+ props = { ...props, ...extractLightTypes(props.lights), lights: void 0 };
4522
4546
  }
4523
- const {
4524
- ambientLight,
4525
- pointLights,
4526
- directionalLights
4527
- } = props || {};
4547
+ const { ambientLight, pointLights, directionalLights } = props || {};
4528
4548
  const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
4529
4549
  if (!hasLights) {
4530
- return {
4531
- ...lighting.defaultUniforms,
4532
- enabled: 0
4533
- };
4550
+ return { ...lighting.defaultUniforms, enabled: 0 };
4534
4551
  }
4535
4552
  const uniforms = {
4536
4553
  ...lighting.defaultUniforms,
4537
4554
  ...prevUniforms,
4538
- ...getLightSourceUniforms({
4539
- ambientLight,
4540
- pointLights,
4541
- directionalLights
4542
- })
4555
+ ...getLightSourceUniforms({ ambientLight, pointLights, directionalLights })
4543
4556
  };
4544
4557
  if (props.enabled !== void 0) {
4545
4558
  uniforms.enabled = props.enabled ? 1 : 0;
@@ -4551,18 +4564,24 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4551
4564
  pointLights = [],
4552
4565
  directionalLights = []
4553
4566
  }) {
4554
- const lightSourceUniforms = {};
4567
+ const lightSourceUniforms = {
4568
+ // lightType: new Array(MAX_LIGHTS).fill(0),
4569
+ // lightColor: new Array(MAX_LIGHTS).fill([0, 0, 0]),
4570
+ // lightPosition: new Array(MAX_LIGHTS).fill([0, 0, 0]),
4571
+ // lightDirection: new Array(MAX_LIGHTS).fill([0, 0, 0]),
4572
+ // lightAttenuation: new Array(MAX_LIGHTS).fill([0, 0, 0])
4573
+ };
4555
4574
  lightSourceUniforms.ambientLightColor = convertColor(ambientLight);
4556
4575
  let currentLight = 0;
4557
4576
  for (const pointLight of pointLights) {
4558
- lightSourceUniforms.lightType = LIGHT_TYPE.POINT;
4577
+ lightSourceUniforms.lightType = 0 /* POINT */;
4559
4578
  lightSourceUniforms.lightColor = convertColor(pointLight);
4560
4579
  lightSourceUniforms.lightPosition = pointLight.position;
4561
4580
  lightSourceUniforms.lightAttenuation = [pointLight.attenuation || 1, 0, 0];
4562
4581
  currentLight++;
4563
4582
  }
4564
4583
  for (const directionalLight of directionalLights) {
4565
- lightSourceUniforms.lightType = LIGHT_TYPE.DIRECTIONAL;
4584
+ lightSourceUniforms.lightType = 1 /* DIRECTIONAL */;
4566
4585
  lightSourceUniforms.lightColor = convertColor(directionalLight);
4567
4586
  lightSourceUniforms.lightPosition = directionalLight.position;
4568
4587
  lightSourceUniforms.lightDirection = directionalLight.direction;
@@ -4572,10 +4591,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4572
4591
  return lightSourceUniforms;
4573
4592
  }
4574
4593
  function extractLightTypes(lights2) {
4575
- const lightSources = {
4576
- pointLights: [],
4577
- directionalLights: []
4578
- };
4594
+ const lightSources = { pointLights: [], directionalLights: [] };
4579
4595
  for (const light of lights2 || []) {
4580
4596
  switch (light.type) {
4581
4597
  case "ambient":
@@ -4593,10 +4609,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4593
4609
  return lightSources;
4594
4610
  }
4595
4611
  function convertColor(colorDef = {}) {
4596
- const {
4597
- color = [0, 0, 0],
4598
- intensity = 1
4599
- } = colorDef;
4612
+ const { color = [0, 0, 0], intensity = 1 } = colorDef;
4600
4613
  return color.map((component) => component * intensity / COLOR_FACTOR);
4601
4614
  }
4602
4615
 
@@ -4626,6 +4639,14 @@ vec4 dirlight_filterColor(vec4 color) {
4626
4639
  dependencies: [],
4627
4640
  vs: VS_GLSL,
4628
4641
  fs: FS_GLSL,
4642
+ // vs: {glsl: VS_GLSL, wgsl: VS_WGSL},
4643
+ // fs: {glsl: FS_GLSL, wgsl: FS_WGSL},
4644
+ // fragmentInputs: [
4645
+ // {
4646
+ // name: 'dirlight_vNormal',
4647
+ // type: 'vec3<f32>'
4648
+ // }
4649
+ // ],
4629
4650
  uniformTypes: {
4630
4651
  lightDirection: "vec3<f32>"
4631
4652
  },
@@ -4642,7 +4663,7 @@ vec4 dirlight_filterColor(vec4 color) {
4642
4663
  return uniforms;
4643
4664
  }
4644
4665
 
4645
- // src/modules/lighting/gouraud-material/gouraud-shaders.glsl.ts
4666
+ // src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
4646
4667
  var GOURAUD_VS = glsl`\
4647
4668
  uniform materialUniforms {
4648
4669
  uniform float ambient;
@@ -4738,6 +4759,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4738
4759
  // src/modules/lighting/gouraud-material/gouraud-material.ts
4739
4760
  var gouraudMaterial = {
4740
4761
  name: "gouraud-lighting",
4762
+ // Note these are switched between phong and gouraud
4741
4763
  vs: GOURAUD_VS,
4742
4764
  fs: GOURAUD_FS,
4743
4765
  defines: {
@@ -4757,14 +4779,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4757
4779
  specularColor: [0.15, 0.15, 0.15]
4758
4780
  },
4759
4781
  getUniforms(props) {
4760
- return {
4761
- ...gouraudMaterial.defaultUniforms,
4762
- ...props
4763
- };
4782
+ return { ...gouraudMaterial.defaultUniforms, ...props };
4764
4783
  }
4765
4784
  };
4766
4785
 
4767
- // src/modules/lighting/phong-material/phong-shaders.glsl.ts
4786
+ // src/modules/lighting/phong-material/phong-shaders-glsl.ts
4768
4787
  var PHONG_VS = glsl`\
4769
4788
  uniform phongMaterialUniforms {
4770
4789
  uniform float ambient;
@@ -4863,6 +4882,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4863
4882
  // src/modules/lighting/phong-material/phong-material.ts
4864
4883
  var phongMaterial = {
4865
4884
  name: "phong-lighting",
4885
+ // Note these are switched between phong and gouraud
4866
4886
  vs: PHONG_VS,
4867
4887
  fs: PHONG_FS,
4868
4888
  defines: {
@@ -4882,14 +4902,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4882
4902
  specularColor: [0.15, 0.15, 0.15]
4883
4903
  },
4884
4904
  getUniforms(props) {
4885
- return {
4886
- ...phongMaterial.defaultUniforms,
4887
- ...props
4888
- };
4905
+ return { ...phongMaterial.defaultUniforms, ...props };
4889
4906
  }
4890
4907
  };
4891
4908
 
4892
- // src/modules/lighting/pbr-material/pbr-vertex.glsl.ts
4909
+ // src/modules/lighting/pbr-material/pbr-vertex-glsl.ts
4893
4910
  var vs2 = glsl`\
4894
4911
  uniform projection {
4895
4912
  mat4 u_MVPMatrix;
@@ -4934,7 +4951,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
4934
4951
  }
4935
4952
  `;
4936
4953
 
4937
- // src/modules/lighting/pbr-material/pbr-fragment.glsl.ts
4954
+ // src/modules/lighting/pbr-material/pbr-fragment-glsl.ts
4938
4955
  var fs3 = glsl`\
4939
4956
  #if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
4940
4957
  # error PBR fragment shader: Texture LOD is not available
@@ -4944,14 +4961,8 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
4944
4961
  # error PBR fragment shader: Derivatives are not available
4945
4962
  #endif
4946
4963
 
4947
- // WebGL 1.0 does not support non-constant in for loops
4948
- // This provides an easy way to handle these cases
4949
- // and still take advantage of WebGL 2.0
4950
- #if (__VERSION__ < 300)
4951
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)
4952
- #else
4953
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
4954
- #endif
4964
+ // TODO - remove we only support WebGL2
4965
+ #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
4955
4966
 
4956
4967
  precision highp float;
4957
4968
 
@@ -5377,57 +5388,52 @@ vec4 pbr_filterColor(vec4 colorUnused)
5377
5388
  PBR_DEBUG: 0
5378
5389
  },
5379
5390
  uniformTypes: {
5391
+ // Material is unlit
5380
5392
  unlit: "i32",
5393
+ // Base color map
5381
5394
  baseColorMapEnabled: "i32",
5382
5395
  baseColorFactor: "vec4<f32>",
5383
5396
  normalMapEnabled: "i32",
5384
5397
  normalScale: "f32",
5398
+ // #ifdef HAS_NORMALMAP
5385
5399
  emissiveMapEnabled: "i32",
5386
5400
  emissiveFactor: "vec3<f32>",
5401
+ // #ifdef HAS_EMISSIVEMAP
5387
5402
  metallicRoughnessValues: "vec2<f32>",
5388
5403
  metallicRoughnessMapEnabled: "i32",
5389
5404
  occlusionMapEnabled: "i32",
5390
5405
  occlusionStrength: "f32",
5406
+ // #ifdef HAS_OCCLUSIONMAP
5391
5407
  alphaCutoffEnabled: "i32",
5392
5408
  alphaCutoff: "f32",
5409
+ // #ifdef ALPHA_CUTOFF
5410
+ // IBL
5393
5411
  IBLenabled: "i32",
5394
5412
  scaleIBLAmbient: "vec2<f32>",
5413
+ // #ifdef USE_IBL
5414
+ // debugging flags used for shader output of intermediate PBR variables
5415
+ // #ifdef PBR_DEBUG
5395
5416
  scaleDiffBaseMR: "vec4<f32>",
5396
5417
  scaleFGDSpec: "vec4<f32>"
5397
5418
  },
5398
5419
  bindings: {
5399
- baseColorSampler: {
5400
- type: "texture",
5401
- location: 8
5402
- },
5403
- normalSampler: {
5404
- type: "texture",
5405
- location: 9
5406
- },
5407
- emissiveSampler: {
5408
- type: "texture",
5409
- location: 10
5410
- },
5411
- metallicRoughnessSampler: {
5412
- type: "texture",
5413
- location: 11
5414
- },
5415
- occlusionSampler: {
5416
- type: "texture",
5417
- location: 12
5418
- },
5419
- diffuseEnvSampler: {
5420
- type: "texture",
5421
- location: 13
5422
- },
5423
- specularEnvSampler: {
5424
- type: "texture",
5425
- location: 14
5426
- },
5427
- brdfLUT: {
5428
- type: "texture",
5429
- location: 15
5430
- }
5420
+ baseColorSampler: { type: "texture", location: 8 },
5421
+ // #ifdef HAS_BASECOLORMAP
5422
+ normalSampler: { type: "texture", location: 9 },
5423
+ // #ifdef HAS_NORMALMAP
5424
+ emissiveSampler: { type: "texture", location: 10 },
5425
+ // #ifdef HAS_EMISSIVEMAP
5426
+ metallicRoughnessSampler: { type: "texture", location: 11 },
5427
+ // #ifdef HAS_METALROUGHNESSMAP
5428
+ occlusionSampler: { type: "texture", location: 12 },
5429
+ // #ifdef HAS_OCCLUSIONMAP
5430
+ // IBL Samplers
5431
+ diffuseEnvSampler: { type: "texture", location: 13 },
5432
+ // #ifdef USE_IBL (samplerCube)
5433
+ specularEnvSampler: { type: "texture", location: 14 },
5434
+ // #ifdef USE_IBL (samplerCube)
5435
+ brdfLUT: { type: "texture", location: 15 }
5436
+ // #ifdef USE_IBL
5431
5437
  },
5432
5438
  dependencies: [lighting]
5433
5439
  };
@@ -5435,14 +5441,14 @@ vec4 pbr_filterColor(vec4 colorUnused)
5435
5441
  // src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts
5436
5442
  var fs4 = glsl`\
5437
5443
 
5438
- uniform BrightnessContrast{
5444
+ uniform brightnessContrastUniforms {
5439
5445
  float brightness;
5440
5446
  float contrast;
5441
5447
  } brightnessContrast;
5442
5448
 
5443
5449
  vec4 brightnessContrast_filterColor(vec4 color) {
5444
5450
  color.rgb += brightnessContrast.brightness;
5445
- if (contrast > 0.0) {
5451
+ if (brightnessContrast.contrast > 0.0) {
5446
5452
  color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
5447
5453
  } else {
5448
5454
  color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;
@@ -5461,43 +5467,31 @@ vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
5461
5467
  contrast: "f32"
5462
5468
  },
5463
5469
  uniformPropTypes: {
5464
- brightness: {
5465
- format: "f32",
5466
- value: 0,
5467
- min: -1,
5468
- max: 1
5469
- },
5470
- contrast: {
5471
- format: "f32",
5472
- value: 0,
5473
- min: -1,
5474
- max: 1
5475
- }
5470
+ brightness: { format: "f32", value: 0, min: -1, max: 1 },
5471
+ contrast: { format: "f32", value: 0, min: -1, max: 1 }
5476
5472
  },
5477
5473
  fs: fs4,
5478
- passes: [{
5479
- filter: true
5480
- }]
5474
+ passes: [{ filter: true }]
5481
5475
  };
5482
5476
 
5483
5477
  // src/modules/postprocessing/image-adjust-filters/denoise.ts
5484
5478
  var fs5 = glsl`\
5485
- uniform Noise {
5479
+ uniform denoiseUniforms {
5486
5480
  float strength;
5487
5481
  } noise;
5488
5482
 
5489
- vec4 denoise_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5483
+ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5490
5484
  float adjustedExponent = 3. + 200. * pow(1. - noise.strength, 4.);
5491
5485
 
5492
- vec4 center = texture2D(texture, texCoord);
5486
+ vec4 center = texture(source, texCoord);
5493
5487
  vec4 color = vec4(0.0);
5494
5488
  float total = 0.0;
5495
5489
  for (float x = -4.0; x <= 4.0; x += 1.0) {
5496
5490
  for (float y = -4.0; y <= 4.0; y += 1.0) {
5497
- vec4 sample = texture2D(texture, texCoord + vec2(x, y) / texSize);
5498
- float weight = 1.0 - abs(dot(sample.rgb - center.rgb, vec3(0.25)));
5491
+ vec4 offsetColor = texture(source, texCoord + vec2(x, y) / texSize);
5492
+ float weight = 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3(0.25)));
5499
5493
  weight = pow(weight, adjustedExponent);
5500
- color += sample * weight;
5494
+ color += offsetColor * weight;
5501
5495
  total += weight;
5502
5496
  }
5503
5497
  }
@@ -5511,31 +5505,23 @@ vec4 denoise_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5511
5505
  strength: "f32"
5512
5506
  },
5513
5507
  uniformPropTypes: {
5514
- strength: {
5515
- format: "f32",
5516
- value: 0.5,
5517
- min: 0,
5518
- max: 0.1
5519
- }
5508
+ strength: { format: "f32", value: 0.5, min: 0, max: 1 }
5509
+ // strength: {..., adjust: (strength: number): number => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing
5520
5510
  },
5521
5511
  fs: fs5,
5522
- passes: [{
5523
- sampler: true
5524
- }, {
5525
- sampler: true
5526
- }]
5512
+ passes: [{ sampler: true }, { sampler: true }]
5527
5513
  };
5528
5514
 
5529
5515
  // src/modules/postprocessing/image-adjust-filters/huesaturation.ts
5530
5516
  var fs6 = glsl`\
5531
- uniform HueSaturation {
5517
+ uniform hueSaturationUniforms {
5532
5518
  float hue;
5533
5519
  float saturation;
5534
5520
  } hueSaturation;
5535
5521
 
5536
5522
  vec4 hueSaturation_filterColor(vec4 color) {
5537
5523
  // hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]
5538
- float angle = hue * 3.14159265;
5524
+ float angle = hueSaturation.hue * 3.14159265;
5539
5525
  float s = sin(angle), c = cos(angle);
5540
5526
  vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;
5541
5527
  float len = length(color.rgb);
@@ -5547,10 +5533,10 @@ vec4 hueSaturation_filterColor(vec4 color) {
5547
5533
 
5548
5534
  // saturation adjustment
5549
5535
  float average = (color.r + color.g + color.b) / 3.0;
5550
- if (saturation > 0.0) {
5551
- color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - saturation));
5536
+ if (hueSaturation.saturation > 0.0) {
5537
+ color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
5552
5538
  } else {
5553
- color.rgb += (average - color.rgb) * (-saturation);
5539
+ color.rgb += (average - color.rgb) * (-hueSaturation.saturation);
5554
5540
  }
5555
5541
 
5556
5542
  return color;
@@ -5567,26 +5553,16 @@ vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5567
5553
  saturation: "f32"
5568
5554
  },
5569
5555
  uniformPropTypes: {
5570
- hue: {
5571
- value: 0,
5572
- min: -1,
5573
- max: 1
5574
- },
5575
- saturation: {
5576
- value: 0,
5577
- min: -1,
5578
- max: 1
5579
- }
5556
+ hue: { value: 0, min: -1, max: 1 },
5557
+ saturation: { value: 0, min: -1, max: 1 }
5580
5558
  },
5581
5559
  fs: fs6,
5582
- passes: [{
5583
- filter: true
5584
- }]
5560
+ passes: [{ filter: true }]
5585
5561
  };
5586
5562
 
5587
5563
  // src/modules/postprocessing/image-adjust-filters/noise.ts
5588
5564
  var fs7 = glsl`\
5589
- uniform Noise {
5565
+ uniform noiseUniforms {
5590
5566
  float amount;
5591
5567
  } noise;
5592
5568
 
@@ -5612,21 +5588,15 @@ vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5612
5588
  amount: "f32"
5613
5589
  },
5614
5590
  uniformPropTypes: {
5615
- amount: {
5616
- value: 0.5,
5617
- min: 0,
5618
- max: 1
5619
- }
5591
+ amount: { value: 0.5, min: 0, max: 1 }
5620
5592
  },
5621
5593
  fs: fs7,
5622
- passes: [{
5623
- filter: true
5624
- }]
5594
+ passes: [{ filter: true }]
5625
5595
  };
5626
5596
 
5627
5597
  // src/modules/postprocessing/image-adjust-filters/sepia.ts
5628
5598
  var fs8 = glsl`\
5629
- uniform Sepia {
5599
+ uniform sepiaUniforms {
5630
5600
  float amount;
5631
5601
  } sepia;
5632
5602
 
@@ -5653,21 +5623,15 @@ vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5653
5623
  amount: "f32"
5654
5624
  },
5655
5625
  uniformPropTypes: {
5656
- amount: {
5657
- value: 0.5,
5658
- min: 0,
5659
- max: 1
5660
- }
5626
+ amount: { value: 0.5, min: 0, max: 1 }
5661
5627
  },
5662
5628
  fs: fs8,
5663
- passes: [{
5664
- filter: true
5665
- }]
5629
+ passes: [{ filter: true }]
5666
5630
  };
5667
5631
 
5668
5632
  // src/modules/postprocessing/image-adjust-filters/vibrance.ts
5669
5633
  var fs9 = glsl`\
5670
- uniform Vibrance {
5634
+ uniform vibranceUniforms {
5671
5635
  float amount;
5672
5636
  } vibrance;
5673
5637
 
@@ -5686,21 +5650,15 @@ vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5686
5650
  var vibrance = {
5687
5651
  name: "vibrance",
5688
5652
  uniformPropTypes: {
5689
- amount: {
5690
- value: 0,
5691
- min: -1,
5692
- max: 1
5693
- }
5653
+ amount: { value: 0, min: -1, max: 1 }
5694
5654
  },
5695
5655
  fs: fs9,
5696
- passes: [{
5697
- filter: true
5698
- }]
5656
+ passes: [{ filter: true }]
5699
5657
  };
5700
5658
 
5701
5659
  // src/modules/postprocessing/image-adjust-filters/vignette.ts
5702
5660
  var fs10 = glsl`\
5703
- uniform Vignette {
5661
+ uniform vignetteUniforms {
5704
5662
  float radius;
5705
5663
  float amount;
5706
5664
  } vignette;
@@ -5723,25 +5681,15 @@ vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5723
5681
  amount: "f32"
5724
5682
  },
5725
5683
  uniformPropTypes: {
5726
- radius: {
5727
- value: 0.5,
5728
- min: 0,
5729
- max: 1
5730
- },
5731
- amount: {
5732
- value: 0.5,
5733
- min: 0,
5734
- max: 1
5735
- }
5684
+ radius: { value: 0.5, min: 0, max: 1 },
5685
+ amount: { value: 0.5, min: 0, max: 1 }
5736
5686
  },
5737
- passes: [{
5738
- filter: true
5739
- }]
5687
+ passes: [{ filter: true }]
5740
5688
  };
5741
5689
 
5742
5690
  // src/modules/postprocessing/image-blur-filters/tiltshift.ts
5743
5691
  var fs11 = glsl`\
5744
- uniform TiltShift {
5692
+ uniform tiltShiftUniforms {
5745
5693
  float blurRadius;
5746
5694
  float gradientRadius;
5747
5695
  vec2 start;
@@ -5754,26 +5702,26 @@ vec2 tiltShift_getDelta(vec2 texSize) {
5754
5702
  return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;
5755
5703
  }
5756
5704
 
5757
- vec4 tiltShift_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5705
+ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5758
5706
  vec4 color = vec4(0.0);
5759
5707
  float total = 0.0;
5760
5708
 
5761
5709
  /* randomize the lookup values to hide the fixed number of samples */
5762
5710
  float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
5763
5711
 
5764
- vec2 normal = normalize(vec2((start.y - end.y) * texSize.y, (end.x - start.x) * texSize.x));
5712
+ vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));
5765
5713
  float radius = smoothstep(0.0, 1.0,
5766
- abs(dot(texCoord * texSize - start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
5714
+ abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
5767
5715
 
5768
5716
  for (float t = -30.0; t <= 30.0; t++) {
5769
5717
  float percent = (t + offset - 0.5) / 30.0;
5770
5718
  float weight = 1.0 - abs(percent);
5771
- vec4 sample = texture2D(texture, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
5719
+ vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
5772
5720
 
5773
5721
  /* switch to pre-multiplied alpha to correctly blur transparent images */
5774
- sample.rgb *= sample.a;
5722
+ offsetColor.rgb *= offsetColor.a;
5775
5723
 
5776
- color += sample * weight;
5724
+ color += offsetColor * weight;
5777
5725
  total += weight;
5778
5726
  }
5779
5727
 
@@ -5795,49 +5743,29 @@ vec4 tiltShift_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5795
5743
  invert: "i32"
5796
5744
  },
5797
5745
  uniformPropTypes: {
5798
- blurRadius: {
5799
- value: 15,
5800
- min: 0,
5801
- max: 50
5802
- },
5803
- gradientRadius: {
5804
- value: 200,
5805
- min: 0,
5806
- max: 400
5807
- },
5808
- start: {
5809
- value: [0, 0]
5810
- },
5811
- end: {
5812
- value: [1, 1]
5813
- },
5814
- invert: {
5815
- value: false,
5816
- private: true
5817
- }
5746
+ blurRadius: { value: 15, min: 0, max: 50 },
5747
+ gradientRadius: { value: 200, min: 0, max: 400 },
5748
+ start: { value: [0, 0] },
5749
+ end: { value: [1, 1] },
5750
+ invert: { value: false, private: true }
5818
5751
  },
5819
- passes: [{
5820
- sampler: true,
5821
- uniforms: {
5822
- invert: false
5823
- }
5824
- }, {
5825
- sampler: true,
5826
- uniforms: {
5827
- invert: true
5828
- }
5829
- }],
5752
+ passes: [
5753
+ { sampler: true, uniforms: { invert: false } },
5754
+ { sampler: true, uniforms: { invert: true } }
5755
+ ],
5830
5756
  dependencies: [random],
5831
5757
  fs: fs11
5832
5758
  };
5833
5759
 
5834
5760
  // src/modules/postprocessing/image-blur-filters/triangleblur.ts
5835
5761
  var fs12 = glsl`\
5836
- uniform float radius;
5837
- uniform vec2 delta;
5762
+ uniform triangleBlurUniforms {
5763
+ float radius;
5764
+ vec2 delta;
5765
+ } triangleBlur;
5838
5766
 
5839
- vec4 triangleBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5840
- vec2 adjustedDelta = delta * radius / texSize;
5767
+ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5768
+ vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
5841
5769
 
5842
5770
  vec4 color = vec4(0.0);
5843
5771
  float total = 0.0;
@@ -5848,12 +5776,12 @@ vec4 triangleBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5848
5776
  for (float t = -30.0; t <= 30.0; t++) {
5849
5777
  float percent = (t + offset - 0.5) / 30.0;
5850
5778
  float weight = 1.0 - abs(percent);
5851
- vec4 sample = texture2D(texture, texCoord + adjustedDelta * percent);
5779
+ vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
5852
5780
 
5853
5781
  /* switch to pre-multiplied alpha to correctly blur transparent images */
5854
- sample.rgb *= sample.a;
5782
+ offsetColor.rgb *= offsetColor.a;
5855
5783
 
5856
- color += sample * weight;
5784
+ color += offsetColor * weight;
5857
5785
  total += weight;
5858
5786
  }
5859
5787
 
@@ -5872,40 +5800,28 @@ vec4 triangleBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5872
5800
  delta: "vec2<f32>"
5873
5801
  },
5874
5802
  uniformPropTypes: {
5875
- radius: {
5876
- value: 20,
5877
- min: 0,
5878
- softMax: 100
5879
- },
5880
- delta: {
5881
- value: [1, 0],
5882
- private: true
5883
- }
5803
+ radius: { value: 20, min: 0, softMax: 100 },
5804
+ delta: { value: [1, 0], private: true }
5884
5805
  },
5885
5806
  fs: fs12,
5886
5807
  dependencies: [random],
5887
- passes: [{
5888
- sampler: true,
5889
- uniforms: {
5890
- delta: [1, 0]
5891
- }
5892
- }, {
5893
- sampler: true,
5894
- uniforms: {
5895
- delta: [0, 1]
5896
- }
5897
- }]
5808
+ passes: [
5809
+ { sampler: true, uniforms: { delta: [1, 0] } },
5810
+ { sampler: true, uniforms: { delta: [0, 1] } }
5811
+ ]
5898
5812
  };
5899
5813
 
5900
5814
  // src/modules/postprocessing/image-blur-filters/zoomblur.ts
5901
5815
  var fs13 = `
5902
- uniform vec2 center;
5903
- uniform float strength;
5816
+ uniform zoomBlurUniforms {
5817
+ vec2 center;
5818
+ float strength;
5819
+ } zoomBlur;
5904
5820
 
5905
- vec4 zoomBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5821
+ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5906
5822
  vec4 color = vec4(0.0);
5907
5823
  float total = 0.0;
5908
- vec2 toCenter = center * texSize - texCoord * texSize;
5824
+ vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;
5909
5825
 
5910
5826
  /* randomize the lookup values to hide the fixed number of samples */
5911
5827
  float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
@@ -5913,12 +5829,12 @@ vec4 zoomBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5913
5829
  for (float t = 0.0; t <= 40.0; t++) {
5914
5830
  float percent = (t + offset) / 40.0;
5915
5831
  float weight = 4.0 * (percent - percent * percent);
5916
- vec4 sample = texture2D(texture, texCoord + toCenter * percent * strength / texSize);
5832
+ vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
5917
5833
 
5918
5834
  /* switch to pre-multiplied alpha to correctly blur transparent images */
5919
- sample.rgb *= sample.a;
5835
+ offsetColor.rgb *= offsetColor.a;
5920
5836
 
5921
- color += sample * weight;
5837
+ color += offsetColor * weight;
5922
5838
  total += weight;
5923
5839
  }
5924
5840
 
@@ -5937,34 +5853,24 @@ vec4 zoomBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
5937
5853
  strength: "f32"
5938
5854
  },
5939
5855
  uniformPropTypes: {
5940
- center: {
5941
- value: [0.5, 0.5]
5942
- },
5943
- strength: {
5944
- value: 0.3,
5945
- min: 0,
5946
- softMax: 1
5947
- }
5856
+ center: { value: [0.5, 0.5] },
5857
+ strength: { value: 0.3, min: 0, softMax: 1 }
5948
5858
  },
5949
5859
  fs: fs13,
5950
5860
  dependencies: [random],
5951
- passes: [{
5952
- sampler: true
5953
- }]
5861
+ passes: [{ sampler: true }]
5954
5862
  };
5955
5863
 
5956
5864
  // src/modules/postprocessing/image-fun-filters/colorhalftone.ts
5957
5865
  var fs14 = glsl`\
5958
- uniform ColorHalftone {
5866
+ uniform colorHalftoneUniforms {
5959
5867
  vec2 center;
5960
5868
  float angle;
5961
5869
  float size;
5962
5870
  } colorHalftone;
5963
5871
 
5964
- float scale = 3.1514 / colorHalftone.size;
5965
-
5966
- float pattern(float angle, vec2 texSize, vec2 texCoord) {
5967
- float s = sin(colorHalftone.angle), c = cos(colorHalftone.angle);
5872
+ float pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {
5873
+ float s = sin(angle), c = cos(angle);
5968
5874
  vec2 tex = texCoord * texSize - colorHalftone.center * texSize;
5969
5875
  vec2 point = vec2(
5970
5876
  c * tex.x - s * tex.y,
@@ -5974,19 +5880,21 @@ float pattern(float angle, vec2 texSize, vec2 texCoord) {
5974
5880
  }
5975
5881
 
5976
5882
  vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5883
+ float scale = 3.1514 / colorHalftone.size;
5977
5884
  vec3 cmy = 1.0 - color.rgb;
5978
5885
  float k = min(cmy.x, min(cmy.y, cmy.z));
5886
+
5979
5887
  cmy = (cmy - k) / (1.0 - k);
5980
5888
  cmy = clamp(
5981
- cmy * 10.0 - 3.0 + vec3(
5982
- pattern(angle + 0.26179, texSize, texCoord),
5983
- pattern(angle + 1.30899, texSize, texCoord),
5984
- pattern(angle, texSize, texCoord)
5985
- ),
5986
- 0.0,
5987
- 1.0
5889
+ cmy * 10.0 - 3.0 + vec3(
5890
+ pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
5891
+ pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
5892
+ pattern(colorHalftone.angle, scale, texSize, texCoord)
5893
+ ),
5894
+ 0.0,
5895
+ 1.0
5988
5896
  );
5989
- k = clamp(k * 10.0 - 5.0 + pattern(angle + 0.78539, texSize, texCoord), 0.0, 1.0);
5897
+ k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
5990
5898
  return vec4(1.0 - cmy - k, color.a);
5991
5899
  }
5992
5900
  `;
@@ -5998,30 +5906,17 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5998
5906
  size: "f32"
5999
5907
  },
6000
5908
  uniformPropTypes: {
6001
- center: {
6002
- value: [0.5, 0.5]
6003
- },
6004
- angle: {
6005
- value: 1.1,
6006
- softMin: 0,
6007
- softMax: Math.PI / 2
6008
- },
6009
- size: {
6010
- value: 4,
6011
- min: 1,
6012
- softMin: 3,
6013
- softMax: 20
6014
- }
5909
+ center: { value: [0.5, 0.5] },
5910
+ angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
5911
+ size: { value: 4, min: 1, softMin: 3, softMax: 20 }
6015
5912
  },
6016
5913
  fs: fs14,
6017
- passes: [{
6018
- filter: true
6019
- }]
5914
+ passes: [{ filter: true }]
6020
5915
  };
6021
5916
 
6022
5917
  // src/modules/postprocessing/image-fun-filters/dotscreen.ts
6023
5918
  var fs15 = glsl`\
6024
- uniform DotScreen {
5919
+ uniform dotScreenUniforms {
6025
5920
  vec2 center;
6026
5921
  float angle;
6027
5922
  float size;
@@ -6052,30 +5947,17 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
6052
5947
  size: "f32"
6053
5948
  },
6054
5949
  uniformPropTypes: {
6055
- center: {
6056
- value: [0.5, 0.5]
6057
- },
6058
- angle: {
6059
- value: 1.1,
6060
- softMin: 0,
6061
- softMax: Math.PI / 2
6062
- },
6063
- size: {
6064
- value: 3,
6065
- min: 1,
6066
- softMin: 3,
6067
- softMax: 20
6068
- }
5950
+ center: { value: [0.5, 0.5] },
5951
+ angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
5952
+ size: { value: 3, min: 1, softMin: 3, softMax: 20 }
6069
5953
  },
6070
5954
  fs: fs15,
6071
- passes: [{
6072
- filter: true
6073
- }]
5955
+ passes: [{ filter: true }]
6074
5956
  };
6075
5957
 
6076
5958
  // src/modules/postprocessing/image-fun-filters/edgework.ts
6077
5959
  var fs16 = glsl`\
6078
- uniform EdgeWork {
5960
+ uniform edgeWorkUniforms {
6079
5961
  float radius;
6080
5962
  vec2 delta;
6081
5963
  } edgeWork;
@@ -6092,7 +5974,7 @@ vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
6092
5974
  for (float t = -30.0; t <= 30.0; t++) {
6093
5975
  float percent = (t + offset - 0.5) / 30.0;
6094
5976
  float weight = 1.0 - abs(percent);
6095
- vec3 sampleColor = texture2D(source, texCoord + relativeDelta * percent).rgb;
5977
+ vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;
6096
5978
  float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
6097
5979
  color.x += average * weight;
6098
5980
  total.x += weight;
@@ -6117,7 +5999,7 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
6117
5999
  for (float t = -30.0; t <= 30.0; t++) {
6118
6000
  float percent = (t + offset - 0.5) / 30.0;
6119
6001
  float weight = 1.0 - abs(percent);
6120
- vec2 sampleColor = texture2D(source, texCoord + relativeDelta * percent).xy;
6002
+ vec2 sampleColor = texture(source, texCoord + relativeDelta * percent).xy;
6121
6003
  color.x += sampleColor.x * weight;
6122
6004
  total.x += weight;
6123
6005
  if (abs(t) < 15.0) {
@@ -6133,39 +6015,33 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
6133
6015
  var edgeWork = {
6134
6016
  name: "edgeWork",
6135
6017
  uniformPropTypes: {
6136
- radius: {
6137
- value: 2,
6138
- min: 1,
6139
- softMax: 50
6140
- },
6141
- delta: {
6142
- value: [1, 0],
6143
- private: true
6144
- }
6018
+ radius: { value: 2, min: 1, softMax: 50 },
6019
+ delta: { value: [1, 0], private: true }
6145
6020
  },
6146
6021
  fs: fs16,
6147
6022
  dependencies: [random],
6148
- passes: [{
6149
- sampler: "edgeWork_sampleColor1",
6150
- uniformPropTypes: {
6151
- delta: [1, 0]
6152
- }
6153
- }, {
6154
- sampler: "edgeWork_sampleColor2",
6155
- uniformPropTypes: {
6156
- delta: [0, 1]
6023
+ passes: [
6024
+ {
6025
+ // @ts-expect-error
6026
+ sampler: "edgeWork_sampleColor1",
6027
+ uniformPropTypes: { delta: [1, 0] }
6028
+ },
6029
+ {
6030
+ // @ts-expect-error
6031
+ sampler: "edgeWork_sampleColor2",
6032
+ uniformPropTypes: { delta: [0, 1] }
6157
6033
  }
6158
- }]
6034
+ ]
6159
6035
  };
6160
6036
 
6161
6037
  // src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts
6162
6038
  var fs17 = glsl`\
6163
- uniform HexagonalPixelate {
6039
+ uniform hexagonalPixelateUniforms {
6164
6040
  vec2 center;
6165
6041
  float scale;
6166
6042
  } hexagonalPixelate;
6167
6043
 
6168
- vec4 hexagonalPixelate_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6044
+ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6169
6045
  vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
6170
6046
  tex.y /= 0.866025404;
6171
6047
  tex.x -= tex.y * 0.5;
@@ -6200,7 +6076,7 @@ vec4 hexagonalPixelate_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoor
6200
6076
  choice.y *= 0.866025404;
6201
6077
  choice *= hexagonalPixelate.scale / texSize;
6202
6078
 
6203
- return texture2D(texture, choice + hexagonalPixelate.center);
6079
+ return texture(source, choice + hexagonalPixelate.center);
6204
6080
  }
6205
6081
  `;
6206
6082
  var hexagonalPixelate = {
@@ -6210,44 +6086,34 @@ vec4 hexagonalPixelate_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoor
6210
6086
  scale: "f32"
6211
6087
  },
6212
6088
  uniformPropTypes: {
6213
- center: {
6214
- value: [0.5, 0.5],
6215
- hint: "screenspace"
6216
- },
6217
- scale: {
6218
- value: 10,
6219
- min: 1,
6220
- softMin: 5,
6221
- softMax: 50
6222
- }
6089
+ center: { value: [0.5, 0.5], hint: "screenspace" },
6090
+ scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
6223
6091
  },
6224
6092
  fs: fs17,
6225
- passes: [{
6226
- sampler: true
6227
- }]
6093
+ passes: [{ sampler: true }]
6228
6094
  };
6229
6095
 
6230
6096
  // src/modules/postprocessing/image-fun-filters/ink.ts
6231
6097
  var fs18 = glsl`\
6232
- uniform Ink {
6098
+ uniform inkUniforms {
6233
6099
  float strength;
6234
6100
  } ink;
6235
6101
 
6236
- vec4 ink_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6102
+ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6237
6103
  vec2 dx = vec2(1.0 / texSize.x, 0.0);
6238
6104
  vec2 dy = vec2(0.0, 1.0 / texSize.y);
6239
- vec4 color = texture2D(texture, texCoord);
6105
+ vec4 color = texture(source, texCoord);
6240
6106
  float bigTotal = 0.0;
6241
6107
  float smallTotal = 0.0;
6242
6108
  vec3 bigAverage = vec3(0.0);
6243
6109
  vec3 smallAverage = vec3(0.0);
6244
6110
  for (float x = -2.0; x <= 2.0; x += 1.0) {
6245
6111
  for (float y = -2.0; y <= 2.0; y += 1.0) {
6246
- vec3 sample = texture2D(texture, texCoord + dx * x + dy * y).rgb;
6247
- bigAverage += sample;
6112
+ vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
6113
+ bigAverage += offsetColor;
6248
6114
  bigTotal += 1.0;
6249
6115
  if (abs(x) + abs(y) < 2.0) {
6250
- smallAverage += sample;
6116
+ smallAverage += offsetColor;
6251
6117
  smallTotal += 1.0;
6252
6118
  }
6253
6119
  }
@@ -6263,21 +6129,15 @@ vec4 ink_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6263
6129
  strength: "f32"
6264
6130
  },
6265
6131
  uniformPropTypes: {
6266
- strength: {
6267
- value: 0.25,
6268
- min: 0,
6269
- softMax: 1
6270
- }
6132
+ strength: { value: 0.25, min: 0, softMax: 1 }
6271
6133
  },
6272
6134
  fs: fs18,
6273
- passes: [{
6274
- sampler: true
6275
- }]
6135
+ passes: [{ sampler: true }]
6276
6136
  };
6277
6137
 
6278
6138
  // src/modules/postprocessing/image-fun-filters/magnify.ts
6279
6139
  var fs19 = glsl`\
6280
- uniform Magnify {
6140
+ uniform magnifyUniforms {
6281
6141
  vec2 screenXY;
6282
6142
  float radiusPixels;
6283
6143
  float zoom;
@@ -6285,17 +6145,17 @@ uniform Magnify {
6285
6145
  vec4 borderColor;
6286
6146
  } magnify;
6287
6147
 
6288
- vec4 magnify_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6148
+ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6289
6149
  vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
6290
6150
  float dist = distance(texCoord * texSize, pos * texSize);
6291
6151
  if (dist < magnify.radiusPixels) {
6292
- return texture2D(texture, (texCoord - pos) / magnify.zoom + pos);
6152
+ return texture(source, (texCoord - pos) / magnify.zoom + pos);
6293
6153
  }
6294
6154
 
6295
6155
  if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
6296
6156
  return magnify.borderColor;
6297
6157
  }
6298
- return texture2D(texture, texCoord);
6158
+ return texture(source, texCoord);
6299
6159
  }
6300
6160
  `;
6301
6161
  var magnify = {
@@ -6308,26 +6168,21 @@ vec4 magnify_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6308
6168
  borderColor: "vec4<f32>"
6309
6169
  },
6310
6170
  uniformPropTypes: {
6311
- screenXY: {
6312
- value: [0, 0]
6313
- },
6171
+ // range 0 to 1
6172
+ screenXY: { value: [0, 0] },
6314
6173
  radiusPixels: 200,
6315
6174
  zoom: 2,
6316
6175
  borderWidthPixels: 0,
6317
- borderColor: {
6318
- value: [255, 255, 255, 255]
6319
- }
6176
+ borderColor: { value: [255, 255, 255, 255] }
6320
6177
  },
6321
6178
  fs: fs19,
6322
- passes: [{
6323
- sampler: true
6324
- }]
6179
+ passes: [{ sampler: true }]
6325
6180
  };
6326
6181
 
6327
6182
  // src/modules/postprocessing/image-warp-filters/warp.ts
6328
6183
  var fs20 = glsl`\
6329
- vec4 warp_sampleColor(sampler2D texture, vec2 texSize, vec2 coord) {
6330
- vec4 color = texture2D(texture, coord / texSize);
6184
+ vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
6185
+ vec4 color = texture(source, coord / texSize);
6331
6186
  vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
6332
6187
  if (coord != clampedCoord) {
6333
6188
  /* fade to transparent if we are outside the image */
@@ -6339,12 +6194,13 @@ vec4 warp_sampleColor(sampler2D texture, vec2 texSize, vec2 coord) {
6339
6194
  `;
6340
6195
  var warp = {
6341
6196
  name: "warp",
6197
+ passes: [],
6342
6198
  fs: fs20
6343
6199
  };
6344
6200
 
6345
6201
  // src/modules/postprocessing/image-warp-filters/bulgepinch.ts
6346
6202
  var fs21 = glsl`\
6347
- uniform BulgePinch {
6203
+ uniform bulgePinchUniforms {
6348
6204
  float radius;
6349
6205
  float strength;
6350
6206
  vec2 center;
@@ -6355,7 +6211,7 @@ vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
6355
6211
  float distance = length(coord);
6356
6212
  if (distance < bulgePinch.radius) {
6357
6213
  float percent = distance / bulgePinch.radius;
6358
- if (strength > 0.0) {
6214
+ if (bulgePinch.strength > 0.0) {
6359
6215
  coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
6360
6216
  } else {
6361
6217
  coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
@@ -6365,11 +6221,11 @@ vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
6365
6221
  return coord;
6366
6222
  }
6367
6223
 
6368
- vec4 bulgePinch_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6224
+ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6369
6225
  vec2 coord = texCoord * texSize;
6370
6226
  coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
6371
6227
 
6372
- return warp_sampleColor(texture, texSize, coord);
6228
+ return warp_sampleColor(source, texSize, coord);
6373
6229
  }
6374
6230
  `;
6375
6231
  var bulgePinch = {
@@ -6381,29 +6237,17 @@ vec4 bulgePinch_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6381
6237
  strength: "f32"
6382
6238
  },
6383
6239
  uniformPropTypes: {
6384
- center: {
6385
- value: [0.5, 0.5]
6386
- },
6387
- radius: {
6388
- value: 200,
6389
- min: 1,
6390
- softMax: 600
6391
- },
6392
- strength: {
6393
- value: 0.5,
6394
- min: -1,
6395
- max: 1
6396
- }
6240
+ center: { value: [0.5, 0.5] },
6241
+ radius: { value: 200, min: 1, softMax: 600 },
6242
+ strength: { value: 0.5, min: -1, max: 1 }
6397
6243
  },
6398
6244
  dependencies: [warp],
6399
- passes: [{
6400
- sampler: true
6401
- }]
6245
+ passes: [{ sampler: true }]
6402
6246
  };
6403
6247
 
6404
6248
  // src/modules/postprocessing/image-warp-filters/swirl.ts
6405
6249
  var fs22 = glsl`\
6406
- uniform Swirl {
6250
+ uniform swirlUniforms {
6407
6251
  float radius;
6408
6252
  float angle;
6409
6253
  vec2 center;
@@ -6426,11 +6270,11 @@ vec2 swirl_warp(vec2 coord, vec2 texCenter) {
6426
6270
  return coord;
6427
6271
  }
6428
6272
 
6429
- vec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6273
+ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6430
6274
  vec2 coord = texCoord * texSize;
6431
6275
  coord = swirl_warp(coord, swirl.center * texSize);
6432
6276
 
6433
- return warp_sampleColor(texture, texSize, coord);
6277
+ return warp_sampleColor(source, texSize, coord);
6434
6278
  }
6435
6279
  `;
6436
6280
  var swirl = {
@@ -6442,24 +6286,12 @@ vec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6442
6286
  angle: "f32"
6443
6287
  },
6444
6288
  uniformPropTypes: {
6445
- center: {
6446
- value: [0.5, 0.5]
6447
- },
6448
- radius: {
6449
- value: 200,
6450
- min: 1,
6451
- softMax: 600
6452
- },
6453
- angle: {
6454
- value: 3,
6455
- softMin: -25,
6456
- softMax: 25
6457
- }
6289
+ center: { value: [0.5, 0.5] },
6290
+ radius: { value: 200, min: 1, softMax: 600 },
6291
+ angle: { value: 3, softMin: -25, softMax: 25 }
6458
6292
  },
6459
6293
  dependencies: [warp],
6460
- passes: [{
6461
- sampler: true
6462
- }]
6294
+ passes: [{ sampler: true }]
6463
6295
  };
6464
6296
 
6465
6297
  // src/modules/postprocessing/fxaa/fxaa.ts
@@ -6651,8 +6483,8 @@ vec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6651
6483
  #define FxaaTex sampler2D
6652
6484
 
6653
6485
  #define FxaaSat(x) clamp(x, 0.0, 1.0)
6654
- #define FxaaTexTop(t, p) texture2D(t, p)
6655
- #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r))
6486
+ #define FxaaTexTop(t, p) texture(t, p)
6487
+ #define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
6656
6488
 
6657
6489
  FxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }
6658
6490
 
@@ -7029,14 +6861,14 @@ FxaaFloat4 FxaaPixelShader_(
7029
6861
  return FxaaTexTop(tex, posM);
7030
6862
  }
7031
6863
 
7032
- vec4 fxaa_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
6864
+ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7033
6865
  const float fxaa_QualitySubpix = 0.5;
7034
6866
  const float fxaa_QualityEdgeThreshold = 0.125;
7035
6867
  const float fxaa_QualityEdgeThresholdMin = 0.0833;
7036
6868
 
7037
6869
  return FxaaPixelShader_(
7038
6870
  texCoord,
7039
- texture,
6871
+ source,
7040
6872
  vec2(1.0) / texSize,
7041
6873
  fxaa_QualitySubpix,
7042
6874
  fxaa_QualityEdgeThreshold,
@@ -7048,9 +6880,7 @@ vec4 fxaa_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
7048
6880
  name: "fxaa",
7049
6881
  uniformPropTypes: {},
7050
6882
  fs: fs23,
7051
- passes: [{
7052
- sampler: true
7053
- }]
6883
+ passes: [{ sampler: true }]
7054
6884
  };
7055
6885
 
7056
6886
  // src/modules-webgl1/math/fp64/fp64-utils.ts
@@ -7075,7 +6905,7 @@ vec4 fxaa_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
7075
6905
  return matrixFP64;
7076
6906
  }
7077
6907
 
7078
- // src/modules-webgl1/math/fp64/fp64-arithmetic.glsl.ts
6908
+ // src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts
7079
6909
  var fp64arithmeticShader = glsl`\
7080
6910
  uniform float ONE;
7081
6911
 
@@ -7244,7 +7074,7 @@ vec2 sqrt_fp64(vec2 a) {
7244
7074
  }
7245
7075
  `;
7246
7076
 
7247
- // src/modules-webgl1/math/fp64/fp64-functions.glsl.ts
7077
+ // src/modules-webgl1/math/fp64/fp64-functions-glsl.ts
7248
7078
  var fp64functionShader = glsl`\
7249
7079
  const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
7250
7080
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
@@ -7919,6 +7749,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
7919
7749
 
7920
7750
  // src/modules-webgl1/math/fp64/fp64.ts
7921
7751
  var CONST_UNIFORMS = {
7752
+ // Used in LUMA_FP64_CODE_ELIMINATION_WORKAROUND
7922
7753
  ONE: 1
7923
7754
  };
7924
7755
  function getUniforms4() {
@@ -7936,6 +7767,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
7936
7767
  name: "fp64",
7937
7768
  vs: fp64functionShader,
7938
7769
  dependencies: [fp64arithmetic],
7770
+ // Additional Functions
7939
7771
  fp64ify,
7940
7772
  fp64LowPart,
7941
7773
  fp64ifyMatrix4
@@ -9548,7 +9380,9 @@ vec3 geometry_getNormal() {
9548
9380
  uniforms.cameraPositionWorld = opts.cameraPositionWorld;
9549
9381
  }
9550
9382
  if (opts.projectionMatrix !== void 0 || opts.viewMatrix !== void 0) {
9551
- uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(opts.viewMatrix);
9383
+ uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(
9384
+ opts.viewMatrix
9385
+ );
9552
9386
  }
9553
9387
  return uniforms;
9554
9388
  }
@@ -9627,7 +9461,7 @@ ${common}`;
9627
9461
  fs: fs25
9628
9462
  };
9629
9463
 
9630
- // src/modules-webgl1/lighting/lights/lights.glsl.ts
9464
+ // src/modules-webgl1/lighting/lights/lights-glsl.ts
9631
9465
  var lightingShader = glsl`\
9632
9466
  #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
9633
9467
 
@@ -9670,10 +9504,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9670
9504
  lightSources: {}
9671
9505
  };
9672
9506
  function convertColor2(colorDef = {}) {
9673
- const {
9674
- color = [0, 0, 0],
9675
- intensity = 1
9676
- } = colorDef;
9507
+ const { color = [0, 0, 0], intensity = 1 } = colorDef;
9677
9508
  return color.map((component) => component * intensity / 255);
9678
9509
  }
9679
9510
  function getLightSourceUniforms2({
@@ -9690,7 +9521,11 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9690
9521
  pointLights.forEach((pointLight, index2) => {
9691
9522
  lightSourceUniforms[`lighting_uPointLight[${index2}].color`] = convertColor2(pointLight);
9692
9523
  lightSourceUniforms[`lighting_uPointLight[${index2}].position`] = pointLight.position;
9693
- lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [1, 0, 0];
9524
+ lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [
9525
+ 1,
9526
+ 0,
9527
+ 0
9528
+ ];
9694
9529
  });
9695
9530
  lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
9696
9531
  directionalLights.forEach((directionalLight, index2) => {
@@ -9702,30 +9537,21 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9702
9537
  }
9703
9538
  function getUniforms6(opts = INITIAL_MODULE_OPTIONS) {
9704
9539
  if ("lightSources" in opts) {
9705
- const {
9706
- ambientLight,
9707
- pointLights,
9708
- directionalLights
9709
- } = opts.lightSources || {};
9540
+ const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
9710
9541
  const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
9711
9542
  if (!hasLights) {
9712
- return {
9713
- lighting_uEnabled: false
9714
- };
9543
+ return { lighting_uEnabled: false };
9715
9544
  }
9716
- return Object.assign({}, getLightSourceUniforms2({
9717
- ambientLight,
9718
- pointLights,
9719
- directionalLights
9720
- }), {
9721
- lighting_uEnabled: true
9722
- });
9545
+ return Object.assign(
9546
+ {},
9547
+ getLightSourceUniforms2({ ambientLight, pointLights, directionalLights }),
9548
+ {
9549
+ lighting_uEnabled: true
9550
+ }
9551
+ );
9723
9552
  }
9724
9553
  if ("lights" in opts) {
9725
- const lightSources = {
9726
- pointLights: [],
9727
- directionalLights: []
9728
- };
9554
+ const lightSources = { pointLights: [], directionalLights: [] };
9729
9555
  for (const light of opts.lights || []) {
9730
9556
  switch (light.type) {
9731
9557
  case "ambient":
@@ -9740,9 +9566,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9740
9566
  default:
9741
9567
  }
9742
9568
  }
9743
- return getUniforms6({
9744
- lightSources
9745
- });
9569
+ return getUniforms6({ lightSources });
9746
9570
  }
9747
9571
  return {};
9748
9572
  }
@@ -9781,12 +9605,13 @@ vec4 dirlight_filterColor(vec4 color) {
9781
9605
  `;
9782
9606
  var dirlight2 = {
9783
9607
  name: "dirlight",
9608
+ // vs // TODO - reuse normal from geometry module
9784
9609
  fs: fs26,
9785
9610
  getUniforms: getUniforms7,
9786
9611
  dependencies: [project]
9787
9612
  };
9788
9613
 
9789
- // src/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.ts
9614
+ // src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts
9790
9615
  var lightingShader2 = glsl`\
9791
9616
 
9792
9617
  uniform float lighting_uAmbient;
@@ -9866,12 +9691,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
9866
9691
  // src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts
9867
9692
  var INITIAL_MODULE_OPTIONS2 = {};
9868
9693
  function getMaterialUniforms(material) {
9869
- const {
9870
- ambient = 0.35,
9871
- diffuse = 0.6,
9872
- shininess = 32,
9873
- specularColor = [30, 30, 30]
9874
- } = material;
9694
+ const { ambient = 0.35, diffuse = 0.6, shininess = 32, specularColor = [30, 30, 30] } = material;
9875
9695
  return {
9876
9696
  lighting_uAmbient: ambient,
9877
9697
  lighting_uDiffuse: diffuse,
@@ -9883,13 +9703,9 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
9883
9703
  if (!("material" in opts)) {
9884
9704
  return {};
9885
9705
  }
9886
- const {
9887
- material
9888
- } = opts;
9706
+ const { material } = opts;
9889
9707
  if (!material) {
9890
- return {
9891
- lighting_uEnabled: false
9892
- };
9708
+ return { lighting_uEnabled: false };
9893
9709
  }
9894
9710
  return getMaterialUniforms(material);
9895
9711
  }
@@ -9912,7 +9728,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
9912
9728
  getUniforms: getUniforms8
9913
9729
  };
9914
9730
 
9915
- // src/modules-webgl1/lighting/pbr/pbr-vertex.glsl.ts
9731
+ // src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts
9916
9732
  var vs5 = glsl`\
9917
9733
  uniform mat4 u_MVPMatrix;
9918
9734
  uniform mat4 u_ModelMatrix;
@@ -9953,7 +9769,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
9953
9769
  }
9954
9770
  `;
9955
9771
 
9956
- // src/modules-webgl1/lighting/pbr/pbr-fragment.glsl.ts
9772
+ // src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
9957
9773
  var fs27 = glsl`\
9958
9774
  #if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
9959
9775
  # error PBR fragment shader: Texture LOD is not available
@@ -9963,14 +9779,8 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
9963
9779
  # error PBR fragment shader: Derivatives are not available
9964
9780
  #endif
9965
9781
 
9966
- // WebGL 1.0 does not support non-constant in for loops
9967
- // This provides an easy way to handle these cases
9968
- // and still take advantage of WebGL 2.0
9969
- #if (__VERSION__ < 300)
9970
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)
9971
- #else
9972
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
9973
- #endif
9782
+ // TODO - remove we no longer support WebGL1
9783
+ #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
9974
9784
 
9975
9785
  precision highp float;
9976
9786