@luma.gl/engine 10.0.0-rc.1 → 10.0.0-rc.2

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 (437) hide show
  1. package/THIRD-PARTY-NOTICES.md +82 -0
  2. package/dist/animation/animation-track.d.ts +7 -0
  3. package/dist/animation/animation-track.d.ts.map +1 -1
  4. package/dist/animation/animation-track.js.map +1 -1
  5. package/dist/animation/node-animation-binding.cjs +1 -0
  6. package/dist/animation/node-animation-binding.d.ts +2 -1
  7. package/dist/animation/node-animation-binding.d.ts.map +1 -1
  8. package/dist/animation/node-animation-binding.js +6 -0
  9. package/dist/animation/node-animation-binding.js.map +1 -1
  10. package/dist/animation/scenegraph-gpu-animation-layout.cjs +99 -0
  11. package/dist/animation/scenegraph-gpu-animation-layout.d.ts +69 -0
  12. package/dist/animation/scenegraph-gpu-animation-layout.d.ts.map +1 -0
  13. package/dist/animation/scenegraph-gpu-animation-layout.js +90 -0
  14. package/dist/animation/scenegraph-gpu-animation-layout.js.map +1 -0
  15. package/dist/animation/scenegraph-gpu-animation.cjs +281 -0
  16. package/dist/animation/scenegraph-gpu-animation.d.ts +54 -0
  17. package/dist/animation/scenegraph-gpu-animation.d.ts.map +1 -0
  18. package/dist/animation/scenegraph-gpu-animation.js +274 -0
  19. package/dist/animation/scenegraph-gpu-animation.js.map +1 -0
  20. package/dist/arrow/arrow-picking.cjs +4 -3
  21. package/dist/arrow/arrow-picking.d.ts +15 -5
  22. package/dist/arrow/arrow-picking.d.ts.map +1 -1
  23. package/dist/arrow/arrow-picking.js +16 -5
  24. package/dist/arrow/arrow-picking.js.map +1 -1
  25. package/dist/arrow/index.cjs.map +1 -1
  26. package/dist/dist.dev.js +1671 -1105
  27. package/dist/dist.min.js +69 -70
  28. package/dist/effects/glfx-effects.cjs +261 -0
  29. package/dist/effects/glfx-effects.d.ts +959 -0
  30. package/dist/effects/glfx-effects.d.ts.map +1 -0
  31. package/dist/effects/glfx-effects.js +200 -0
  32. package/dist/effects/glfx-effects.js.map +1 -0
  33. package/dist/effects/graph/gpu-effect-operation.cjs +402 -0
  34. package/dist/effects/graph/gpu-effect-operation.d.ts +101 -0
  35. package/dist/effects/graph/gpu-effect-operation.d.ts.map +1 -0
  36. package/dist/effects/graph/gpu-effect-operation.js +410 -0
  37. package/dist/effects/graph/gpu-effect-operation.js.map +1 -0
  38. package/dist/effects/graph/temporal-graph-history.cjs +48 -0
  39. package/dist/effects/graph/temporal-graph-history.d.ts +17 -0
  40. package/dist/effects/graph/temporal-graph-history.d.ts.map +1 -0
  41. package/dist/effects/graph/temporal-graph-history.js +30 -0
  42. package/dist/effects/graph/temporal-graph-history.js.map +1 -0
  43. package/dist/effects/index.cjs +117 -30
  44. package/dist/effects/index.cjs.map +3 -3
  45. package/dist/effects/index.d.ts +34 -18
  46. package/dist/effects/index.d.ts.map +1 -1
  47. package/dist/effects/index.js +31 -18
  48. package/dist/effects/index.js.map +1 -1
  49. package/dist/effects/passes/postprocessing/fxaa/fxaa.cjs +9 -2
  50. package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts +19 -0
  51. package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  52. package/dist/effects/passes/postprocessing/fxaa/fxaa.js +6 -0
  53. package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
  54. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.cjs +9 -2
  55. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts +41 -0
  56. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts.map +1 -1
  57. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js +6 -0
  58. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js.map +1 -1
  59. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.cjs +200 -13
  60. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts +992 -6
  61. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts.map +1 -1
  62. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js +199 -10
  63. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js.map +1 -1
  64. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts +3 -3
  65. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts.map +1 -1
  66. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.js.map +1 -1
  67. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.cjs +41 -40
  68. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts +116 -8
  69. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts.map +1 -1
  70. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js +38 -37
  71. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js.map +1 -1
  72. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.cjs +83 -66
  73. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +470 -2
  74. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
  75. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js +80 -62
  76. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js.map +1 -1
  77. package/dist/effects/passes/screen-space/copy-pass.cjs +7 -0
  78. package/dist/effects/passes/screen-space/copy-pass.d.ts +1 -0
  79. package/dist/effects/passes/screen-space/copy-pass.d.ts.map +1 -1
  80. package/dist/effects/passes/screen-space/copy-pass.js +4 -0
  81. package/dist/effects/passes/screen-space/copy-pass.js.map +1 -1
  82. package/dist/effects/passes/screen-space/depth-aware-blur.cjs +14 -5
  83. package/dist/effects/passes/screen-space/depth-aware-blur.d.ts +125 -17
  84. package/dist/effects/passes/screen-space/depth-aware-blur.d.ts.map +1 -1
  85. package/dist/effects/passes/screen-space/depth-aware-blur.js +11 -3
  86. package/dist/effects/passes/screen-space/depth-aware-blur.js.map +1 -1
  87. package/dist/effects/passes/screen-space/dof.cjs +19 -3
  88. package/dist/effects/passes/screen-space/dof.d.ts +181 -0
  89. package/dist/effects/passes/screen-space/dof.d.ts.map +1 -1
  90. package/dist/effects/passes/screen-space/dof.js +17 -3
  91. package/dist/effects/passes/screen-space/dof.js.map +1 -1
  92. package/dist/effects/passes/screen-space/gtao.cjs +82 -62
  93. package/dist/effects/passes/screen-space/gtao.d.ts +608 -3
  94. package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
  95. package/dist/effects/passes/screen-space/gtao.js +83 -60
  96. package/dist/effects/passes/screen-space/gtao.js.map +1 -1
  97. package/dist/effects/passes/screen-space/hdr-auto-exposure.cjs +103 -79
  98. package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts +225 -3
  99. package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts.map +1 -1
  100. package/dist/effects/passes/screen-space/hdr-auto-exposure.js +102 -77
  101. package/dist/effects/passes/screen-space/hdr-auto-exposure.js.map +1 -1
  102. package/dist/effects/passes/screen-space/height-fog.cjs +14 -0
  103. package/dist/effects/passes/screen-space/height-fog.d.ts +71 -0
  104. package/dist/effects/passes/screen-space/height-fog.d.ts.map +1 -1
  105. package/dist/effects/passes/screen-space/height-fog.js +16 -3
  106. package/dist/effects/passes/screen-space/height-fog.js.map +1 -1
  107. package/dist/effects/passes/screen-space/motion-blur.cjs +7 -8
  108. package/dist/effects/passes/screen-space/motion-blur.d.ts +41 -2
  109. package/dist/effects/passes/screen-space/motion-blur.d.ts.map +1 -1
  110. package/dist/effects/passes/screen-space/motion-blur.js +6 -6
  111. package/dist/effects/passes/screen-space/motion-blur.js.map +1 -1
  112. package/dist/effects/passes/screen-space/outlines.cjs +143 -18
  113. package/dist/effects/passes/screen-space/outlines.d.ts +162 -3
  114. package/dist/effects/passes/screen-space/outlines.d.ts.map +1 -1
  115. package/dist/effects/passes/screen-space/outlines.js +137 -15
  116. package/dist/effects/passes/screen-space/outlines.js.map +1 -1
  117. package/dist/effects/passes/screen-space/screen-space-global-illumination.cjs +70 -61
  118. package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +309 -2
  119. package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts.map +1 -1
  120. package/dist/effects/passes/screen-space/screen-space-global-illumination.js +69 -59
  121. package/dist/effects/passes/screen-space/screen-space-global-illumination.js.map +1 -1
  122. package/dist/effects/passes/screen-space/screen-space-reflections.cjs +151 -83
  123. package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +778 -7
  124. package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
  125. package/dist/effects/passes/screen-space/screen-space-reflections.js +148 -79
  126. package/dist/effects/passes/screen-space/screen-space-reflections.js.map +1 -1
  127. package/dist/effects/passes/screen-space/selection-outline.cjs +12 -2
  128. package/dist/effects/passes/screen-space/selection-outline.d.ts +44 -0
  129. package/dist/effects/passes/screen-space/selection-outline.d.ts.map +1 -1
  130. package/dist/effects/passes/screen-space/selection-outline.js +9 -0
  131. package/dist/effects/passes/screen-space/selection-outline.js.map +1 -1
  132. package/dist/effects/passes/screen-space/ssao.cjs +66 -43
  133. package/dist/effects/passes/screen-space/ssao.d.ts +647 -2
  134. package/dist/effects/passes/screen-space/ssao.d.ts.map +1 -1
  135. package/dist/effects/passes/screen-space/ssao.js +64 -41
  136. package/dist/effects/passes/screen-space/ssao.js.map +1 -1
  137. package/dist/effects/passes/screen-space/temporal-antialiasing.cjs +42 -30
  138. package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts +107 -6
  139. package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts.map +1 -1
  140. package/dist/effects/passes/screen-space/temporal-antialiasing.js +40 -27
  141. package/dist/effects/passes/screen-space/temporal-antialiasing.js.map +1 -1
  142. package/dist/effects/passes/screen-space/temporal-frame.cjs +34 -0
  143. package/dist/effects/passes/screen-space/temporal-frame.d.ts +23 -0
  144. package/dist/effects/passes/screen-space/temporal-frame.d.ts.map +1 -0
  145. package/dist/effects/passes/screen-space/temporal-frame.js +16 -0
  146. package/dist/effects/passes/screen-space/temporal-frame.js.map +1 -0
  147. package/dist/effects/passes/screen-space/volumetric-fog.cjs +25 -22
  148. package/dist/effects/passes/screen-space/volumetric-fog.d.ts +161 -2
  149. package/dist/effects/passes/screen-space/volumetric-fog.d.ts.map +1 -1
  150. package/dist/effects/passes/screen-space/volumetric-fog.js +27 -21
  151. package/dist/effects/passes/screen-space/volumetric-fog.js.map +1 -1
  152. package/dist/effects/temporal-upscale/index.cjs +40 -0
  153. package/dist/effects/temporal-upscale/index.d.ts +5 -0
  154. package/dist/effects/temporal-upscale/index.d.ts.map +1 -0
  155. package/dist/effects/temporal-upscale/index.js +6 -0
  156. package/dist/effects/temporal-upscale/index.js.map +1 -0
  157. package/dist/effects/temporal-upscale/temporal-math.cjs +202 -0
  158. package/dist/effects/temporal-upscale/temporal-math.d.ts +101 -0
  159. package/dist/effects/temporal-upscale/temporal-math.d.ts.map +1 -0
  160. package/dist/effects/temporal-upscale/temporal-math.js +202 -0
  161. package/dist/effects/temporal-upscale/temporal-math.js.map +1 -0
  162. package/dist/effects/temporal-upscale/temporal-upscale-shaders.cjs +353 -0
  163. package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts +7 -0
  164. package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts.map +1 -0
  165. package/dist/effects/temporal-upscale/temporal-upscale-shaders.js +321 -0
  166. package/dist/effects/temporal-upscale/temporal-upscale-shaders.js.map +1 -0
  167. package/dist/effects/temporal-upscale/temporal-upscaler.cjs +392 -0
  168. package/dist/effects/temporal-upscale/temporal-upscaler.d.ts +143 -0
  169. package/dist/effects/temporal-upscale/temporal-upscaler.d.ts.map +1 -0
  170. package/dist/effects/temporal-upscale/temporal-upscaler.js +385 -0
  171. package/dist/effects/temporal-upscale/temporal-upscaler.js.map +1 -0
  172. package/dist/gltf/gltf/create-gltf-model.cjs +34 -71
  173. package/dist/gltf/gltf/create-gltf-model.d.ts +3 -0
  174. package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
  175. package/dist/gltf/gltf/create-gltf-model.js +40 -74
  176. package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
  177. package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +46 -4
  178. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +9 -1
  179. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
  180. package/dist/gltf/gltf/create-scenegraph-from-gltf.js +54 -4
  181. package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
  182. package/dist/gltf/gltf/gltf-animated-crowd.cjs +25 -136
  183. package/dist/gltf/gltf/gltf-animated-crowd.d.ts +4 -8
  184. package/dist/gltf/gltf/gltf-animated-crowd.d.ts.map +1 -1
  185. package/dist/gltf/gltf/gltf-animated-crowd.js +27 -139
  186. package/dist/gltf/gltf/gltf-animated-crowd.js.map +1 -1
  187. package/dist/gltf/gltf/gltf-animation-nodes.cjs +84 -0
  188. package/dist/gltf/gltf/gltf-animation-nodes.d.ts +11 -0
  189. package/dist/gltf/gltf/gltf-animation-nodes.d.ts.map +1 -0
  190. package/dist/gltf/gltf/gltf-animation-nodes.js +62 -0
  191. package/dist/gltf/gltf/gltf-animation-nodes.js.map +1 -0
  192. package/dist/gltf/gltf/gltf-animator.cjs +8 -2
  193. package/dist/gltf/gltf/gltf-animator.d.ts +6 -1
  194. package/dist/gltf/gltf/gltf-animator.d.ts.map +1 -1
  195. package/dist/gltf/gltf/gltf-animator.js +10 -2
  196. package/dist/gltf/gltf/gltf-animator.js.map +1 -1
  197. package/dist/gltf/gltf/gltf-gpu-animation-controller.cjs +81 -0
  198. package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts +9 -0
  199. package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts.map +1 -0
  200. package/dist/gltf/gltf/gltf-gpu-animation-controller.js +67 -0
  201. package/dist/gltf/gltf/gltf-gpu-animation-controller.js.map +1 -0
  202. package/dist/gltf/gltf/gltf-gpu-animation.cjs +33 -28
  203. package/dist/gltf/gltf/gltf-gpu-animation.d.ts +7 -26
  204. package/dist/gltf/gltf/gltf-gpu-animation.d.ts.map +1 -1
  205. package/dist/gltf/gltf/gltf-gpu-animation.js +29 -28
  206. package/dist/gltf/gltf/gltf-gpu-animation.js.map +1 -1
  207. package/dist/gltf/index.cjs.map +3 -3
  208. package/dist/gltf/index.d.ts +2 -2
  209. package/dist/gltf/index.d.ts.map +1 -1
  210. package/dist/gltf/index.js.map +1 -1
  211. package/dist/gltf/parsers/parse-gltf.cjs +4 -2
  212. package/dist/gltf/parsers/parse-gltf.d.ts +3 -0
  213. package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
  214. package/dist/gltf/parsers/parse-gltf.js +7 -2
  215. package/dist/gltf/parsers/parse-gltf.js.map +1 -1
  216. package/dist/graph/models/index.cjs.map +2 -2
  217. package/dist/graph/physics/index.cjs +5 -0
  218. package/dist/graph/physics/index.cjs.map +3 -3
  219. package/dist/graph/physics/index.d.ts +1 -0
  220. package/dist/graph/physics/index.d.ts.map +1 -1
  221. package/dist/graph/physics/index.js +1 -0
  222. package/dist/graph/physics/index.js.map +1 -1
  223. package/dist/graph/physics/physics-controller-geometry.cjs +21 -0
  224. package/dist/graph/physics/physics-controller-geometry.d.ts +8 -1
  225. package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -1
  226. package/dist/graph/physics/physics-controller-geometry.js +22 -0
  227. package/dist/graph/physics/physics-controller-geometry.js.map +1 -1
  228. package/dist/graph/physics/scenegraph-session.d.ts +1 -1
  229. package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
  230. package/dist/graph/tables/index.cjs.map +2 -2
  231. package/dist/index.cjs +16 -0
  232. package/dist/index.cjs.map +3 -3
  233. package/dist/index.d.ts +6 -0
  234. package/dist/index.d.ts.map +1 -1
  235. package/dist/index.js +4 -0
  236. package/dist/index.js.map +1 -1
  237. package/dist/lighting/ambient-occlusion-pass.cjs +47 -28
  238. package/dist/lighting/ambient-occlusion-pass.d.ts +12 -0
  239. package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -1
  240. package/dist/lighting/ambient-occlusion-pass.js +45 -26
  241. package/dist/lighting/ambient-occlusion-pass.js.map +1 -1
  242. package/dist/lighting/clustered-light-grid.cjs +71 -20
  243. package/dist/lighting/clustered-light-grid.d.ts +37 -0
  244. package/dist/lighting/clustered-light-grid.d.ts.map +1 -1
  245. package/dist/lighting/clustered-light-grid.js +68 -18
  246. package/dist/lighting/clustered-light-grid.js.map +1 -1
  247. package/dist/lighting/contact-shadow-composite.cjs +72 -51
  248. package/dist/lighting/contact-shadow-composite.d.ts +274 -3
  249. package/dist/lighting/contact-shadow-composite.d.ts.map +1 -1
  250. package/dist/lighting/contact-shadow-composite.js +72 -50
  251. package/dist/lighting/contact-shadow-composite.js.map +1 -1
  252. package/dist/lighting/contact-shadow-pass.cjs +50 -39
  253. package/dist/lighting/contact-shadow-pass.d.ts +8 -0
  254. package/dist/lighting/contact-shadow-pass.d.ts.map +1 -1
  255. package/dist/lighting/contact-shadow-pass.js +47 -37
  256. package/dist/lighting/contact-shadow-pass.js.map +1 -1
  257. package/dist/lighting/cortao/cortao-occluder-lookup-table.cjs +96 -0
  258. package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts +41 -0
  259. package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts.map +1 -0
  260. package/dist/lighting/cortao/cortao-occluder-lookup-table.js +94 -0
  261. package/dist/lighting/cortao/cortao-occluder-lookup-table.js.map +1 -0
  262. package/dist/lighting/cortao/cortao-parameters.cjs +127 -0
  263. package/dist/lighting/cortao/cortao-parameters.d.ts +95 -0
  264. package/dist/lighting/cortao/cortao-parameters.d.ts.map +1 -0
  265. package/dist/lighting/cortao/cortao-parameters.js +122 -0
  266. package/dist/lighting/cortao/cortao-parameters.js.map +1 -0
  267. package/dist/lighting/cortao/cortao-pass.cjs +100 -0
  268. package/dist/lighting/cortao/cortao-pass.d.ts +33 -0
  269. package/dist/lighting/cortao/cortao-pass.d.ts.map +1 -0
  270. package/dist/lighting/cortao/cortao-pass.js +84 -0
  271. package/dist/lighting/cortao/cortao-pass.js.map +1 -0
  272. package/dist/lighting/cortao/cortao-passes.cjs +42 -0
  273. package/dist/lighting/cortao/cortao-passes.d.ts +38 -0
  274. package/dist/lighting/cortao/cortao-passes.d.ts.map +1 -0
  275. package/dist/lighting/cortao/cortao-passes.js +19 -0
  276. package/dist/lighting/cortao/cortao-passes.js.map +1 -0
  277. package/dist/lighting/cortao/cortao-shaders-wgsl.cjs +606 -0
  278. package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts +49 -0
  279. package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts.map +1 -0
  280. package/dist/lighting/cortao/cortao-shaders-wgsl.js +610 -0
  281. package/dist/lighting/cortao/cortao-shaders-wgsl.js.map +1 -0
  282. package/dist/lighting/cortao/cortao-shaders.cjs +667 -0
  283. package/dist/lighting/cortao/cortao-shaders.d.ts +118 -0
  284. package/dist/lighting/cortao/cortao-shaders.d.ts.map +1 -0
  285. package/dist/lighting/cortao/cortao-shaders.js +657 -0
  286. package/dist/lighting/cortao/cortao-shaders.js.map +1 -0
  287. package/dist/lighting/cortao/cortao-upsample.cjs +191 -0
  288. package/dist/lighting/cortao/cortao-upsample.d.ts +16 -0
  289. package/dist/lighting/cortao/cortao-upsample.d.ts.map +1 -0
  290. package/dist/lighting/cortao/cortao-upsample.js +159 -0
  291. package/dist/lighting/cortao/cortao-upsample.js.map +1 -0
  292. package/dist/lighting/cortao/cortao-webgl-passes.cjs +229 -0
  293. package/dist/lighting/cortao/cortao-webgl-passes.d.ts +28 -0
  294. package/dist/lighting/cortao/cortao-webgl-passes.d.ts.map +1 -0
  295. package/dist/lighting/cortao/cortao-webgl-passes.js +212 -0
  296. package/dist/lighting/cortao/cortao-webgl-passes.js.map +1 -0
  297. package/dist/lighting/cortao/cortao-webgpu-passes.cjs +348 -0
  298. package/dist/lighting/cortao/cortao-webgpu-passes.d.ts +31 -0
  299. package/dist/lighting/cortao/cortao-webgpu-passes.d.ts.map +1 -0
  300. package/dist/lighting/cortao/cortao-webgpu-passes.js +335 -0
  301. package/dist/lighting/cortao/cortao-webgpu-passes.js.map +1 -0
  302. package/dist/lighting/index.cjs +13 -2
  303. package/dist/lighting/index.cjs.map +3 -3
  304. package/dist/lighting/index.d.ts +11 -6
  305. package/dist/lighting/index.d.ts.map +1 -1
  306. package/dist/lighting/index.js +6 -5
  307. package/dist/lighting/index.js.map +1 -1
  308. package/dist/lighting/shadow-map-renderer.cjs +40 -37
  309. package/dist/lighting/shadow-map-renderer.d.ts +15 -0
  310. package/dist/lighting/shadow-map-renderer.d.ts.map +1 -1
  311. package/dist/lighting/shadow-map-renderer.js +37 -35
  312. package/dist/lighting/shadow-map-renderer.js.map +1 -1
  313. package/dist/model/gpu-vector-model.cjs +39 -16
  314. package/dist/model/gpu-vector-model.d.ts +8 -0
  315. package/dist/model/gpu-vector-model.d.ts.map +1 -1
  316. package/dist/model/gpu-vector-model.js +46 -18
  317. package/dist/model/gpu-vector-model.js.map +1 -1
  318. package/dist/passes/effect-renderer.cjs +155 -0
  319. package/dist/passes/effect-renderer.d.ts +158 -0
  320. package/dist/passes/effect-renderer.d.ts.map +1 -0
  321. package/dist/passes/effect-renderer.js +143 -0
  322. package/dist/passes/effect-renderer.js.map +1 -0
  323. package/dist/passes/scene-capture-pass.cjs +42 -0
  324. package/dist/passes/scene-capture-pass.d.ts +29 -0
  325. package/dist/passes/scene-capture-pass.d.ts.map +1 -0
  326. package/dist/passes/scene-capture-pass.js +21 -0
  327. package/dist/passes/scene-capture-pass.js.map +1 -0
  328. package/dist/passes/shader-pass-renderer.cjs +94 -68
  329. package/dist/passes/shader-pass-renderer.d.ts +32 -15
  330. package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
  331. package/dist/passes/shader-pass-renderer.js +104 -76
  332. package/dist/passes/shader-pass-renderer.js.map +1 -1
  333. package/dist/scenegraph/model-node.cjs +2 -0
  334. package/dist/scenegraph/model-node.d.ts +4 -0
  335. package/dist/scenegraph/model-node.d.ts.map +1 -1
  336. package/dist/scenegraph/model-node.js +2 -0
  337. package/dist/scenegraph/model-node.js.map +1 -1
  338. package/dist/splats/gpu-paged-splat-renderer.cjs +52 -8
  339. package/dist/splats/gpu-paged-splat-renderer.d.ts +16 -3
  340. package/dist/splats/gpu-paged-splat-renderer.d.ts.map +1 -1
  341. package/dist/splats/gpu-paged-splat-renderer.js +55 -9
  342. package/dist/splats/gpu-paged-splat-renderer.js.map +1 -1
  343. package/dist/splats/gpu-paged-splat-shaders.cjs +3 -1
  344. package/dist/splats/gpu-paged-splat-shaders.d.ts.map +1 -1
  345. package/dist/splats/gpu-paged-splat-shaders.js +3 -1
  346. package/dist/splats/gpu-paged-splat-shaders.js.map +1 -1
  347. package/dist/splats/index.cjs.map +2 -2
  348. package/dist/text/fonts/atlas/browser-font-atlas.cjs +10 -1
  349. package/dist/text/fonts/atlas/browser-font-atlas.d.ts +3 -1
  350. package/dist/text/fonts/atlas/browser-font-atlas.d.ts.map +1 -1
  351. package/dist/text/fonts/atlas/browser-font-atlas.js +10 -2
  352. package/dist/text/fonts/atlas/browser-font-atlas.js.map +1 -1
  353. package/dist/text/fonts/atlas/lru-cache.cjs +4 -0
  354. package/dist/text/fonts/atlas/lru-cache.d.ts +3 -1
  355. package/dist/text/fonts/atlas/lru-cache.d.ts.map +1 -1
  356. package/dist/text/fonts/atlas/lru-cache.js +4 -0
  357. package/dist/text/fonts/atlas/lru-cache.js.map +1 -1
  358. package/dist/text/fonts/index.cjs +2 -0
  359. package/dist/text/fonts/index.cjs.map +1 -1
  360. package/dist/text/fonts/index.d.ts +1 -1
  361. package/dist/text/fonts/index.d.ts.map +1 -1
  362. package/dist/text/fonts/index.js +1 -1
  363. package/dist/text/fonts/index.js.map +1 -1
  364. package/dist/text/index.cjs.map +1 -1
  365. package/package.json +8 -8
  366. package/src/animation/animation-track.ts +5 -0
  367. package/src/animation/node-animation-binding.ts +9 -8
  368. package/src/animation/scenegraph-gpu-animation-layout.ts +195 -0
  369. package/src/animation/scenegraph-gpu-animation.ts +340 -0
  370. package/src/arrow/arrow-picking.ts +23 -11
  371. package/src/effects/README.md +38 -14
  372. package/src/effects/glfx-effects.ts +227 -0
  373. package/src/effects/graph/gpu-effect-operation.ts +601 -0
  374. package/src/effects/graph/temporal-graph-history.ts +46 -0
  375. package/src/effects/index.ts +81 -19
  376. package/src/effects/passes/postprocessing/fxaa/fxaa.ts +8 -0
  377. package/src/effects/passes/postprocessing/image-adjust-filters/tone-mapping.ts +8 -0
  378. package/src/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.ts +219 -19
  379. package/src/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.ts +6 -6
  380. package/src/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +45 -45
  381. package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +88 -68
  382. package/src/effects/passes/screen-space/copy-pass.ts +4 -0
  383. package/src/effects/passes/screen-space/depth-aware-blur.ts +13 -3
  384. package/src/effects/passes/screen-space/dof.ts +20 -3
  385. package/src/effects/passes/screen-space/gtao.ts +91 -65
  386. package/src/effects/passes/screen-space/hdr-auto-exposure.ts +109 -84
  387. package/src/effects/passes/screen-space/height-fog.ts +18 -3
  388. package/src/effects/passes/screen-space/motion-blur.ts +8 -7
  389. package/src/effects/passes/screen-space/outlines.ts +143 -17
  390. package/src/effects/passes/screen-space/screen-space-global-illumination.ts +75 -64
  391. package/src/effects/passes/screen-space/screen-space-reflections.ts +158 -95
  392. package/src/effects/passes/screen-space/selection-outline.ts +11 -0
  393. package/src/effects/passes/screen-space/ssao.ts +76 -45
  394. package/src/effects/passes/screen-space/temporal-antialiasing.ts +43 -33
  395. package/src/effects/passes/screen-space/temporal-frame.ts +33 -0
  396. package/src/effects/passes/screen-space/volumetric-fog.ts +30 -24
  397. package/src/effects/temporal-upscale/index.ts +20 -0
  398. package/src/effects/temporal-upscale/temporal-math.ts +308 -0
  399. package/src/effects/temporal-upscale/temporal-upscale-shaders.ts +326 -0
  400. package/src/effects/temporal-upscale/temporal-upscaler.ts +538 -0
  401. package/src/gltf/gltf/create-gltf-model.ts +59 -90
  402. package/src/gltf/gltf/create-scenegraph-from-gltf.ts +71 -5
  403. package/src/gltf/gltf/gltf-animated-crowd.ts +30 -177
  404. package/src/gltf/gltf/gltf-animation-nodes.ts +82 -0
  405. package/src/gltf/gltf/gltf-animator.ts +15 -4
  406. package/src/gltf/gltf/gltf-gpu-animation-controller.ts +88 -0
  407. package/src/gltf/gltf/gltf-gpu-animation.ts +53 -60
  408. package/src/gltf/index.ts +5 -0
  409. package/src/gltf/parsers/parse-gltf.ts +12 -2
  410. package/src/graph/physics/index.ts +4 -0
  411. package/src/graph/physics/physics-controller-geometry.ts +33 -1
  412. package/src/index.ts +25 -0
  413. package/src/lighting/ambient-occlusion-pass.ts +62 -28
  414. package/src/lighting/clustered-light-grid.ts +87 -30
  415. package/src/lighting/contact-shadow-composite.ts +80 -52
  416. package/src/lighting/contact-shadow-pass.ts +59 -39
  417. package/src/lighting/cortao/cortao-occluder-lookup-table.ts +138 -0
  418. package/src/lighting/cortao/cortao-parameters.ts +218 -0
  419. package/src/lighting/cortao/cortao-pass.ts +136 -0
  420. package/src/lighting/cortao/cortao-passes.ts +50 -0
  421. package/src/lighting/cortao/cortao-shaders-wgsl.ts +633 -0
  422. package/src/lighting/cortao/cortao-shaders.ts +674 -0
  423. package/src/lighting/cortao/cortao-upsample.ts +177 -0
  424. package/src/lighting/cortao/cortao-webgl-passes.ts +284 -0
  425. package/src/lighting/cortao/cortao-webgpu-passes.ts +430 -0
  426. package/src/lighting/index.ts +12 -3
  427. package/src/lighting/shadow-map-renderer.ts +57 -43
  428. package/src/model/gpu-vector-model.ts +47 -18
  429. package/src/passes/effect-renderer.ts +332 -0
  430. package/src/passes/scene-capture-pass.ts +51 -0
  431. package/src/passes/shader-pass-renderer.ts +164 -115
  432. package/src/scenegraph/model-node.ts +5 -0
  433. package/src/splats/gpu-paged-splat-renderer.ts +77 -9
  434. package/src/splats/gpu-paged-splat-shaders.ts +7 -1
  435. package/src/text/fonts/atlas/browser-font-atlas.ts +12 -2
  436. package/src/text/fonts/atlas/lru-cache.ts +6 -1
  437. package/src/text/fonts/index.ts +1 -0
@@ -0,0 +1,633 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ // The CORTAO functions in this file are adapted from src/shaders/*.h of the CORTAO reference
5
+ // implementation (https://github.com/theagentd/CORTAO).
6
+ // SPDX-FileCopyrightText: Copyright (c) 2026 Daniel Isheden
7
+ // See THIRD-PARTY-NOTICES.md in this module.
8
+
9
+ import {CORTAO_PACKED_NORMAL_BITS} from './cortao-shaders';
10
+
11
+ /**
12
+ * The WGSL passes of CORTAO for WebGPU.
13
+ *
14
+ * All passes are compute passes with 8 x 8 workgroups. The prepass, the
15
+ * mip pass and the main pass work in "GL pixel coordinates", with the origin at the bottom left,
16
+ * as in the GLSL port. They flip the row only when they read or write a texel. So the noise,
17
+ * the mip child choice and the sample positions are the same as in the GLSL port. The filter pass
18
+ * works in texel coordinates, as the reference does: its math does not depend on the direction
19
+ * of the rows.
20
+ */
21
+
22
+ /** The workgroup size of the compute passes, in both dimensions. */
23
+ export const CORTAO_WORKGROUP_SIZE = 8;
24
+
25
+ /** Shared WGSL code of the compute passes. */
26
+ const CORTAO_BASE_WGSL = /* wgsl */ `\
27
+ const CORTAO_PI2: f32 = 6.283185307179586;
28
+ const CORTAO_GOLDEN_ANGLE: f32 = 2.3999632297286535;
29
+ const CORTAO_PACKED_NORMAL_BITS: u32 = ${CORTAO_PACKED_NORMAL_BITS}u;
30
+
31
+ fn cortao_seed(coords: vec2u) -> u32 {
32
+ // 1719413 * 929 and 140473 * 2467 * 11.
33
+ let q = coords * vec2u(1597334677u, 3812015801u);
34
+ return q.x ^ q.y;
35
+ }
36
+
37
+ fn cortao_hash(n: u32) -> u32 {
38
+ return n * (n ^ (n >> 15u));
39
+ }
40
+
41
+ fn cortao_hash2(n: vec2u) -> vec2u {
42
+ return n * (n ^ (n >> vec2u(15u)));
43
+ }
44
+
45
+ fn cortao_unpack16(x: u32) -> vec2u {
46
+ return vec2u(x & 0xFFFFu, x >> 16u);
47
+ }
48
+
49
+ fn cortao_encodeNormal(normal: vec3f, dither: vec2f) -> u32 {
50
+ let bitsPerComponent = CORTAO_PACKED_NORMAL_BITS / 2u;
51
+ let componentMask = (1u << bitsPerComponent) - 1u;
52
+ let componentMax = componentMask >> 1u;
53
+ let encodedNormal = normal.xy * inverseSqrt(normal.z * 2.0 + 2.0);
54
+ let values = vec2i(floor(encodedNormal * f32(componentMax) + dither));
55
+ return (bitcast<u32>(values.x) & componentMask) |
56
+ ((bitcast<u32>(values.y) & componentMask) << bitsPerComponent);
57
+ }
58
+
59
+ fn cortao_decodeNormal(packedData: u32) -> vec3f {
60
+ let bitsPerComponent = CORTAO_PACKED_NORMAL_BITS / 2u;
61
+ let componentMax = i32(((1u << bitsPerComponent) - 1u) >> 1u);
62
+ let leftShift = vec2u(32u - bitsPerComponent, 32u - bitsPerComponent * 2u);
63
+ let values = (vec2i(bitcast<i32>(packedData)) << leftShift) >> vec2u(32u - bitsPerComponent);
64
+ let e = vec2f(values) * (1.0 / f32(componentMax));
65
+ let z = max(1.0 - e.x * e.x - e.y * e.y, 0.0);
66
+ return vec3f(e * (2.0 * sqrt(z)), z * 2.0 - 1.0);
67
+ }
68
+
69
+ fn cortao_unpackDepth(packedData: u32) -> f32 {
70
+ return bitcast<f32>(packedData);
71
+ }
72
+
73
+ fn cortao_unprojectWithOffset(
74
+ unprojectParameters: vec4f, texCoords: vec2f, linearDepth: f32, offset: vec3f
75
+ ) -> vec3f {
76
+ let direction = texCoords * unprojectParameters.xy + unprojectParameters.zw;
77
+ return vec3f(direction, -1.0) * linearDepth + offset;
78
+ }
79
+
80
+ fn cortao_unproject(unprojectParameters: vec4f, texCoords: vec2f, linearDepth: f32) -> vec3f {
81
+ return cortao_unprojectWithOffset(unprojectParameters, texCoords, linearDepth, vec3f(0.0));
82
+ }
83
+
84
+ // Converts between GL pixel coordinates (origin at the bottom left) and texel coordinates.
85
+ fn cortao_flipRow(coords: vec2i, size: vec2i) -> vec2i {
86
+ return vec2i(coords.x, size.y - 1 - coords.y);
87
+ }
88
+ `;
89
+
90
+ /**
91
+ * Prepass. Port of `cortao_prepass()` for level 0 only, with normals from depth, as in the GLSL
92
+ * port. Bindings: 0 uniforms, 1 hardware depth, 2 packed level 0 (storage), 3 normal (storage).
93
+ */
94
+ export function getCORTAOPrepassWGSL(scaled: boolean): string {
95
+ return /* wgsl */ `\
96
+ ${CORTAO_BASE_WGSL}
97
+ struct CORTAOPrepassUniforms {
98
+ unprojectParams: vec4f,
99
+ resolution: vec2f,
100
+ depthScale: f32,
101
+ depthOffset: f32,
102
+ randomSeed: u32,
103
+ };
104
+
105
+ @group(0) @binding(0) var<uniform> cortaoPrepass: CORTAOPrepassUniforms;
106
+ @group(0) @binding(1) var depthTexture: texture_depth_2d;
107
+ @group(0) @binding(2) var packedOutput: texture_storage_2d<r32uint, write>;
108
+ @group(0) @binding(3) var normalOutput: texture_storage_2d<rgba8unorm, write>;
109
+
110
+ struct CORTAOPosition {
111
+ valid: bool,
112
+ position: vec3f,
113
+ };
114
+
115
+ fn cortao_skyDepth() -> f32 {
116
+ // Handles both standard and reverse depth.
117
+ return select(0.0, 1.0, cortaoPrepass.depthScale < 0.0);
118
+ }
119
+
120
+ fn cortao_loadPosition(pixel: vec2i) -> CORTAOPosition {
121
+ let size = vec2i(cortaoPrepass.resolution);
122
+ if (any(pixel < vec2i(0)) || any(pixel >= size)) {
123
+ return CORTAOPosition(false, vec3f(0.0));
124
+ }
125
+ ${
126
+ scaled
127
+ ? `let depthSize = vec2i(textureDimensions(depthTexture));
128
+ let sampleScale = vec2f(depthSize) / vec2f(size);
129
+ let depthPixel = vec2i((vec2f(cortao_flipRow(pixel, size)) + 0.5) * sampleScale);
130
+ let texCoords = (vec2f(cortao_flipRow(depthPixel, depthSize)) + 0.5) / vec2f(depthSize);`
131
+ : `let depthPixel = cortao_flipRow(pixel, size);
132
+ let texCoords = (vec2f(pixel) + 0.5) / cortaoPrepass.resolution;`
133
+ }
134
+ let depth = textureLoad(depthTexture, depthPixel, 0);
135
+ if (depth == cortao_skyDepth()) {
136
+ return CORTAOPosition(false, vec3f(0.0));
137
+ }
138
+ let linearDepth = 1.0 / (depth * cortaoPrepass.depthScale + cortaoPrepass.depthOffset);
139
+ return CORTAOPosition(true, cortao_unproject(cortaoPrepass.unprojectParams, texCoords, linearDepth));
140
+ }
141
+
142
+ // Picks the neighbor difference along one axis with the smaller depth step. This keeps the
143
+ // normal of a surface intact at the silhouette of a nearer or farther surface.
144
+ fn cortao_getTangent(pixel: vec2i, axis: vec2i, position: vec3f) -> CORTAOPosition {
145
+ let forwardSample = cortao_loadPosition(pixel + axis);
146
+ let backwardSample = cortao_loadPosition(pixel - axis);
147
+ let forward = forwardSample.position - position;
148
+ let backward = position - backwardSample.position;
149
+ if (forwardSample.valid && backwardSample.valid) {
150
+ return CORTAOPosition(true, select(backward, forward, abs(forward.z) < abs(backward.z)));
151
+ }
152
+ if (forwardSample.valid) {
153
+ return CORTAOPosition(true, forward);
154
+ }
155
+ if (backwardSample.valid) {
156
+ return CORTAOPosition(true, backward);
157
+ }
158
+ return CORTAOPosition(false, vec3f(0.0));
159
+ }
160
+
161
+ @compute @workgroup_size(${CORTAO_WORKGROUP_SIZE}, ${CORTAO_WORKGROUP_SIZE})
162
+ fn main(@builtin(global_invocation_id) id: vec3u) {
163
+ let size = vec2i(cortaoPrepass.resolution);
164
+ let texel = vec2i(id.xy);
165
+ if (any(texel >= size)) {
166
+ return;
167
+ }
168
+ let pixel = cortao_flipRow(texel, size);
169
+ let center = cortao_loadPosition(pixel);
170
+ if (!center.valid) {
171
+ textureStore(packedOutput, texel, vec4u(0u));
172
+ textureStore(normalOutput, texel, vec4f(0.5, 0.5, 1.0, 1.0));
173
+ return;
174
+ }
175
+ let position = center.position;
176
+ let linearDepth = -position.z;
177
+
178
+ var normal = normalize(-position);
179
+ let tangentX = cortao_getTangent(pixel, vec2i(1, 0), position);
180
+ let tangentY = cortao_getTangent(pixel, vec2i(0, 1), position);
181
+ if (tangentX.valid && tangentY.valid) {
182
+ let crossProduct = cross(tangentX.position, tangentY.position);
183
+ if (dot(crossProduct, crossProduct) > 0.0) {
184
+ normal = normalize(crossProduct);
185
+ }
186
+ }
187
+ // A visible surface faces the camera.
188
+ if (dot(normal, position) > 0.0) {
189
+ normal = -normal;
190
+ }
191
+
192
+ // Pack a sphere-map encoded normal into the low bits of the linear depth.
193
+ let seed = cortao_hash(cortao_seed(vec2u(pixel)) + cortaoPrepass.randomSeed);
194
+ let dither = vec2f(cortao_unpack16(seed)) * (1.0 / 65535.0);
195
+ let mask = (1u << CORTAO_PACKED_NORMAL_BITS) - 1u;
196
+ let packedNormal = cortao_encodeNormal(normal, dither);
197
+ let packedData = (bitcast<u32>(linearDepth) & ~mask) | (packedNormal & mask);
198
+ textureStore(packedOutput, texel, vec4u(packedData, 0u, 0u, 0u));
199
+ textureStore(normalOutput, texel, vec4f(normal * 0.5 + 0.5, 1.0));
200
+ }
201
+ `;
202
+ }
203
+
204
+ /**
205
+ * Mip pass for one level. Port of the mip chain part of `cortao_prepass()`. CORTAO does not average
206
+ * depth: each texel of level K copies one of its four children in level K - 1, chosen by the
207
+ * random seed. Bindings: 0 uniforms, 1 level K - 1, 2 level K (storage).
208
+ */
209
+ export const CORTAO_MIPMAP_WGSL = /* wgsl */ `\
210
+ struct CORTAOMipmapUniforms {
211
+ resolution: vec2f,
212
+ level: u32,
213
+ randomSeed: u32,
214
+ };
215
+
216
+ @group(0) @binding(0) var<uniform> cortaoMipmap: CORTAOMipmapUniforms;
217
+ @group(0) @binding(1) var sourceLevel: texture_2d<u32>;
218
+ @group(0) @binding(2) var targetLevel: texture_storage_2d<r32uint, write>;
219
+
220
+ @compute @workgroup_size(${CORTAO_WORKGROUP_SIZE}, ${CORTAO_WORKGROUP_SIZE})
221
+ fn main(@builtin(global_invocation_id) id: vec3u) {
222
+ let size = vec2u(cortaoMipmap.resolution);
223
+ let level = cortaoMipmap.level;
224
+ let levelSize = max(size >> vec2u(level), vec2u(1u));
225
+ if (any(id.xy >= levelSize)) {
226
+ return;
227
+ }
228
+ let sourceSize = max(size >> vec2u(level - 1u), vec2u(1u));
229
+ // GL pixel coordinates of this texel.
230
+ let coords = vec2u(id.x, levelSize.y - 1u - id.y);
231
+ // The child that cortao_prepass() does not reject as "wrongPixel" at this level.
232
+ let dither = vec2u(cortaoMipmap.randomSeed) >> vec2u(level * 2u, level * 2u + 1u);
233
+ var child = coords * 2u + vec2u((coords.y ^ dither.x) & 1u, (coords.x ^ dither.y) & 1u);
234
+ child = min(child, sourceSize - 1u);
235
+ let sourceTexel = vec2u(child.x, sourceSize.y - 1u - child.y);
236
+ textureStore(targetLevel, id.xy, vec4u(textureLoad(sourceLevel, sourceTexel, 0).r, 0u, 0u, 0u));
237
+ }
238
+ `;
239
+
240
+ /** The defines of the main pass. */
241
+ export type CORTAOMainPassWGSLOptions = {
242
+ sampleCount: number;
243
+ rayCount: number;
244
+ lookupDirectionResolution: number;
245
+ lookupRadiusResolution: number;
246
+ };
247
+
248
+ /**
249
+ * Main pass. Port of `cortao_mainPass()` for a perspective projection, with the occluder lookup
250
+ * table and occlusion output only. It reads real mip levels with `textureLoad()`. Bindings:
251
+ * 0 uniforms, 1 packed data with all levels, 2 normal, 3 lookup table, 4 occlusion (storage).
252
+ */
253
+ export function getCORTAOMainPassWGSL(options: CORTAOMainPassWGSLOptions): string {
254
+ return /* wgsl */ `\
255
+ ${CORTAO_BASE_WGSL}
256
+ const CORTAO_SAMPLE_COUNT: i32 = ${options.sampleCount};
257
+ const CORTAO_RAY_COUNT: u32 = ${options.rayCount}u;
258
+ const CORTAO_LOOKUP_SIZE = vec3i(
259
+ ${options.lookupDirectionResolution}, ${options.lookupDirectionResolution}, ${options.lookupRadiusResolution}
260
+ );
261
+
262
+ struct CORTAOMainUniforms {
263
+ unprojectParams: vec4f,
264
+ projectionParams: vec4f,
265
+ resolution: vec2f,
266
+ normalBias: f32,
267
+ radius: f32,
268
+ maxApparentCircleRadiusCoefficient: f32,
269
+ mipBias: f32,
270
+ inverseMaxSlopeCompensation: f32,
271
+ backfaceThreshold: f32,
272
+ backfaceBoost: f32,
273
+ intensity: f32,
274
+ mipCount: i32,
275
+ randomSeed: u32,
276
+ };
277
+
278
+ @group(0) @binding(0) var<uniform> cortaoMain: CORTAOMainUniforms;
279
+ @group(0) @binding(1) var packedDataTexture: texture_2d<u32>;
280
+ @group(0) @binding(2) var normalTexture: texture_2d<f32>;
281
+ @group(0) @binding(3) var occluderLookupTable: texture_3d<u32>;
282
+ @group(0) @binding(4) var occlusionOutput: texture_storage_2d<rgba8unorm, write>;
283
+
284
+ // Nearest-mip sample of the packed data with a border value of 0.
285
+ fn cortao_samplePackedData(texCoords: vec2f, mipmap: f32) -> u32 {
286
+ if (any(texCoords < vec2f(0.0)) || any(texCoords >= vec2f(1.0))) {
287
+ return 0u;
288
+ }
289
+ let level = clamp(i32(floor(mipmap + 0.5)), 0, cortaoMain.mipCount - 1);
290
+ let size = vec2i(cortaoMain.resolution);
291
+ let levelSize = max(size >> vec2u(u32(level)), vec2i(1));
292
+ let texel = min(vec2i(texCoords * vec2f(levelSize)), levelSize - 1);
293
+ return textureLoad(packedDataTexture, cortao_flipRow(texel, levelSize), level).r;
294
+ }
295
+
296
+ // Nearest sample with clamp-to-edge.
297
+ fn cortao_sampleOccluderLookupTable(texCoords: vec3f) -> u32 {
298
+ let texel = clamp(vec3i(floor(texCoords * vec3f(CORTAO_LOOKUP_SIZE))), vec3i(0), CORTAO_LOOKUP_SIZE - 1);
299
+ return textureLoad(occluderLookupTable, texel, 0).r;
300
+ }
301
+
302
+ fn cortao_computeRayOcclusion(
303
+ offsetDither: f32,
304
+ offsetTransform: mat3x3f,
305
+ tangentSpaceTransform: mat3x3f,
306
+ mipBias: f32,
307
+ viewPosition: vec3f,
308
+ normal: vec3f,
309
+ viewDirection: vec3f,
310
+ maxRadius: f32
311
+ ) -> u32 {
312
+ var rayBits = 0u;
313
+ for (var i = 0; i < CORTAO_SAMPLE_COUNT; i++) {
314
+ // Golden-angle spiral direction.
315
+ let a = f32(i) * CORTAO_GOLDEN_ANGLE;
316
+ let spiral = vec2f(cos(a), sin(a));
317
+ let inverseSampleCount = 1.0 / f32(CORTAO_SAMPLE_COUNT);
318
+
319
+ // The skew pulls the sample distribution toward the center.
320
+ let skew = 3.5;
321
+ let innerRadius = pow(f32(i) * inverseSampleCount, skew * 0.5);
322
+ let outerRadius = pow((f32(i) + 1.0) * inverseSampleCount, skew * 0.5);
323
+ let innerSpiral = spiral * innerRadius;
324
+ let outerSpiral = spiral * outerRadius;
325
+
326
+ // The weight is the square root of the area of the strip that the sample can move over.
327
+ let sampleArea = outerRadius * outerRadius - innerRadius * innerRadius;
328
+ let sampleWeight = sqrt(sampleArea);
329
+ let sampleMipmap = log2(outerRadius);
330
+
331
+ let sampleOffset = (outerSpiral - innerSpiral) * offsetDither + innerSpiral;
332
+ let projectedCoords = offsetTransform * vec3f(sampleOffset, 1.0);
333
+ let sampleCoords = projectedCoords.xy / projectedCoords.z;
334
+
335
+ let mipmap = mipBias + sampleMipmap;
336
+ let packedData = cortao_samplePackedData(sampleCoords, mipmap);
337
+ let sampleDepth = cortao_unpackDepth(packedData);
338
+
339
+ let dPos = cortao_unprojectWithOffset(cortaoMain.unprojectParams, sampleCoords, sampleDepth, -viewPosition);
340
+
341
+ // Sky samples and samples outside the screen have a depth of 0, which is outside the hemisphere.
342
+ let lengthSquared = dot(dPos, dPos);
343
+ if (lengthSquared < maxRadius * maxRadius && dot(dPos, normal) > 0.0) {
344
+ let inverseLength = inverseSqrt(lengthSquared);
345
+ var direction = dPos * inverseLength;
346
+ let sampleNormal = cortao_decodeNormal(packedData);
347
+
348
+ let slopeCompensation = inverseSqrt(max(dot(sampleNormal, viewDirection), cortaoMain.inverseMaxSlopeCompensation));
349
+ var occluderRadius = (maxRadius * sampleWeight) * (slopeCompensation * inverseLength);
350
+
351
+ let sampleDot = dot(sampleNormal, direction);
352
+ if (sampleDot < cortaoMain.backfaceThreshold) {
353
+ // Front face: move the occluder by one radius into the object to prevent self-occlusion.
354
+ let adjustedOffset = -occluderRadius / max(1.0 - occluderRadius * occluderRadius * 0.5, 0.000001);
355
+ direction = normalize(sampleNormal * adjustedOffset + direction);
356
+ } else {
357
+ // Back face: optionally enlarge the occluder to prevent light leaks.
358
+ occluderRadius *= mix(1.0, slopeCompensation, cortaoMain.backfaceBoost);
359
+ }
360
+
361
+ let hemisphereDirection = direction * tangentSpaceTransform;
362
+
363
+ // Sphere-map encode the direction to get the lookup coordinates.
364
+ let scale = inverseSqrt(hemisphereDirection.z * 8.0 + 8.0);
365
+ let sphereMapCoordinates = hemisphereDirection.xy * scale + 0.5;
366
+ let lookupCoords = vec3f(sphereMapCoordinates, occluderRadius * sqrt(0.5));
367
+ // The sphere-map projection fails for (0, 0, -1). Ignore that sample.
368
+ if (hemisphereDirection.z > -0.99) {
369
+ rayBits |= cortao_sampleOccluderLookupTable(lookupCoords);
370
+ }
371
+ }
372
+ }
373
+ return rayBits;
374
+ }
375
+
376
+ // Frisvad's orthonormal basis. Returns the tangent and the bitangent as the columns 0 and 1.
377
+ fn cortao_constructBasis(normal: vec3f) -> mat2x3f {
378
+ let a = 1.0 / max(1.0 + normal.z, 0.000001);
379
+ let b = normal.x * normal.y * a;
380
+ return mat2x3f(
381
+ vec3f(normal.x * normal.x * a - 1.0, b, normal.x),
382
+ vec3f(b, normal.y * normal.y * a - 1.0, normal.y)
383
+ );
384
+ }
385
+
386
+ @compute @workgroup_size(${CORTAO_WORKGROUP_SIZE}, ${CORTAO_WORKGROUP_SIZE})
387
+ fn main(@builtin(global_invocation_id) id: vec3u) {
388
+ let size = vec2i(cortaoMain.resolution);
389
+ let texel = vec2i(id.xy);
390
+ if (any(texel >= size)) {
391
+ return;
392
+ }
393
+ let pixelCoords = cortao_flipRow(texel, size);
394
+ let texCoords = (vec2f(pixelCoords) + 0.5) / cortaoMain.resolution;
395
+
396
+ let linearDepth = cortao_unpackDepth(textureLoad(packedDataTexture, texel, 0).r);
397
+ if (linearDepth == 0.0) {
398
+ // Sky pixel.
399
+ textureStore(occlusionOutput, texel, vec4f(1.0));
400
+ return;
401
+ }
402
+
403
+ let normal = normalize(textureLoad(normalTexture, texel, 0).xyz * 2.0 - 1.0);
404
+ var viewPosition = cortao_unproject(cortaoMain.unprojectParams, texCoords, linearDepth);
405
+
406
+ let random = cortao_hash2(vec2u(cortao_seed(vec2u(pixelCoords))) + cortao_unpack16(cortaoMain.randomSeed));
407
+ let randomSampleRotation = f32(random.x) * (CORTAO_PI2 / 4294967295.0);
408
+ let offsetDither = f32(random.y) * (1.0 / 4294967295.0);
409
+ let randomTangentRotation = f32(random.x ^ random.y ^ cortaoMain.randomSeed) * (CORTAO_PI2 / 4294967295.0);
410
+ let sampleRotation = vec2f(sin(randomSampleRotation), cos(randomSampleRotation));
411
+
412
+ // The radius is the world-space radius, clamped by the maximum screen-space radius.
413
+ let clampedRadius = min(cortaoMain.radius, linearDepth * cortaoMain.maxApparentCircleRadiusCoefficient);
414
+
415
+ // Near the sampling sphere, the sphere looks larger due to the horizon. Expand the circle.
416
+ let inverseCircleDistance = inverseSqrt(linearDepth * linearDepth - clampedRadius * clampedRadius);
417
+ let apparentCircleRadius = clampedRadius * inverseCircleDistance;
418
+ let circleRadius = apparentCircleRadius * linearDepth;
419
+
420
+ let viewDirection = -normalize(viewPosition);
421
+
422
+ // The sample pattern stretches near the screen edge. Increase the mip bias to compensate.
423
+ let stretchMultiplier = inverseSqrt(viewDirection.z);
424
+ let baseMipBias = log2(apparentCircleRadius * stretchMultiplier) + cortaoMain.mipBias;
425
+
426
+ // Push the center out along the normal to prevent self-shadowing.
427
+ let pixelSize = cortaoMain.normalBias * linearDepth;
428
+ viewPosition = normal * pixelSize + viewPosition;
429
+
430
+ let scaledRotation = sampleRotation * circleRadius;
431
+ let rotationScaleMatrix = mat3x3f(
432
+ scaledRotation.x, -scaledRotation.y, 0.0,
433
+ scaledRotation.y, scaledRotation.x, 0.0,
434
+ 0.0, 0.0, 1.0
435
+ );
436
+
437
+ let viewBasis = cortao_constructBasis(viewDirection);
438
+ var right = viewBasis[0];
439
+ let up = viewBasis[1];
440
+ // Randomly switch between a clockwise and a counter-clockwise spiral.
441
+ if ((random.x & 1u) == 0u) {
442
+ right = -right;
443
+ }
444
+ let circleMatrix = mat3x3f(right, up, viewPosition);
445
+
446
+ // Truncated projection: field of view and off-center offset, with the NDC to texture transform.
447
+ let projectionMatrix = mat3x3f(
448
+ cortaoMain.projectionParams.x, 0.0, 0.0,
449
+ 0.0, cortaoMain.projectionParams.y, 0.0,
450
+ cortaoMain.projectionParams.z, cortaoMain.projectionParams.w, -1.0
451
+ );
452
+ let offsetTransform = projectionMatrix * (circleMatrix * rotationScaleMatrix);
453
+
454
+ let normalBasis = cortao_constructBasis(normal);
455
+ let s = sin(randomTangentRotation);
456
+ let c = cos(randomTangentRotation);
457
+ let tangent = c * normalBasis[0] + s * normalBasis[1];
458
+ let bitangent = c * normalBasis[1] - s * normalBasis[0];
459
+ let tangentSpaceTransform = mat3x3f(tangent, bitangent, normal);
460
+
461
+ let rayBits = cortao_computeRayOcclusion(
462
+ offsetDither, offsetTransform, tangentSpaceTransform, baseMipBias, viewPosition, normal, viewDirection, clampedRadius
463
+ );
464
+
465
+ var occlusion = 1.0 - f32(countOneBits(rayBits)) / f32(CORTAO_RAY_COUNT);
466
+ // Non-photorealistic intensity, as the CORTAO documentation recommends.
467
+ occlusion = pow(occlusion, cortaoMain.intensity);
468
+ textureStore(occlusionOutput, texel, vec4f(occlusion, 0.0, 0.0, 1.0));
469
+ }
470
+ `;
471
+ }
472
+
473
+ /** The defines of the filter pass. */
474
+ export type CORTAOFilterPassWGSLOptions = {
475
+ largeFilter: boolean;
476
+ filterSymmetry: boolean;
477
+ };
478
+
479
+ /**
480
+ * Filter pass. Port of `cortao_filterPass()` for occlusion only, with `textureGather()`. Each
481
+ * invocation filters one 2 x 2 block, as in the reference. WebGPU has no border clamp, so the
482
+ * gathers zero the texels outside the texture. Bindings: 0 uniforms, 1 packed level 0,
483
+ * 2 occlusion, 3 nearest non-filtering sampler, 4 filtered occlusion (storage).
484
+ */
485
+ export function getCORTAOFilterPassWGSL(options: CORTAOFilterPassWGSLOptions): string {
486
+ const offsets = options.largeFilter
487
+ ? [
488
+ [3, 0],
489
+ [6, 0],
490
+ [3, 3],
491
+ [0, 3],
492
+ [0, 6],
493
+ [3, -3]
494
+ ]
495
+ : [
496
+ [3, 0],
497
+ [0, 3]
498
+ ];
499
+ const taps = offsets
500
+ .map(([x, y]) => {
501
+ const minimum = options.filterSymmetry
502
+ ? `
503
+ let minWeight = min(weightA, weightB);
504
+ weightA = minWeight;
505
+ weightB = minWeight;`
506
+ : '';
507
+ return `
508
+ {
509
+ let offset = vec2i(${x}, ${y});
510
+ var weightA = cortao_calculateWeight(weightParams, cortao_gatherPackedData(pixelCoords - offset), -offset);
511
+ var weightB = cortao_calculateWeight(weightParams, cortao_gatherPackedData(pixelCoords + offset), offset);${minimum}
512
+ weightSum += weightA + weightB;
513
+ occlusionSum += cortao_gatherOcclusion(pixelCoords - offset) * weightA;
514
+ occlusionSum += cortao_gatherOcclusion(pixelCoords + offset) * weightB;
515
+ }`;
516
+ })
517
+ .join('');
518
+ return /* wgsl */ `\
519
+ const CORTAO_PACKED_NORMAL_BITS: u32 = ${CORTAO_PACKED_NORMAL_BITS}u;
520
+
521
+ struct CORTAOFilterUniforms {
522
+ resolution: vec2f,
523
+ depthSensitivity: f32,
524
+ normalSensitivity: f32,
525
+ };
526
+
527
+ @group(0) @binding(0) var<uniform> cortaoFilter: CORTAOFilterUniforms;
528
+ @group(0) @binding(1) var packedDataTexture: texture_2d<u32>;
529
+ @group(0) @binding(2) var occlusionTexture: texture_2d<f32>;
530
+ @group(0) @binding(3) var pointSampler: sampler;
531
+ @group(0) @binding(4) var occlusionOutput: texture_storage_2d<rgba8unorm, write>;
532
+
533
+ struct CORTAOWeightParams {
534
+ depthMultiplier: vec4f,
535
+ depthOffset: f32,
536
+ deltaX: vec4f,
537
+ deltaY: vec4f,
538
+ centerNormalX: vec4i,
539
+ centerNormalY: vec4i,
540
+ normalErrorMultiplier: f32,
541
+ };
542
+
543
+ // A gather at the texel corner "corner" reads the texels corner - 1 and corner on each axis.
544
+ // Component order: x = (x0, y1), y = (x1, y1), z = (x1, y0), w = (x0, y0).
545
+ fn cortao_gatherMask(corner: vec2i) -> vec4<bool> {
546
+ let size = vec2i(cortaoFilter.resolution);
547
+ let low = corner - vec2i(1);
548
+ let x0 = low.x >= 0 && low.x < size.x;
549
+ let x1 = corner.x >= 0 && corner.x < size.x;
550
+ let y0 = low.y >= 0 && low.y < size.y;
551
+ let y1 = corner.y >= 0 && corner.y < size.y;
552
+ return vec4<bool>(x0 && y1, x1 && y1, x1 && y0, x0 && y0);
553
+ }
554
+
555
+ fn cortao_gatherPackedData(corner: vec2i) -> vec4u {
556
+ let texCoords = vec2f(corner) / cortaoFilter.resolution;
557
+ return select(vec4u(0u), textureGather(0, packedDataTexture, pointSampler, texCoords), cortao_gatherMask(corner));
558
+ }
559
+
560
+ fn cortao_gatherOcclusion(corner: vec2i) -> vec4f {
561
+ let texCoords = vec2f(corner) / cortaoFilter.resolution;
562
+ return select(vec4f(0.0), textureGather(0, occlusionTexture, pointSampler, texCoords), cortao_gatherMask(corner));
563
+ }
564
+
565
+ fn cortao_unpackDepth(packedData: vec4u) -> vec4f {
566
+ return bitcast<vec4f>(packedData);
567
+ }
568
+
569
+ fn cortao_unpackNormalX(packedData: vec4u) -> vec4i {
570
+ let normalBits = CORTAO_PACKED_NORMAL_BITS / 2u;
571
+ return (bitcast<vec4i>(packedData) << vec4u(32u - normalBits)) >> vec4u(32u - normalBits);
572
+ }
573
+
574
+ fn cortao_unpackNormalY(packedData: vec4u) -> vec4i {
575
+ let normalBits = CORTAO_PACKED_NORMAL_BITS / 2u;
576
+ return (bitcast<vec4i>(packedData) << vec4u(32u - normalBits * 2u)) >> vec4u(32u - normalBits);
577
+ }
578
+
579
+ fn cortao_calculateWeight(params: CORTAOWeightParams, packedData: vec4u, offset: vec2i) -> vec4f {
580
+ let sampleDepth = cortao_unpackDepth(packedData) * params.depthMultiplier + params.depthOffset;
581
+ var error = abs(params.deltaX * f32(offset.x) + params.deltaY * f32(offset.y) + sampleDepth);
582
+ let normalX = cortao_unpackNormalX(packedData) - params.centerNormalX;
583
+ let normalY = cortao_unpackNormalY(packedData) - params.centerNormalY;
584
+ error += vec4f(normalX * normalX + normalY * normalY) * params.normalErrorMultiplier;
585
+ return exp2(-error);
586
+ }
587
+
588
+ @compute @workgroup_size(${CORTAO_WORKGROUP_SIZE}, ${CORTAO_WORKGROUP_SIZE})
589
+ fn main(@builtin(global_invocation_id) id: vec3u) {
590
+ let resolution = vec2i(cortaoFilter.resolution);
591
+ let pixelCoords = vec2i(id.xy) * 2 + vec2i(1);
592
+ // ">" is correct here, as the block also writes pixelCoords - 1.
593
+ if (pixelCoords.x > resolution.x || pixelCoords.y > resolution.y) {
594
+ return;
595
+ }
596
+
597
+ let centerPackedData = cortao_gatherPackedData(pixelCoords);
598
+ let centerDepth = cortao_unpackDepth(centerPackedData);
599
+ let inverseCenterDepth = 1.0 / centerDepth;
600
+ let sensitivity = cortaoFilter.depthSensitivity;
601
+
602
+ var weightParams: CORTAOWeightParams;
603
+ weightParams.deltaX = (centerDepth.xxww - centerDepth.yyzz) * inverseCenterDepth * sensitivity;
604
+ weightParams.deltaY = (centerDepth.wzzw - centerDepth.xyyx) * inverseCenterDepth * sensitivity;
605
+ weightParams.depthMultiplier = sensitivity * inverseCenterDepth;
606
+ weightParams.depthOffset = -sensitivity;
607
+ weightParams.centerNormalX = cortao_unpackNormalX(centerPackedData);
608
+ weightParams.centerNormalY = cortao_unpackNormalY(centerPackedData);
609
+ weightParams.normalErrorMultiplier = cortaoFilter.normalSensitivity / f32(1u << (CORTAO_PACKED_NORMAL_BITS / 2u));
610
+
611
+ var occlusionSum = cortao_gatherOcclusion(pixelCoords);
612
+ var weightSum = vec4f(1.0);
613
+ ${taps}
614
+
615
+ let result = occlusionSum / weightSum;
616
+ let low = pixelCoords - vec2i(1);
617
+ var outputCoords = array<vec2i, 4>(
618
+ vec2i(low.x, pixelCoords.y),
619
+ pixelCoords,
620
+ vec2i(pixelCoords.x, low.y),
621
+ low
622
+ );
623
+ for (var i = 0; i < 4; i++) {
624
+ let coords = outputCoords[i];
625
+ if (coords.x < resolution.x && coords.y < resolution.y) {
626
+ // Sky pixels are not occluded.
627
+ let occlusion = select(result[i], 1.0, centerPackedData[i] == 0u);
628
+ textureStore(occlusionOutput, coords, vec4f(occlusion, 0.0, 0.0, 1.0));
629
+ }
630
+ }
631
+ }
632
+ `;
633
+ }