@luma.gl/shadertools 9.1.0-alpha.1 → 9.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/dist.dev.js +816 -483
  2. package/dist/dist.min.js +2325 -1622
  3. package/dist/index.cjs +2669 -1808
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +29 -28
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +8 -12
  8. package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
  9. package/dist/lib/glsl-utils/shader-utils.js +2 -3
  10. package/dist/lib/shader-assembler.d.ts +3 -4
  11. package/dist/lib/shader-assembler.d.ts.map +1 -1
  12. package/dist/lib/shader-assembler.js +3 -2
  13. package/dist/lib/shader-assembly/assemble-shaders.d.ts +4 -3
  14. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  15. package/dist/lib/shader-assembly/assemble-shaders.js +43 -16
  16. package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -1
  17. package/dist/lib/shader-assembly/platform-defines.js +14 -6
  18. package/dist/lib/shader-module/shader-module-dependencies.d.ts +53 -0
  19. package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
  20. package/dist/lib/{shader-assembly/resolve-modules.js → shader-module/shader-module-dependencies.js} +38 -14
  21. package/dist/lib/shader-module/shader-module.d.ts +29 -11
  22. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  23. package/dist/lib/shader-module/shader-module.js +76 -6
  24. package/dist/lib/shader-module/shader-pass.d.ts +3 -2
  25. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  26. package/dist/module-injectors.d.ts +2 -2
  27. package/dist/module-injectors.d.ts.map +1 -1
  28. package/dist/module-injectors.js +13 -10
  29. package/dist/modules/engine/geometry/geometry.d.ts.map +1 -1
  30. package/dist/modules/engine/geometry/geometry.js +12 -8
  31. package/dist/modules/engine/picking/picking.d.ts +4 -4
  32. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  33. package/dist/modules/engine/picking/picking.js +103 -66
  34. package/dist/modules/engine/project/project.d.ts +2 -2
  35. package/dist/modules/engine/project/project.d.ts.map +1 -1
  36. package/dist/modules/engine/project/project.js +36 -22
  37. package/dist/modules/engine/transform/transform.d.ts.map +1 -1
  38. package/dist/modules/engine/transform/transform.js +28 -16
  39. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +9 -7
  40. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  41. package/dist/modules/lighting/gouraud-material/gouraud-material.js +2 -0
  42. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +2 -2
  43. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
  44. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +79 -53
  45. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  46. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  47. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +38 -23
  48. package/dist/modules/lighting/lights/lighting.d.ts +4 -4
  49. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  50. package/dist/modules/lighting/lights/lighting.js +2 -2
  51. package/dist/modules/lighting/no-material/dirlight.d.ts +4 -4
  52. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  53. package/dist/modules/lighting/no-material/dirlight.js +12 -9
  54. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
  55. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  56. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +304 -181
  57. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +71 -69
  58. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  59. package/dist/modules/lighting/pbr-material/pbr-material.js +4 -2
  60. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +1 -1
  61. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -1
  62. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +38 -20
  63. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
  64. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  65. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +21 -16
  66. package/dist/modules/lighting/phong-material/phong-material.d.ts +12 -12
  67. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  68. package/dist/modules/lighting/phong-material/phong-material.js +3 -3
  69. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  70. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  71. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +82 -54
  72. package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
  73. package/dist/modules/math/fp32/fp32.js +127 -100
  74. package/dist/modules/math/random/random.d.ts +1 -1
  75. package/dist/modules/math/random/random.d.ts.map +1 -1
  76. package/dist/modules/math/random/random.js +3 -3
  77. package/dist/modules/module-injectors.d.ts +2 -2
  78. package/dist/modules/module-injectors.d.ts.map +1 -1
  79. package/dist/modules/module-injectors.js +13 -10
  80. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +4 -1
  81. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  82. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +16 -12
  83. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +4 -1
  84. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  85. package/dist/modules/postprocessing/image-adjust-filters/denoise.js +21 -17
  86. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +5 -2
  87. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  88. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +29 -22
  89. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +4 -1
  90. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  91. package/dist/modules/postprocessing/image-adjust-filters/noise.js +14 -10
  92. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +4 -1
  93. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  94. package/dist/modules/postprocessing/image-adjust-filters/sepia.js +17 -12
  95. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +4 -1
  96. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  97. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +12 -9
  98. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +4 -1
  99. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  100. package/dist/modules/postprocessing/image-adjust-filters/vignette.js +13 -10
  101. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +5 -2
  102. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  103. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +40 -26
  104. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +5 -2
  105. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  106. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +32 -19
  107. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +4 -1
  108. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  109. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +2 -0
  110. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +4 -1
  111. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  112. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +31 -27
  113. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +4 -1
  114. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  115. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +19 -15
  116. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +8 -5
  117. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  118. package/dist/modules/postprocessing/image-fun-filters/edgework.js +53 -42
  119. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +4 -1
  120. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  121. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +41 -33
  122. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +4 -1
  123. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
  124. package/dist/modules/postprocessing/image-fun-filters/ink.js +27 -25
  125. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -1
  126. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  127. package/dist/modules/postprocessing/image-fun-filters/magnify.js +17 -16
  128. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -2
  129. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  130. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +24 -20
  131. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +5 -2
  132. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
  133. package/dist/modules/postprocessing/image-warp-filters/swirl.js +26 -22
  134. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +2 -1
  135. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
  136. package/dist/modules/postprocessing/image-warp-filters/warp.js +9 -8
  137. package/dist/modules-webgl1/geometry/geometry.d.ts.map +1 -1
  138. package/dist/modules-webgl1/geometry/geometry.js +12 -8
  139. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
  140. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +8 -5
  141. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +1 -1
  142. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -1
  143. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +19 -11
  144. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +1 -1
  145. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -1
  146. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +268 -157
  147. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +1 -1
  148. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -1
  149. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +16 -12
  150. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +1 -1
  151. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -1
  152. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +64 -55
  153. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  154. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  155. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +113 -81
  156. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +1 -1
  157. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -1
  158. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +588 -433
  159. package/dist/modules-webgl1/project/project.d.ts +2 -2
  160. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  161. package/dist/modules-webgl1/project/project.js +5 -4
  162. package/package.json +2 -2
  163. package/src/index.ts +78 -32
  164. package/src/lib/glsl-utils/shader-utils.ts +1 -3
  165. package/src/lib/shader-assembler.ts +7 -8
  166. package/src/lib/shader-assembly/assemble-shaders.ts +52 -20
  167. package/src/lib/shader-assembly/platform-defines.ts +5 -6
  168. package/src/lib/shader-module/shader-module-dependencies.ts +112 -0
  169. package/src/lib/shader-module/shader-module.ts +129 -18
  170. package/src/lib/shader-module/shader-pass.ts +3 -2
  171. package/src/module-injectors.ts +2 -4
  172. package/src/modules/engine/geometry/geometry.ts +2 -3
  173. package/src/modules/engine/picking/picking.ts +7 -5
  174. package/src/modules/engine/project/project.ts +2 -3
  175. package/src/modules/engine/transform/transform.ts +1 -3
  176. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  177. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +2 -4
  178. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +1 -3
  179. package/src/modules/lighting/lights/lighting.ts +4 -2
  180. package/src/modules/lighting/no-material/dirlight.ts +6 -5
  181. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +1 -2
  182. package/src/modules/lighting/pbr-material/pbr-material.ts +44 -38
  183. package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +1 -3
  184. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +1 -3
  185. package/src/modules/lighting/phong-material/phong-material.ts +4 -3
  186. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -4
  187. package/src/modules/math/fp32/fp32.ts +1 -2
  188. package/src/modules/math/random/random.ts +1 -2
  189. package/src/modules/module-injectors.ts +2 -4
  190. package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -2
  191. package/src/modules/postprocessing/image-adjust-filters/denoise.ts +7 -3
  192. package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +9 -4
  193. package/src/modules/postprocessing/image-adjust-filters/noise.ts +6 -2
  194. package/src/modules/postprocessing/image-adjust-filters/sepia.ts +6 -2
  195. package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +5 -2
  196. package/src/modules/postprocessing/image-adjust-filters/vignette.ts +11 -4
  197. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +6 -2
  198. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +6 -2
  199. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +5 -0
  200. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +6 -2
  201. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +6 -2
  202. package/src/modules/postprocessing/image-fun-filters/edgework.ts +10 -4
  203. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +6 -2
  204. package/src/modules/postprocessing/image-fun-filters/ink.ts +8 -3
  205. package/src/modules/postprocessing/image-fun-filters/magnify.ts +3 -2
  206. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +6 -2
  207. package/src/modules/postprocessing/image-warp-filters/swirl.ts +8 -2
  208. package/src/modules/postprocessing/image-warp-filters/warp.ts +3 -2
  209. package/src/modules-webgl1/geometry/geometry.ts +2 -3
  210. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +1 -2
  211. package/src/modules-webgl1/lighting/lights/lights-glsl.ts +1 -3
  212. package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +1 -2
  213. package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +1 -3
  214. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +1 -3
  215. package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +1 -3
  216. package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +1 -3
  217. package/src/modules-webgl1/project/project.ts +1 -2
  218. package/dist/lib/glsl-utils/highlight.d.ts +0 -6
  219. package/dist/lib/glsl-utils/highlight.d.ts.map +0 -1
  220. package/dist/lib/glsl-utils/highlight.js +0 -9
  221. package/dist/lib/shader-assembly/resolve-modules.d.ts +0 -40
  222. package/dist/lib/shader-assembly/resolve-modules.d.ts.map +0 -1
  223. package/dist/lib/shader-module/normalize-shader-module.d.ts +0 -3
  224. package/dist/lib/shader-module/normalize-shader-module.d.ts.map +0 -1
  225. package/dist/lib/shader-module/normalize-shader-module.js +0 -14
  226. package/dist/lib/shader-module/shader-module-instance.d.ts +0 -28
  227. package/dist/lib/shader-module/shader-module-instance.d.ts.map +0 -1
  228. package/dist/lib/shader-module/shader-module-instance.js +0 -126
  229. package/src/lib/glsl-utils/highlight.ts +0 -11
  230. package/src/lib/shader-assembly/resolve-modules.ts +0 -81
  231. package/src/lib/shader-module/normalize-shader-module.ts +0 -17
  232. package/src/lib/shader-module/shader-module-instance.ts +0 -167
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,IAAI,WAAW,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAM5E;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IACnD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IACnD,oBAAoB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IACvD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;CACvD,CAAC;AASF,iBAAS,WAAW,CAClB,IAAI,GAAE,eAAwC,EAC9C,YAAY,GAAE,kBAAuB,GACpC,kBAAkB,CAuBpB;AAmFD;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;CAY+C,CAAC"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,IAAI,WAAW,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAK5E;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IACnD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IACnD,oBAAoB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;IACvD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;CACvD,CAAC;AASF,iBAAS,WAAW,CAClB,IAAI,GAAE,eAAwC,EAC9C,YAAY,GAAE,kBAAuB,GACpC,kBAAkB,CAuBpB;AAmFD;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;CAY+C,CAAC"}
@@ -2,7 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { Matrix4 } from '@math.gl/core';
5
- import { glsl } from "../../../lib/glsl-utils/highlight.js";
6
5
  const IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
7
6
  const DEFAULT_MODULE_OPTIONS = {
8
7
  viewMatrix: IDENTITY_MATRIX,
@@ -36,62 +35,77 @@ function getUniforms(opts = DEFAULT_MODULE_OPTIONS, prevUniforms = {}) {
36
35
  * @note varyings must match vertex shader
37
36
  * @note project module uses unprefixed uniforms to match conventions
38
37
  */
39
- const vs = `\
38
+ const vs = /* glsl */ `\
40
39
  varying vec4 project_vPositionWorld;
41
40
  varying vec3 project_vNormalWorld;
41
+
42
+ // Project uniform block
42
43
  uniform Project {
43
- mat4 viewMatrix;
44
- mat4 projectionMatrix;
45
- mat4 viewProjectionMatrix;
46
- vec3 cameraPositionWorld;
44
+ mat4 viewMatrix;
45
+ mat4 projectionMatrix;
46
+ mat4 viewProjectionMatrix;
47
+ vec3 cameraPositionWorld;
47
48
  } project;
49
+
48
50
  struct World {
49
- vec3 position;
50
- vec3 normal;
51
+ vec3 position;
52
+ vec3 normal;
51
53
  };
54
+
52
55
  World world;
56
+
53
57
  void project_setPosition(vec4 position) {
54
- project_vPositionWorld = position;
58
+ project_vPositionWorld = position;
55
59
  }
60
+
56
61
  void project_setNormal(vec3 normal) {
57
- project_vNormalWorld = normal;
62
+ project_vNormalWorld = normal;
58
63
  }
64
+
59
65
  void project_setPositionAndNormal_World(vec3 position, vec3 normal) {
60
- world.position = position;
61
- world.normal = normal;
66
+ world.position = position;
67
+ world.normal = normal;
62
68
  }
69
+
63
70
  void project_setPositionAndNormal_Model(vec3 position, vec3 normal, mat4 modelMatrix) {
64
- world.position = (modelMatrix * vec4(position, 1.)).xyz;
65
- world.normal = mat3(modelMatrix) * normal;
71
+ world.position = (modelMatrix * vec4(position, 1.)).xyz;
72
+ world.normal = mat3(modelMatrix) * normal;
66
73
  }
74
+
67
75
  vec4 project_model_to_clipspace(vec4 position) {
68
- return project.viewProjectionMatrix * position;
76
+ return project.viewProjectionMatrix * position;
69
77
  }
78
+
70
79
  vec4 project_model_to_clipspace_Model(vec3 position, mat4 modelMatrix) {
71
- return project.viewProjectionMatrix * modelMatrix * vec4(position, 1.);
80
+ return project.viewProjectionMatrix * modelMatrix * vec4(position, 1.);
72
81
  }
82
+
73
83
  vec4 project_world_to_clipspace(vec3 position) {
74
- return project.viewProjectionMatrix * vec4(position, 1.);
84
+ return project.viewProjectionMatrix * vec4(position, 1.);
75
85
  }
86
+
76
87
  vec4 project_view_to_clipspace(vec3 position) {
77
- return project.projectionMatrix * vec4(position, 1.);
88
+ return project.projectionMatrix * vec4(position, 1.);
78
89
  }
90
+
79
91
  vec4 project_to_clipspace(vec3 position) {
80
- return project.viewProjectionMatrix * vec4(position, 1.);
92
+ return project.viewProjectionMatrix * vec4(position, 1.);
81
93
  }
82
94
  `;
83
95
  /**
84
96
  * Functions to get the position and normal from the vertex shader
85
97
  * @note varyings must match vertex shader
86
98
  */
87
- const fs = `\
99
+ const fs = /* glsl */ `\
88
100
  varying vec4 project_vPositionWorld;
89
101
  varying vec3 project_vNormalWorld;
102
+
90
103
  vec4 project_getPosition_World() {
91
- return project_vPositionWorld;
104
+ return project_vPositionWorld;
92
105
  }
106
+
93
107
  vec3 project_getNormal_World() {
94
- return project_vNormalWorld;
108
+ return project_vNormalWorld;
95
109
  }
96
110
  `;
97
111
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/transform/transform.ts"],"names":[],"mappings":"AA+CA,gDAAgD;AAChD,eAAO,MAAM,SAAS;;;CAGrB,CAAC"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/transform/transform.ts"],"names":[],"mappings":"AA6CA,gDAAgD;AAChD,eAAO,MAAM,SAAS;;;CAGrB,CAAC"}
@@ -1,32 +1,44 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { glsl } from "../../../lib/glsl-utils/highlight.js";
5
- const vs = `\
4
+ const vs = /* glsl */ `\
6
5
  attribute float transform_elementID;
6
+
7
+ // returns half of pixel size, used to move the pixel position to center of the pixel.
7
8
  vec2 transform_getPixelSizeHalf(vec2 size) {
8
- return vec2(1.) / (2. * size);
9
+ return vec2(1.) / (2. * size);
9
10
  }
11
+
12
+ // returns current elements pixel indeces [x, y],
13
+ // where x ranges in [0 to texSize-1] and y ranges in [0 to texSize-1]
10
14
  vec2 transform_getPixelIndices(vec2 texSize, vec2 pixelSizeHalf) {
11
- float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);
12
- float xIndex = transform_elementID - (yIndex * texSize[0]);
13
- return vec2(xIndex, yIndex);
15
+ // Add safe offset (half of pixel height) before doing floor
16
+ float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);
17
+ float xIndex = transform_elementID - (yIndex * texSize[0]);
18
+ return vec2(xIndex, yIndex);
14
19
  }
20
+
21
+ // returns current elementID's texture co-ordianate
15
22
  vec2 transform_getTexCoord(vec2 size) {
16
- vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);
17
- vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);
18
- vec2 coord = indices / size + pixelSizeHalf;
19
- return coord;
23
+ vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);
24
+ vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);
25
+ vec2 coord = indices / size + pixelSizeHalf;
26
+ return coord;
20
27
  }
28
+
29
+ // returns current elementID's position
21
30
  vec2 transform_getPos(vec2 size) {
22
- vec2 texCoord = transform_getTexCoord(size);
23
- vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);
24
- return pos;
31
+ vec2 texCoord = transform_getTexCoord(size);
32
+ // Change from [0 1] range to [-1 1]
33
+ vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);
34
+ return pos;
25
35
  }
36
+
37
+ // returns current elementID's pixel value
26
38
  vec4 transform_getInput(sampler2D texSampler, vec2 size) {
27
- vec2 texCoord = transform_getTexCoord(size);
28
- vec4 textureColor = texture2D(texSampler, texCoord);
29
- return textureColor;
39
+ vec2 texCoord = transform_getTexCoord(size);
40
+ vec4 textureColor = texture2D(texSampler, texCoord);
41
+ return textureColor;
30
42
  }
31
43
  `;
32
44
  /** Private shader module used by `Transform` */
@@ -8,13 +8,17 @@ export type GouraudMaterialUniforms = {
8
8
  };
9
9
  /** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
10
10
  export declare const gouraudMaterial: {
11
+ readonly props: GouraudMaterialProps;
12
+ readonly uniforms: GouraudMaterialUniforms;
11
13
  readonly name: "gouraud-lighting";
12
- readonly vs: string;
13
- readonly fs: string;
14
+ readonly vs: "uniform materialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
15
+ readonly fs: "uniform materialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting.enabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0:\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n break;\n\n case 1:\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n break;\n }\n }\n return lightColor;\n}\n";
14
16
  readonly defines: {
15
17
  readonly LIGHTING_VERTEX: 1;
16
18
  };
17
19
  readonly dependencies: [{
20
+ readonly props: import("../lights/lighting").LightingProps;
21
+ readonly uniforms: import("../lights/lighting").LightingUniforms;
18
22
  readonly name: "lighting";
19
23
  readonly defines: {
20
24
  readonly MAX_LIGHTS: 5;
@@ -39,11 +43,9 @@ export declare const gouraudMaterial: {
39
43
  readonly lightDirection: readonly [1, 1, 1];
40
44
  readonly lightAttenuation: readonly [1, 1, 1];
41
45
  };
42
- readonly vs: string;
43
- readonly fs: string;
44
- readonly props: Required<import("../lights/lighting").LightingProps>;
45
- readonly uniforms: import("../lights/lighting").LightingUniforms;
46
- readonly getUniforms: (props?: import("../lights/lighting").LightingProps | undefined, prevUniforms?: Partial<import("../lights/lighting").LightingUniforms>) => import("../lights/lighting").LightingUniforms;
46
+ readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
47
+ readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
48
+ readonly getUniforms: (props?: import("../lights/lighting").LightingProps, prevUniforms?: Partial<import("../lights/lighting").LightingUniforms>) => import("../lights/lighting").LightingUniforms;
47
49
  }];
48
50
  readonly uniformTypes: {
49
51
  readonly ambient: "f32";
@@ -1 +1 @@
1
- {"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAE3D,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,yIAAyI;AACzI,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAqBP,oBAAoB,KAAG,uBAAuB;CAGa,CAAC"}
1
+ {"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAE3D,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,yIAAyI;AACzI,eAAO,MAAM,eAAe;oBACb,oBAAoB;uBACjB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAuBpB,oBAAoB,KAAG,uBAAuB;CAGa,CAAC"}
@@ -5,6 +5,8 @@ import { lighting } from "../lights/lighting.js";
5
5
  import { GOURAUD_VS, GOURAUD_FS } from "./gouraud-shaders-glsl.js";
6
6
  /** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
7
7
  export const gouraudMaterial = {
8
+ props: {},
9
+ uniforms: {},
8
10
  name: 'gouraud-lighting',
9
11
  // Note these are switched between phong and gouraud
10
12
  vs: GOURAUD_VS,
@@ -1,5 +1,5 @@
1
- export declare const GOURAUD_VS: string;
2
- export declare const GOURAUD_FS: string;
1
+ export declare const GOURAUD_VS = "uniform materialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
2
+ export declare const GOURAUD_FS = "uniform materialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting.enabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0:\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n break;\n\n case 1:\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n break;\n }\n }\n return lightColor;\n}\n";
3
3
  /**
4
4
  for (int i = 0; i < MAX_LIGHTS; i++) {
5
5
  if (i >= lighting.pointLightCount) {
@@ -1 +1 @@
1
- {"version":3,"file":"gouraud-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,QAOtB,CAAC;AAEF,eAAO,MAAM,UAAU,QAkFtB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsCI"}
1
+ {"version":3,"file":"gouraud-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,8JAOtB,CAAC;AAEF,eAAO,MAAM,UAAU,ihHAkFtB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsCI"}
@@ -1,69 +1,95 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { glsl } from "../../../lib/glsl-utils/highlight.js";
5
- export const GOURAUD_VS = `\
4
+ export const GOURAUD_VS = /* glsl */ `\
6
5
  uniform materialUniforms {
7
- uniform float ambient;
8
- uniform float diffuse;
9
- uniform float shininess;
10
- uniform vec3 specularColor;
6
+ uniform float ambient;
7
+ uniform float diffuse;
8
+ uniform float shininess;
9
+ uniform vec3 specularColor;
11
10
  } material;
12
11
  `;
13
- export const GOURAUD_FS = `\
12
+ export const GOURAUD_FS = /* glsl */ `\
14
13
  uniform materialUniforms {
15
- uniform float ambient;
16
- uniform float diffuse;
17
- uniform float shininess;
18
- uniform vec3 specularColor;
14
+ uniform float ambient;
15
+ uniform float diffuse;
16
+ uniform float shininess;
17
+ uniform vec3 specularColor;
19
18
  } material;
19
+
20
20
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
21
- vec3 halfway_direction = normalize(light_direction + view_direction);
22
- float lambertian = dot(light_direction, normal_worldspace);
23
- float specular = 0.0;
24
- if (lambertian > 0.0) {
25
- float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
26
- specular = pow(specular_angle, material.shininess);
27
- }
28
- lambertian = max(lambertian, 0.0);
29
- return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
21
+ vec3 halfway_direction = normalize(light_direction + view_direction);
22
+ float lambertian = dot(light_direction, normal_worldspace);
23
+ float specular = 0.0;
24
+ if (lambertian > 0.0) {
25
+ float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
26
+ specular = pow(specular_angle, material.shininess);
27
+ }
28
+ lambertian = max(lambertian, 0.0);
29
+ return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
30
30
  }
31
+
31
32
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
32
- vec3 lightColor = surfaceColor;
33
- if (lighting.enabled) {
34
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
35
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
36
- if (lighting.lightType == 0) {
37
- PointLight pointLight = lighting_getPointLight(0);
38
- vec3 light_position_worldspace = pointLight.position;
39
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
40
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
41
- } else if (lighting.lightType == 1) {
42
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
43
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
44
- }
45
- }
46
- return lightColor;
33
+ vec3 lightColor = surfaceColor;
34
+
35
+ if (lighting.enabled) {
36
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
37
+ lightColor = material.ambient * surfaceColor * lighting.ambientColor;
38
+
39
+ if (lighting.lightType == 0) {
40
+ PointLight pointLight = lighting_getPointLight(0);
41
+ vec3 light_position_worldspace = pointLight.position;
42
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
43
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
44
+ } else if (lighting.lightType == 1) {
45
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
46
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
47
+ }
48
+ /*
49
+ for (int i = 0; i < MAX_LIGHTS; i++) {
50
+ if (i >= lighting.pointLightCount) {
51
+ break;
52
+ }
53
+ PointLight pointLight = lighting.pointLight[i];
54
+ vec3 light_position_worldspace = pointLight.position;
55
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
56
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
57
+ }
58
+
59
+ for (int i = 0; i < MAX_LIGHTS; i++) {
60
+ if (i >= lighting.directionalLightCount) {
61
+ break;
62
+ }
63
+ DirectionalLight directionalLight = lighting.directionalLight[i];
64
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
65
+ }
66
+ */
67
+ }
68
+ return lightColor;
47
69
  }
70
+
48
71
  vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
49
- vec3 lightColor = vec3(0, 0, 0);
50
- vec3 surfaceColor = vec3(0, 0, 0);
51
- if (lighting.enabled) {
52
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
53
- switch (lighting.lightType) {
54
- case 0:
55
- PointLight pointLight = lighting_getPointLight(0);
56
- vec3 light_position_worldspace = pointLight.position;
57
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
58
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
59
- break;
60
- case 1:
61
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
62
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
63
- break;
64
- }
65
- }
66
- return lightColor;
72
+ vec3 lightColor = vec3(0, 0, 0);
73
+ vec3 surfaceColor = vec3(0, 0, 0);
74
+
75
+ if (lighting.enabled) {
76
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
77
+
78
+ switch (lighting.lightType) {
79
+ case 0:
80
+ PointLight pointLight = lighting_getPointLight(0);
81
+ vec3 light_position_worldspace = pointLight.position;
82
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
83
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
84
+ break;
85
+
86
+ case 1:
87
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
88
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
89
+ break;
90
+ }
91
+ }
92
+ return lightColor;
67
93
  }
68
94
  `;
69
95
  // TODO - handle multiple lights
@@ -1,2 +1,2 @@
1
- export declare const lightingUniforms: string;
1
+ export declare const lightingUniforms = "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
2
2
  //# sourceMappingURL=lighting-uniforms-glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lighting-uniforms-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-glsl.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,QAoD5B,CAAC"}
1
+ {"version":3,"file":"lighting-uniforms-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,6wCAoD5B,CAAC"}
@@ -1,41 +1,56 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { glsl } from "../../../lib/glsl-utils/highlight.js";
5
- export const lightingUniforms = `\
4
+ export const lightingUniforms = /* glsl */ `\
6
5
  precision highp int;
6
+
7
+ // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
7
8
  struct AmbientLight {
8
- vec3 color;
9
+ vec3 color;
9
10
  };
11
+
10
12
  struct PointLight {
11
- vec3 color;
12
- vec3 position;
13
- vec3 attenuation;
13
+ vec3 color;
14
+ vec3 position;
15
+ vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
14
16
  };
17
+
15
18
  struct DirectionalLight {
16
- vec3 color;
17
- vec3 direction;
19
+ vec3 color;
20
+ vec3 direction;
18
21
  };
22
+
19
23
  uniform lightingUniforms {
20
- int enabled;
21
- int pointLightCount;
22
- int directionalLightCount;
23
- vec3 ambientColor;
24
- int lightType;
25
- vec3 lightColor;
26
- vec3 lightDirection;
27
- vec3 lightPosition;
28
- vec3 lightAttenuation;
24
+ int enabled;
25
+ int pointLightCount;
26
+ int directionalLightCount;
27
+
28
+ vec3 ambientColor;
29
+
30
+ int lightType;
31
+ vec3 lightColor;
32
+ vec3 lightDirection;
33
+ vec3 lightPosition;
34
+ vec3 lightAttenuation;
35
+
36
+ // AmbientLight ambientLight;
37
+ // PointLight pointLight[MAX_LIGHTS];
38
+ // DirectionalLight directionalLight[MAX_LIGHTS];
29
39
  } lighting;
40
+
30
41
  PointLight lighting_getPointLight(int index) {
31
- return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
42
+ return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
32
43
  }
44
+
33
45
  DirectionalLight lighting_getDirectionalLight(int index) {
34
- return DirectionalLight(lighting.lightColor, lighting.lightDirection);
35
- }
46
+ return DirectionalLight(lighting.lightColor, lighting.lightDirection);
47
+ }
48
+
36
49
  float getPointLightAttenuation(PointLight pointLight, float distance) {
37
- return pointLight.attenuation.x
38
- + pointLight.attenuation.y * distance
39
- + pointLight.attenuation.z * distance * distance;
50
+ return pointLight.attenuation.x
51
+ + pointLight.attenuation.y * distance
52
+ + pointLight.attenuation.z * distance * distance;
40
53
  }
54
+
55
+ // #endif
41
56
  `;
@@ -47,6 +47,8 @@ export type LightingUniforms = {
47
47
  };
48
48
  /** UBO ready lighting module */
49
49
  export declare const lighting: {
50
+ readonly props: LightingProps;
51
+ readonly uniforms: LightingUniforms;
50
52
  readonly name: "lighting";
51
53
  readonly defines: {
52
54
  readonly MAX_LIGHTS: 5;
@@ -71,10 +73,8 @@ export declare const lighting: {
71
73
  readonly lightDirection: readonly [1, 1, 1];
72
74
  readonly lightAttenuation: readonly [1, 1, 1];
73
75
  };
74
- readonly vs: string;
75
- readonly fs: string;
76
- readonly props: Required<LightingProps>;
77
- readonly uniforms: LightingUniforms;
76
+ readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
77
+ readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
78
78
  readonly getUniforms: typeof getUniforms;
79
79
  };
80
80
  declare function getUniforms(props?: LightingProps, prevUniforms?: Partial<LightingUniforms>): LightingUniforms;
@@ -1 +1 @@
1
- {"version":3,"file":"lighting.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAUhD,mCAAmC;AACnC,oBAAY,UAAU;IACpB,KAAK,IAAI;IACT,WAAW,IAAI;CAChB;AAED,4BAA4B;AAE5B,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,kBAAkB;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,kBAAkB;IAClB,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClC,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,cAAc,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACzC,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC6C,CAAC;AAEnE,iBAAS,WAAW,CAClB,KAAK,CAAC,EAAE,aAAa,EACrB,YAAY,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAC3C,gBAAgB,CAoClB"}
1
+ {"version":3,"file":"lighting.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAUhD,mCAAmC;AACnC,oBAAY,UAAU;IACpB,KAAK,IAAI;IACT,WAAW,IAAI;CAChB;AAED,4BAA4B;AAE5B,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,kBAAkB;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,kBAAkB;IAClB,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClC,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,cAAc,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACzC,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCgC,CAAC;AAEnE,iBAAS,WAAW,CAClB,KAAK,CAAC,EAAE,aAAa,EACrB,YAAY,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAC3C,gBAAgB,CAoClB"}
@@ -14,6 +14,8 @@ export var LIGHT_TYPE;
14
14
  })(LIGHT_TYPE || (LIGHT_TYPE = {}));
15
15
  /** UBO ready lighting module */
16
16
  export const lighting = {
17
+ props: {},
18
+ uniforms: {},
17
19
  name: 'lighting',
18
20
  defines: {
19
21
  MAX_LIGHTS
@@ -42,8 +44,6 @@ export const lighting = {
42
44
  },
43
45
  vs: lightingUniforms,
44
46
  fs: lightingUniforms,
45
- props: {},
46
- uniforms: {},
47
47
  getUniforms
48
48
  };
49
49
  function getUniforms(props, prevUniforms = {}) {
@@ -9,18 +9,18 @@ export declare const FS_WGSL = "uniform dirlightUniforms {\n vec3 lightDirectio
9
9
  * Cheap lighting - single directional light, single dot product, one uniform
10
10
  */
11
11
  export declare const dirlight: {
12
+ readonly props: DirlightProps;
13
+ readonly uniforms: DirlightUniforms;
12
14
  readonly name: "dirlight";
13
15
  readonly dependencies: [];
14
- readonly vs: string;
15
- readonly fs: string;
16
+ readonly vs: "out vec3 dirlight_vNormal;\n\nvoid dirlight_setNormal(vec3 normal) {\n dirlight_vNormal = normalize(normal);\n}\n";
17
+ readonly fs: "uniform dirlightUniforms {\n vec3 lightDirection;\n} dirlight;\n\nin vec3 dirlight_vNormal;\n\n// Returns color attenuated by angle from light source\nvec4 dirlight_filterColor(vec4 color) {\n float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));\n return vec4(color.rgb * d, color.a);\n}\n";
16
18
  readonly uniformTypes: {
17
19
  readonly lightDirection: "vec3<f32>";
18
20
  };
19
21
  readonly defaultUniforms: {
20
22
  readonly lightDirection: Float32Array;
21
23
  };
22
- readonly props: Required<DirlightProps>;
23
- readonly uniforms: DirlightProps;
24
24
  readonly getUniforms: typeof getUniforms;
25
25
  };
26
26
  declare function getUniforms(opts?: DirlightProps): DirlightUniforms;
@@ -1 +1 @@
1
- {"version":3,"file":"dirlight.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/no-material/dirlight.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAIhD,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAG7C,eAAO,MAAM,OAAO,mGAInB,CAAC;AAGF,eAAO,MAAM,OAAO,4UAUnB,CAAC;AAwBF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;CAoB6C,CAAC;AAEnE,iBAAS,WAAW,CAAC,IAAI,GAAE,aAAwC,GAAG,gBAAgB,CAOrF"}
1
+ {"version":3,"file":"dirlight.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/no-material/dirlight.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAGhD,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAG7C,eAAO,MAAM,OAAO,mGAInB,CAAC;AAGF,eAAO,MAAM,OAAO,4UAUnB,CAAC;AAwBF;;GAEG;AACH,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;CAoBgC,CAAC;AAEnE,iBAAS,WAAW,CAAC,IAAI,GAAE,aAAwC,GAAG,gBAAgB,CAOrF"}