@zephyr3d/scene 0.9.1 → 0.9.3

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 (522) hide show
  1. package/dist/animation/animationset.js +2 -0
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/cloth/gpu_cloth_system.js +9 -1
  4. package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
  5. package/dist/animation/fixed_geometry_cache_track.js +5 -1
  6. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  7. package/dist/animation/geometry_cache_utils.js +20 -4
  8. package/dist/animation/geometry_cache_utils.js.map +1 -1
  9. package/dist/animation/ik/ik_angle_constraint.js +2 -6
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
  11. package/dist/animation/ik/ik_chain_builder.js +68 -0
  12. package/dist/animation/ik/ik_chain_builder.js.map +1 -0
  13. package/dist/animation/ik/ik_pole_constraint.js +2 -7
  14. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  15. package/dist/animation/ik/two_bone_ik_solver.js +2 -6
  16. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
  17. package/dist/animation/joint_dynamics/collision.js +60 -12
  18. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  19. package/dist/animation/joint_dynamics/constraints.js +20 -4
  20. package/dist/animation/joint_dynamics/constraints.js.map +1 -1
  21. package/dist/animation/joint_dynamics/controller.js +94 -46
  22. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  23. package/dist/animation/joint_dynamics/math.js +16 -0
  24. package/dist/animation/joint_dynamics/math.js.map +1 -0
  25. package/dist/animation/joint_dynamics/solver.js +21 -11
  26. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  27. package/dist/animation/joint_dynamics/types.js +15 -3
  28. package/dist/animation/joint_dynamics/types.js.map +1 -1
  29. package/dist/animation/pca_geometry_cache_track.js +5 -1
  30. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  31. package/dist/animation/skeleton.js +2 -2
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +2 -6
  34. package/dist/animation/skeleton_modifier.js.map +1 -1
  35. package/dist/animation/spring/spring_particle.js +4 -4
  36. package/dist/animation/spring/spring_particle.js.map +1 -1
  37. package/dist/animation/spring/spring_system.js +13 -40
  38. package/dist/animation/spring/spring_system.js.map +1 -1
  39. package/dist/animation/spring2/constraints.js.map +1 -1
  40. package/dist/animation/spring2/controller.js +64 -64
  41. package/dist/animation/spring2/controller.js.map +1 -1
  42. package/dist/animation/spring2/math.js.map +1 -1
  43. package/dist/animation/spring2/spring_system.js +8 -8
  44. package/dist/animation/spring2/spring_system.js.map +1 -1
  45. package/dist/app/app.js.map +1 -1
  46. package/dist/app/engine.js +1 -1
  47. package/dist/app/engine.js.map +1 -1
  48. package/dist/app/screen.js +4 -4
  49. package/dist/app/screen.js.map +1 -1
  50. package/dist/app/scriptingsystem.js +24 -1
  51. package/dist/app/scriptingsystem.js.map +1 -1
  52. package/dist/app/scriptregistry.js +22 -1
  53. package/dist/app/scriptregistry.js.map +1 -1
  54. package/dist/asset/assetmanager.js +2 -2
  55. package/dist/asset/assetmanager.js.map +1 -1
  56. package/dist/asset/model.js +60 -60
  57. package/dist/asset/model.js.map +1 -1
  58. package/dist/camera/camera.js +1 -1
  59. package/dist/camera/camera.js.map +1 -1
  60. package/dist/camera/orbit.js.map +1 -1
  61. package/dist/index.d.ts +795 -266
  62. package/dist/index.js +3 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/material/material.js +3 -1
  65. package/dist/material/material.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  67. package/dist/material/shader/helper.js +281 -278
  68. package/dist/material/shader/helper.js.map +1 -1
  69. package/dist/material/sprite.js +6 -6
  70. package/dist/material/sprite.js.map +1 -1
  71. package/dist/material/terrain-cm.js +2 -2
  72. package/dist/material/terrain-cm.js.map +1 -1
  73. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  74. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  75. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  76. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  77. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  78. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  79. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  80. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  81. package/dist/posteffect/taa.js +31 -39
  82. package/dist/posteffect/taa.js.map +1 -1
  83. package/dist/render/cluster_light.js +3 -4
  84. package/dist/render/cluster_light.js.map +1 -1
  85. package/dist/render/drawable.js +5 -1
  86. package/dist/render/drawable.js.map +1 -1
  87. package/dist/render/rendergraph/device_pool_allocator.js +29 -3
  88. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  89. package/dist/render/rendergraph/executor.js +283 -33
  90. package/dist/render/rendergraph/executor.js.map +1 -1
  91. package/dist/render/rendergraph/forward_plus_builder.js +338 -108
  92. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  93. package/dist/render/rendergraph/history_resource_manager.js +195 -115
  94. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  95. package/dist/render/rendergraph/history_resources.js +10 -0
  96. package/dist/render/rendergraph/history_resources.js.map +1 -0
  97. package/dist/render/rendergraph/rendergraph.js +162 -35
  98. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  99. package/dist/render/rendergraph/types.js +25 -5
  100. package/dist/render/rendergraph/types.js.map +1 -1
  101. package/dist/render/rendertarget.js +5 -1
  102. package/dist/render/rendertarget.js.map +1 -1
  103. package/dist/render/screenrendertarget.js +5 -1
  104. package/dist/render/screenrendertarget.js.map +1 -1
  105. package/dist/render/sky.js +4 -4
  106. package/dist/render/sky.js.map +1 -1
  107. package/dist/scene/basesprite.js +2 -2
  108. package/dist/scene/basesprite.js.map +1 -1
  109. package/dist/scene/graph_node.js +1 -1
  110. package/dist/scene/graph_node.js.map +1 -1
  111. package/dist/scene/mesh.js +81 -97
  112. package/dist/scene/mesh.js.map +1 -1
  113. package/dist/scene/particlesys.js +1 -1
  114. package/dist/scene/particlesys.js.map +1 -1
  115. package/dist/scene/scene_node.js +228 -228
  116. package/dist/scene/scene_node.js.map +1 -1
  117. package/dist/scene/script_attachment.js +15 -3
  118. package/dist/scene/script_attachment.js.map +1 -1
  119. package/dist/scene/terrain-cm/terrain-cm.js +3 -3
  120. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  121. package/dist/shadow/shadowmapper.js.map +1 -1
  122. package/dist/shapes/box.js +1 -1
  123. package/dist/shapes/box.js.map +1 -1
  124. package/dist/shapes/capsule.js +0 -3
  125. package/dist/shapes/capsule.js.map +1 -1
  126. package/dist/shapes/cylinder.js +0 -3
  127. package/dist/shapes/cylinder.js.map +1 -1
  128. package/dist/shapes/plane.js +0 -3
  129. package/dist/shapes/plane.js.map +1 -1
  130. package/dist/shapes/tetrahedron.js +3 -9
  131. package/dist/shapes/tetrahedron.js.map +1 -1
  132. package/dist/shapes/torus.js +94 -66
  133. package/dist/shapes/torus.js.map +1 -1
  134. package/dist/src/animation/animation.js +127 -0
  135. package/dist/src/animation/animation.js.map +1 -0
  136. package/dist/src/animation/animationset.js +255 -0
  137. package/dist/src/animation/animationset.js.map +1 -0
  138. package/dist/src/animation/animationtrack.js +34 -0
  139. package/dist/src/animation/animationtrack.js.map +1 -0
  140. package/dist/src/animation/eulerrotationtrack.js +52 -0
  141. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  142. package/dist/src/animation/morphtarget.js +93 -0
  143. package/dist/src/animation/morphtarget.js.map +1 -0
  144. package/dist/src/animation/morphtrack.js +70 -0
  145. package/dist/src/animation/morphtrack.js.map +1 -0
  146. package/dist/src/animation/proptrack.js +161 -0
  147. package/dist/src/animation/proptrack.js.map +1 -0
  148. package/dist/src/animation/rotationtrack.js +51 -0
  149. package/dist/src/animation/rotationtrack.js.map +1 -0
  150. package/dist/src/animation/scaletrack.js +50 -0
  151. package/dist/src/animation/scaletrack.js.map +1 -0
  152. package/dist/src/animation/skeleton.js +204 -0
  153. package/dist/src/animation/skeleton.js.map +1 -0
  154. package/dist/src/animation/translationtrack.js +50 -0
  155. package/dist/src/animation/translationtrack.js.map +1 -0
  156. package/dist/src/app/app.js +129 -0
  157. package/dist/src/app/app.js.map +1 -0
  158. package/dist/src/app/inputmgr.js +267 -0
  159. package/dist/src/app/inputmgr.js.map +1 -0
  160. package/dist/src/asset/assetmanager.js +404 -0
  161. package/dist/src/asset/assetmanager.js.map +1 -0
  162. package/dist/src/asset/builtin.js +337 -0
  163. package/dist/src/asset/builtin.js.map +1 -0
  164. package/dist/src/asset/loaders/dds/dds.js +470 -0
  165. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  166. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  167. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  168. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  169. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  170. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  171. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  172. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  173. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  174. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  175. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  176. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  177. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  178. package/dist/src/asset/loaders/loader.js +45 -0
  179. package/dist/src/asset/loaders/loader.js.map +1 -0
  180. package/dist/src/asset/model.js +414 -0
  181. package/dist/src/asset/model.js.map +1 -0
  182. package/dist/src/blitter/bilateralblur.js +221 -0
  183. package/dist/src/blitter/bilateralblur.js.map +1 -0
  184. package/dist/src/blitter/blitter.js +390 -0
  185. package/dist/src/blitter/blitter.js.map +1 -0
  186. package/dist/src/blitter/box.js +118 -0
  187. package/dist/src/blitter/box.js.map +1 -0
  188. package/dist/src/blitter/copy.js +22 -0
  189. package/dist/src/blitter/copy.js.map +1 -0
  190. package/dist/src/blitter/gaussianblur.js +228 -0
  191. package/dist/src/blitter/gaussianblur.js.map +1 -0
  192. package/dist/src/camera/base.js +92 -0
  193. package/dist/src/camera/base.js.map +1 -0
  194. package/dist/src/camera/camera.js +1005 -0
  195. package/dist/src/camera/camera.js.map +1 -0
  196. package/dist/src/camera/fps.js +238 -0
  197. package/dist/src/camera/fps.js.map +1 -0
  198. package/dist/src/camera/orbit.js +245 -0
  199. package/dist/src/camera/orbit.js.map +1 -0
  200. package/dist/src/camera/orthocamera.js +167 -0
  201. package/dist/src/camera/orthocamera.js.map +1 -0
  202. package/dist/src/camera/perspectivecamera.js +141 -0
  203. package/dist/src/camera/perspectivecamera.js.map +1 -0
  204. package/dist/src/index.js +120 -0
  205. package/dist/src/index.js.map +1 -0
  206. package/dist/src/material/blinn.js +81 -0
  207. package/dist/src/material/blinn.js.map +1 -0
  208. package/dist/src/material/grassmaterial.js +113 -0
  209. package/dist/src/material/grassmaterial.js.map +1 -0
  210. package/dist/src/material/lambert.js +92 -0
  211. package/dist/src/material/lambert.js.map +1 -0
  212. package/dist/src/material/material.js +301 -0
  213. package/dist/src/material/material.js.map +1 -0
  214. package/dist/src/material/meshmaterial.js +704 -0
  215. package/dist/src/material/meshmaterial.js.map +1 -0
  216. package/dist/src/material/mixins/albedocolor.js +76 -0
  217. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  218. package/dist/src/material/mixins/foliage.js +47 -0
  219. package/dist/src/material/mixins/foliage.js.map +1 -0
  220. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  221. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  222. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  223. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  224. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  225. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  226. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  227. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  228. package/dist/src/material/mixins/lit.js +476 -0
  229. package/dist/src/material/mixins/lit.js.map +1 -0
  230. package/dist/src/material/mixins/pbr/common.js +918 -0
  231. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  232. package/dist/src/material/mixins/texture.js +172 -0
  233. package/dist/src/material/mixins/texture.js.map +1 -0
  234. package/dist/src/material/mixins/vertexcolor.js +56 -0
  235. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  236. package/dist/src/material/particle.js +178 -0
  237. package/dist/src/material/particle.js.map +1 -0
  238. package/dist/src/material/pbrmr.js +97 -0
  239. package/dist/src/material/pbrmr.js.map +1 -0
  240. package/dist/src/material/pbrsg.js +97 -0
  241. package/dist/src/material/pbrsg.js.map +1 -0
  242. package/dist/src/material/shader/helper.js +1209 -0
  243. package/dist/src/material/shader/helper.js.map +1 -0
  244. package/dist/src/material/terrain-cm.js +606 -0
  245. package/dist/src/material/terrain-cm.js.map +1 -0
  246. package/dist/src/material/terrainmaterial.js +375 -0
  247. package/dist/src/material/terrainmaterial.js.map +1 -0
  248. package/dist/src/material/unlit.js +41 -0
  249. package/dist/src/material/unlit.js.map +1 -0
  250. package/dist/src/material/water.js +417 -0
  251. package/dist/src/material/water.js.map +1 -0
  252. package/dist/src/posteffect/bloom.js +361 -0
  253. package/dist/src/posteffect/bloom.js.map +1 -0
  254. package/dist/src/posteffect/compositor.js +226 -0
  255. package/dist/src/posteffect/compositor.js.map +1 -0
  256. package/dist/src/posteffect/fxaa.js +273 -0
  257. package/dist/src/posteffect/fxaa.js.map +1 -0
  258. package/dist/src/posteffect/grayscale.js +69 -0
  259. package/dist/src/posteffect/grayscale.js.map +1 -0
  260. package/dist/src/posteffect/motionblur.js +96 -0
  261. package/dist/src/posteffect/motionblur.js.map +1 -0
  262. package/dist/src/posteffect/posteffect.js +126 -0
  263. package/dist/src/posteffect/posteffect.js.map +1 -0
  264. package/dist/src/posteffect/sao.js +324 -0
  265. package/dist/src/posteffect/sao.js.map +1 -0
  266. package/dist/src/posteffect/ssr.js +489 -0
  267. package/dist/src/posteffect/ssr.js.map +1 -0
  268. package/dist/src/posteffect/taa.js +172 -0
  269. package/dist/src/posteffect/taa.js.map +1 -0
  270. package/dist/src/posteffect/tonemap.js +94 -0
  271. package/dist/src/posteffect/tonemap.js.map +1 -0
  272. package/dist/src/render/abuffer_oit.js +361 -0
  273. package/dist/src/render/abuffer_oit.js.map +1 -0
  274. package/dist/src/render/clipmap.js +851 -0
  275. package/dist/src/render/clipmap.js.map +1 -0
  276. package/dist/src/render/cluster_light.js +333 -0
  277. package/dist/src/render/cluster_light.js.map +1 -0
  278. package/dist/src/render/cull_visitor.js +187 -0
  279. package/dist/src/render/cull_visitor.js.map +1 -0
  280. package/dist/src/render/depthpass.js +68 -0
  281. package/dist/src/render/depthpass.js.map +1 -0
  282. package/dist/src/render/drawable_mixin.js +227 -0
  283. package/dist/src/render/drawable_mixin.js.map +1 -0
  284. package/dist/src/render/envlight.js +463 -0
  285. package/dist/src/render/envlight.js.map +1 -0
  286. package/dist/src/render/fbm_wavegenerator.js +251 -0
  287. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  288. package/dist/src/render/fft_wavegenerator.js +1006 -0
  289. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  290. package/dist/src/render/fullscreenquad.js +38 -0
  291. package/dist/src/render/fullscreenquad.js.map +1 -0
  292. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  293. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  294. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  295. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  296. package/dist/src/render/hzb.js +273 -0
  297. package/dist/src/render/hzb.js.map +1 -0
  298. package/dist/src/render/lightpass.js +172 -0
  299. package/dist/src/render/lightpass.js.map +1 -0
  300. package/dist/src/render/objectcolorpass.js +51 -0
  301. package/dist/src/render/objectcolorpass.js.map +1 -0
  302. package/dist/src/render/primitive.js +364 -0
  303. package/dist/src/render/primitive.js.map +1 -0
  304. package/dist/src/render/render_queue.js +467 -0
  305. package/dist/src/render/render_queue.js.map +1 -0
  306. package/dist/src/render/renderbundle_wrapper.js +152 -0
  307. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  308. package/dist/src/render/renderer.js +455 -0
  309. package/dist/src/render/renderer.js.map +1 -0
  310. package/dist/src/render/renderpass.js +200 -0
  311. package/dist/src/render/renderpass.js.map +1 -0
  312. package/dist/src/render/shadowmap_pass.js +56 -0
  313. package/dist/src/render/shadowmap_pass.js.map +1 -0
  314. package/dist/src/render/sky.js +1103 -0
  315. package/dist/src/render/sky.js.map +1 -0
  316. package/dist/src/render/weightedblended_oit.js +168 -0
  317. package/dist/src/render/weightedblended_oit.js.map +1 -0
  318. package/dist/src/scene/batchgroup.js +162 -0
  319. package/dist/src/scene/batchgroup.js.map +1 -0
  320. package/dist/src/scene/environment.js +209 -0
  321. package/dist/src/scene/environment.js.map +1 -0
  322. package/dist/src/scene/graph_node.js +72 -0
  323. package/dist/src/scene/graph_node.js.map +1 -0
  324. package/dist/src/scene/light.js +416 -0
  325. package/dist/src/scene/light.js.map +1 -0
  326. package/dist/src/scene/mesh.js +341 -0
  327. package/dist/src/scene/mesh.js.map +1 -0
  328. package/dist/src/scene/octree.js +649 -0
  329. package/dist/src/scene/octree.js.map +1 -0
  330. package/dist/src/scene/particlesys.js +738 -0
  331. package/dist/src/scene/particlesys.js.map +1 -0
  332. package/dist/src/scene/raycast_visitor.js +103 -0
  333. package/dist/src/scene/raycast_visitor.js.map +1 -0
  334. package/dist/src/scene/scene.js +284 -0
  335. package/dist/src/scene/scene.js.map +1 -0
  336. package/dist/src/scene/scene_node.js +732 -0
  337. package/dist/src/scene/scene_node.js.map +1 -0
  338. package/dist/src/scene/terrain/grass.js +278 -0
  339. package/dist/src/scene/terrain/grass.js.map +1 -0
  340. package/dist/src/scene/terrain/heightfield.js +475 -0
  341. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  342. package/dist/src/scene/terrain/patch.js +530 -0
  343. package/dist/src/scene/terrain/patch.js.map +1 -0
  344. package/dist/src/scene/terrain/quadtree.js +461 -0
  345. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  346. package/dist/src/scene/terrain/terrain.js +246 -0
  347. package/dist/src/scene/terrain/terrain.js.map +1 -0
  348. package/dist/src/scene/terrain-cm/grass.js +594 -0
  349. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  350. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  351. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  352. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  353. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  354. package/dist/src/scene/water.js +374 -0
  355. package/dist/src/scene/water.js.map +1 -0
  356. package/dist/src/shaders/atmosphere.js +957 -0
  357. package/dist/src/shaders/atmosphere.js.map +1 -0
  358. package/dist/src/shaders/fog.js +112 -0
  359. package/dist/src/shaders/fog.js.map +1 -0
  360. package/dist/src/shaders/misc.js +266 -0
  361. package/dist/src/shaders/misc.js.map +1 -0
  362. package/dist/src/shaders/noise.js +222 -0
  363. package/dist/src/shaders/noise.js.map +1 -0
  364. package/dist/src/shaders/pbr.js +51 -0
  365. package/dist/src/shaders/pbr.js.map +1 -0
  366. package/dist/src/shaders/shadow.js +636 -0
  367. package/dist/src/shaders/shadow.js.map +1 -0
  368. package/dist/src/shaders/ssr.js +490 -0
  369. package/dist/src/shaders/ssr.js.map +1 -0
  370. package/dist/src/shaders/temporal.js +215 -0
  371. package/dist/src/shaders/temporal.js.map +1 -0
  372. package/dist/src/shaders/water.js +756 -0
  373. package/dist/src/shaders/water.js.map +1 -0
  374. package/dist/src/shadow/esm.js +237 -0
  375. package/dist/src/shadow/esm.js.map +1 -0
  376. package/dist/src/shadow/pcf_opt.js +181 -0
  377. package/dist/src/shadow/pcf_opt.js.map +1 -0
  378. package/dist/src/shadow/pcf_pd.js +189 -0
  379. package/dist/src/shadow/pcf_pd.js.map +1 -0
  380. package/dist/src/shadow/shader.js +37 -0
  381. package/dist/src/shadow/shader.js.map +1 -0
  382. package/dist/src/shadow/shadow_impl.js +15 -0
  383. package/dist/src/shadow/shadow_impl.js.map +1 -0
  384. package/dist/src/shadow/shadowmapper.js +790 -0
  385. package/dist/src/shadow/shadowmapper.js.map +1 -0
  386. package/dist/src/shadow/ssm.js +159 -0
  387. package/dist/src/shadow/ssm.js.map +1 -0
  388. package/dist/src/shadow/vsm.js +297 -0
  389. package/dist/src/shadow/vsm.js.map +1 -0
  390. package/dist/src/shapes/box.js +386 -0
  391. package/dist/src/shapes/box.js.map +1 -0
  392. package/dist/src/shapes/cylinder.js +125 -0
  393. package/dist/src/shapes/cylinder.js.map +1 -0
  394. package/dist/src/shapes/plane.js +88 -0
  395. package/dist/src/shapes/plane.js.map +1 -0
  396. package/dist/src/shapes/shape.js +87 -0
  397. package/dist/src/shapes/shape.js.map +1 -0
  398. package/dist/src/shapes/sphere.js +114 -0
  399. package/dist/src/shapes/sphere.js.map +1 -0
  400. package/dist/src/shapes/tetrahedron.js +188 -0
  401. package/dist/src/shapes/tetrahedron.js.map +1 -0
  402. package/dist/src/shapes/torus.js +111 -0
  403. package/dist/src/shapes/torus.js.map +1 -0
  404. package/dist/src/utility/aabbtree.js +400 -0
  405. package/dist/src/utility/aabbtree.js.map +1 -0
  406. package/dist/src/utility/bounding_volume.js +29 -0
  407. package/dist/src/utility/bounding_volume.js.map +1 -0
  408. package/dist/src/utility/debug.js +28 -0
  409. package/dist/src/utility/debug.js.map +1 -0
  410. package/dist/src/utility/draco/decoder.js +116 -0
  411. package/dist/src/utility/draco/decoder.js.map +1 -0
  412. package/dist/src/utility/misc.js +105 -0
  413. package/dist/src/utility/misc.js.map +1 -0
  414. package/dist/src/utility/panorama.js +163 -0
  415. package/dist/src/utility/panorama.js.map +1 -0
  416. package/dist/src/utility/pmrem.js +354 -0
  417. package/dist/src/utility/pmrem.js.map +1 -0
  418. package/dist/src/utility/rendermipmap.js +115 -0
  419. package/dist/src/utility/rendermipmap.js.map +1 -0
  420. package/dist/src/utility/serialization/json.js +402 -0
  421. package/dist/src/utility/serialization/json.js.map +1 -0
  422. package/dist/src/utility/serialization/manager.js +623 -0
  423. package/dist/src/utility/serialization/manager.js.map +1 -0
  424. package/dist/src/utility/serialization/scene/animation.js +248 -0
  425. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  426. package/dist/src/utility/serialization/scene/batch.js +59 -0
  427. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  428. package/dist/src/utility/serialization/scene/camera.js +790 -0
  429. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  430. package/dist/src/utility/serialization/scene/common.js +222 -0
  431. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  432. package/dist/src/utility/serialization/scene/light.js +575 -0
  433. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  434. package/dist/src/utility/serialization/scene/material.js +1111 -0
  435. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  436. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  437. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  438. package/dist/src/utility/serialization/scene/misc.js +39 -0
  439. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  440. package/dist/src/utility/serialization/scene/node.js +451 -0
  441. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  442. package/dist/src/utility/serialization/scene/particle.js +425 -0
  443. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  444. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  445. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  446. package/dist/src/utility/serialization/scene/scene.js +704 -0
  447. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  448. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  449. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  450. package/dist/src/utility/serialization/scene/water.js +465 -0
  451. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  452. package/dist/src/utility/shprojector.js +297 -0
  453. package/dist/src/utility/shprojector.js.map +1 -0
  454. package/dist/src/utility/textures/ggxlut.js +213 -0
  455. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  456. package/dist/src/utility/textures/gradientnoise.js +62 -0
  457. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  458. package/dist/src/utility/textures/randomnoise.js +41 -0
  459. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  460. package/dist/src/values.js +162 -0
  461. package/dist/src/values.js.map +1 -0
  462. package/dist/utility/blueprint/material/common.js +7 -0
  463. package/dist/utility/blueprint/material/common.js.map +1 -0
  464. package/dist/utility/blueprint/material/inputs.js +3 -3
  465. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  466. package/dist/utility/blueprint/material/ir.js +4 -4
  467. package/dist/utility/blueprint/material/ir.js.map +1 -1
  468. package/dist/utility/serialization/blueprint/constants.js +255 -0
  469. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  470. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  471. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  472. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  473. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  474. package/dist/utility/serialization/manager.js +299 -268
  475. package/dist/utility/serialization/manager.js.map +1 -1
  476. package/dist/utility/serialization/scene/animation.js +45 -0
  477. package/dist/utility/serialization/scene/animation.js.map +1 -1
  478. package/dist/utility/serialization/scene/camera.js +53 -0
  479. package/dist/utility/serialization/scene/camera.js.map +1 -1
  480. package/dist/utility/serialization/scene/common.js +10 -0
  481. package/dist/utility/serialization/scene/common.js.map +1 -1
  482. package/dist/utility/serialization/scene/light.js +30 -0
  483. package/dist/utility/serialization/scene/light.js.map +1 -1
  484. package/dist/utility/serialization/scene/material.js +63 -0
  485. package/dist/utility/serialization/scene/material.js.map +1 -1
  486. package/dist/utility/serialization/scene/mesh.js +11 -0
  487. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  488. package/dist/utility/serialization/scene/misc.js +2 -0
  489. package/dist/utility/serialization/scene/misc.js.map +1 -1
  490. package/dist/utility/serialization/scene/node.js +19 -0
  491. package/dist/utility/serialization/scene/node.js.map +1 -1
  492. package/dist/utility/serialization/scene/particle.js +22 -0
  493. package/dist/utility/serialization/scene/particle.js.map +1 -1
  494. package/dist/utility/serialization/scene/primitive.js +33 -0
  495. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  496. package/dist/utility/serialization/scene/scene.js +39 -0
  497. package/dist/utility/serialization/scene/scene.js.map +1 -1
  498. package/dist/utility/serialization/scene/script.js +2 -0
  499. package/dist/utility/serialization/scene/script.js.map +1 -1
  500. package/dist/utility/serialization/scene/sprite.js +6 -0
  501. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  502. package/dist/utility/serialization/scene/terrain.js +9 -0
  503. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  504. package/dist/utility/serialization/scene/water.js +21 -0
  505. package/dist/utility/serialization/scene/water.js.map +1 -1
  506. package/dist/utility/serialization/types.js +5 -1
  507. package/dist/utility/serialization/types.js.map +1 -1
  508. package/dist/values.js +49 -53
  509. package/dist/values.js.map +1 -1
  510. package/package.json +2 -2
  511. package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
  512. package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
  513. package/dist/animation/spring/spring_bone.js +0 -240
  514. package/dist/animation/spring/spring_bone.js.map +0 -1
  515. package/dist/animation/spring/spring_bone_collider.js +0 -198
  516. package/dist/animation/spring/spring_bone_collider.js.map +0 -1
  517. package/dist/animation/spring/spring_bone_constraint.js +0 -170
  518. package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
  519. package/dist/animation/spring/spring_bone_system.js +0 -328
  520. package/dist/animation/spring/spring_bone_system.js.map +0 -1
  521. package/dist/render/sky_motion_vector.js +0 -85
  522. package/dist/render/sky_motion_vector.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fxaa.js","sources":["../../../src/posteffect/fxaa.ts"],"sourcesContent":["import { Vector2 } from '@zephyr3d/base';\r\nimport { AbstractPostEffect, PostEffectLayer } from './posteffect';\r\nimport { linearToGamma } from '../shaders/misc';\r\nimport type { AbstractDevice, BindGroup, GPUProgram, Texture2D } from '@zephyr3d/device';\r\nimport type { DrawContext } from '../render';\r\nimport { fetchSampler } from '../utility/misc';\r\n\r\n/**\r\n * FXAA post effect\r\n * @public\r\n */\r\nexport class FXAA extends AbstractPostEffect {\r\n private static _program: GPUProgram = null;\r\n private static _bindgroup: BindGroup = null;\r\n private readonly _invTexSize: Vector2;\r\n /**\r\n * Creates an instance of grayscale post effect\r\n */\r\n constructor() {\r\n super();\r\n this._layer = PostEffectLayer.transparent;\r\n this._invTexSize = new Vector2();\r\n }\r\n /** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */\r\n requireLinearDepthTexture(): boolean {\r\n return false;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */\r\n requireDepthAttachment(): boolean {\r\n return false;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.apply} */\r\n apply(ctx: DrawContext, inputColorTexture: Texture2D, sceneDepthTexture: Texture2D, srgbOutput: boolean) {\r\n const device = ctx.device;\r\n this._prepare(device);\r\n this._invTexSize.setXY(1 / inputColorTexture.width, 1 / inputColorTexture.height);\r\n FXAA._bindgroup.setTexture('srcTex', inputColorTexture, fetchSampler('clamp_linear_nomip'));\r\n FXAA._bindgroup.setValue('flip', this.needFlip(device) ? 1 : 0);\r\n FXAA._bindgroup.setValue('srgbOut', srgbOutput ? 1 : 0);\r\n FXAA._bindgroup.setValue('invTexSize', this._invTexSize);\r\n device.setProgram(FXAA._program);\r\n device.setBindGroup(0, FXAA._bindgroup);\r\n this.drawFullscreenQuad();\r\n }\r\n /** @internal */\r\n private _prepare(device: AbstractDevice) {\r\n if (!FXAA._program) {\r\n FXAA._program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.flip = pb.int().uniform(0);\r\n this.$inputs.pos = pb.vec2().attrib('position');\r\n this.$outputs.uv = pb.vec2();\r\n pb.main(function () {\r\n this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);\r\n this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));\r\n this.$if(pb.notEqual(this.flip, 0), function () {\r\n this.$builtins.position.y = pb.neg(this.$builtins.position.y);\r\n });\r\n });\r\n },\r\n fragment(pb) {\r\n this.srcTex = pb.tex2D().uniform(0);\r\n this.srgbOut = pb.int().uniform(0);\r\n this.invTexSize = pb.vec2().uniform(0);\r\n this.$outputs.outColor = pb.vec4();\r\n pb.func('getLuma', [pb.vec3('vSample')], function () {\r\n this.$return(pb.dot(this.vSample, pb.vec3(0.299, 0.587, 0.114)));\r\n });\r\n pb.func('FXAA', [pb.vec2('uv')], function () {\r\n this.$l.posM = this.uv;\r\n this.$l.rgbyM = pb.textureSampleLevel(this.srcTex, this.uv, 0);\r\n this.$l.lumaM = this.getLuma(this.rgbyM.rgb);\r\n this.$l.lumaN = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(0, -1), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaW = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(-1, 0), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaE = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(1, 0), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaS = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(0, 1), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.rangeMin = pb.min(\r\n this.lumaM,\r\n pb.min(pb.min(this.lumaN, this.lumaW), pb.min(this.lumaS, this.lumaE))\r\n );\r\n this.$l.rangeMax = pb.max(\r\n this.lumaM,\r\n pb.max(pb.max(this.lumaN, this.lumaW), pb.max(this.lumaS, this.lumaE))\r\n );\r\n this.$l.range = pb.sub(this.rangeMax, this.rangeMin);\r\n this.$if(pb.lessThan(this.range, pb.max(1 / 16, pb.div(this.rangeMax, 8))), function () {\r\n this.$return(this.rgbyM);\r\n });\r\n this.$l.lumaNW = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(-1, -1), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaNE = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(1, -1), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaSW = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(-1, 1), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaSE = this.getLuma(\r\n pb.textureSampleLevel(this.srcTex, pb.add(this.uv, pb.mul(pb.vec2(1, 1), this.invTexSize)), 0)\r\n .rgb\r\n );\r\n this.$l.lumaNS = pb.add(this.lumaN, this.lumaS);\r\n this.$l.lumaWE = pb.add(this.lumaW, this.lumaE);\r\n this.$l.subpixRcpRange = pb.div(1, this.range);\r\n this.$l.subpixNSWE = pb.add(this.lumaNS, this.lumaWE);\r\n this.$l.edgeHorz1 = pb.add(pb.mul(-2, this.lumaM), this.lumaNS);\r\n this.$l.edgeVert1 = pb.add(pb.mul(-2, this.lumaM), this.lumaWE);\r\n this.$l.lumaNESE = pb.add(this.lumaNE, this.lumaSE);\r\n this.$l.lumaNWNE = pb.add(this.lumaNW, this.lumaNE);\r\n this.$l.edgeHorz2 = pb.add(pb.mul(-2, this.lumaE), this.lumaNESE);\r\n this.$l.edgeVert2 = pb.add(pb.mul(-2, this.lumaN), this.lumaNWNE);\r\n this.$l.lumaNWSW = pb.add(this.lumaNW, this.lumaSW);\r\n this.$l.lumaSWSE = pb.add(this.lumaSW, this.lumaSE);\r\n this.$l.edgeHorz4 = pb.add(pb.mul(pb.abs(this.edgeHorz1), 2), pb.abs(this.edgeHorz2));\r\n this.$l.edgeVert4 = pb.add(pb.mul(pb.abs(this.edgeVert1), 2), pb.abs(this.edgeVert2));\r\n this.$l.edgeHorz3 = pb.add(pb.mul(-2, this.lumaW), this.lumaNWSW);\r\n this.$l.edgeVert3 = pb.add(pb.mul(-2, this.lumaS), this.lumaSWSE);\r\n this.$l.edgeHorz = pb.add(pb.abs(this.edgeHorz3), this.edgeHorz4);\r\n this.$l.edgeVert = pb.add(pb.abs(this.edgeVert3), this.edgeVert4);\r\n this.$l.subpixNWSWNESE = pb.add(this.lumaNWSW, this.lumaNESE);\r\n this.$l.lengthSign = this.invTexSize.x;\r\n this.$l.horzSpan = pb.greaterThanEqual(this.edgeHorz, this.edgeVert);\r\n this.$l.subpixA = pb.add(pb.mul(this.subpixNSWE, 2), this.subpixNWSWNESE);\r\n this.$if(pb.not(this.horzSpan), function () {\r\n this.lumaN = this.lumaW;\r\n this.lumaS = this.lumaE;\r\n }).$else(function () {\r\n this.lengthSign = this.invTexSize.y;\r\n });\r\n this.$l.subpixB = pb.sub(pb.div(this.subpixA, 12), this.lumaM);\r\n this.$l.gradientN = pb.sub(this.lumaN, this.lumaM);\r\n this.$l.gradientS = pb.sub(this.lumaS, this.lumaM);\r\n this.$l.lumaNN = pb.add(this.lumaN, this.lumaM);\r\n this.$l.lumaSS = pb.add(this.lumaS, this.lumaM);\r\n this.$l.pairN = pb.greaterThanEqual(pb.abs(this.gradientN), pb.abs(this.gradientS));\r\n this.$l.gradient = pb.max(pb.abs(this.gradientN), pb.abs(this.gradientS));\r\n this.$if(this.pairN, function () {\r\n this.lengthSign = pb.neg(this.lengthSign);\r\n });\r\n this.$l.subpixC = pb.clamp(pb.mul(pb.abs(this.subpixB), this.subpixRcpRange), 0, 1);\r\n\r\n this.$l.posB = this.posM;\r\n this.$l.offNP = pb.vec2();\r\n this.$if(pb.not(this.horzSpan), function () {\r\n this.offNP.x = 0;\r\n this.offNP.y = this.invTexSize.y;\r\n this.posB.x = pb.add(this.posB.x, pb.mul(this.lengthSign, 0.5));\r\n }).$else(function () {\r\n this.offNP.x = this.invTexSize.x;\r\n this.offNP.y = 0;\r\n this.posB.y = pb.add(this.posB.y, pb.mul(this.lengthSign, 0.5));\r\n });\r\n this.$l.posN = pb.sub(this.posB, this.offNP);\r\n this.$l.posP = pb.add(this.posB, this.offNP);\r\n this.$l.subpixD = pb.add(pb.mul(-2, this.subpixC), 3);\r\n this.$l.lumaEndN = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posN, 0).rgb);\r\n this.$l.subpixE = pb.mul(this.subpixC, this.subpixC);\r\n this.$l.lumaEndP = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posP, 0).rgb);\r\n this.$if(pb.not(this.pairN), function () {\r\n this.lumaNN = this.lumaSS;\r\n });\r\n this.$l.gradientScaled = pb.div(this.gradient, 4);\r\n this.$l.lumaMM = pb.sub(this.lumaM, pb.mul(this.lumaNN, 0.5));\r\n this.$l.subpixF = pb.mul(this.subpixD, this.subpixE);\r\n this.$l.lumaMLTZero = pb.lessThan(this.lumaMM, 0);\r\n\r\n this.lumaEndN = pb.sub(this.lumaEndN, pb.mul(this.lumaNN, 0.5));\r\n this.lumaEndP = pb.sub(this.lumaEndP, pb.mul(this.lumaNN, 0.5));\r\n this.$l.doneN = pb.greaterThanEqual(pb.abs(this.lumaEndN), this.gradientScaled);\r\n this.$l.doneP = pb.greaterThanEqual(pb.abs(this.lumaEndP), this.gradientScaled);\r\n this.$if(pb.not(this.doneN), function () {\r\n this.posN = pb.sub(this.posN, pb.mul(this.offNP, 1.5));\r\n });\r\n this.$l.doneNP = pb.or(pb.not(this.doneN), pb.not(this.doneP));\r\n this.$if(pb.not(this.doneP), function () {\r\n this.posP = pb.add(this.posP, pb.mul(this.offNP, 1.5));\r\n });\r\n this.$if(this.doneNP, function () {\r\n this.$if(pb.not(this.doneN), function () {\r\n this.lumaEndN = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posN.xy, 0).rgb);\r\n this.lumaEndN = pb.sub(this.lumaEndN, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.$if(pb.not(this.doneP), function () {\r\n this.lumaEndP = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posP.xy, 0).rgb);\r\n this.lumaEndP = pb.sub(this.lumaEndP, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.doneN = pb.greaterThanEqual(pb.abs(this.lumaEndN), this.gradientScaled);\r\n this.doneP = pb.greaterThanEqual(pb.abs(this.lumaEndP), this.gradientScaled);\r\n this.$if(pb.not(this.doneN), function () {\r\n this.posN = pb.sub(this.posN, pb.mul(this.offNP, 2.0));\r\n });\r\n this.doneNP = pb.or(pb.not(this.doneN), pb.not(this.doneP));\r\n this.$if(pb.not(this.doneP), function () {\r\n this.posP = pb.add(this.posP, pb.mul(this.offNP, 2.0));\r\n });\r\n this.$if(this.doneNP, function () {\r\n this.$if(pb.not(this.doneN), function () {\r\n this.lumaEndN = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posN.xy, 0).rgb);\r\n this.lumaEndN = pb.sub(this.lumaEndN, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.$if(pb.not(this.doneP), function () {\r\n this.lumaEndP = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posP.xy, 0).rgb);\r\n this.lumaEndP = pb.sub(this.lumaEndP, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.doneN = pb.greaterThanEqual(pb.abs(this.lumaEndN), this.gradientScaled);\r\n this.doneP = pb.greaterThanEqual(pb.abs(this.lumaEndP), this.gradientScaled);\r\n this.$if(pb.not(this.doneN), function () {\r\n this.posN = pb.sub(this.posN, pb.mul(this.offNP, 2.0));\r\n });\r\n this.doneNP = pb.or(pb.not(this.doneN), pb.not(this.doneP));\r\n this.$if(pb.not(this.doneP), function () {\r\n this.posP = pb.add(this.posP, pb.mul(this.offNP, 2.0));\r\n });\r\n this.$if(this.doneNP, function () {\r\n this.$if(pb.not(this.doneN), function () {\r\n this.lumaEndN = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posN.xy, 0).rgb);\r\n this.lumaEndN = pb.sub(this.lumaEndN, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.$if(pb.not(this.doneP), function () {\r\n this.lumaEndP = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posP.xy, 0).rgb);\r\n this.lumaEndP = pb.sub(this.lumaEndP, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.doneN = pb.greaterThanEqual(pb.abs(this.lumaEndN), this.gradientScaled);\r\n this.doneP = pb.greaterThanEqual(pb.abs(this.lumaEndP), this.gradientScaled);\r\n this.$if(pb.not(this.doneN), function () {\r\n this.posN = pb.sub(this.posN, pb.mul(this.offNP, 4.0));\r\n });\r\n this.doneNP = pb.or(pb.not(this.doneN), pb.not(this.doneP));\r\n this.$if(pb.not(this.doneP), function () {\r\n this.posP = pb.add(this.posP, pb.mul(this.offNP, 4.0));\r\n });\r\n this.$if(this.doneNP, function () {\r\n this.$if(pb.not(this.doneN), function () {\r\n this.lumaEndN = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posN.xy, 0).rgb);\r\n this.lumaEndN = pb.sub(this.lumaEndN, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.$if(pb.not(this.doneP), function () {\r\n this.lumaEndP = this.getLuma(pb.textureSampleLevel(this.srcTex, this.posP.xy, 0).rgb);\r\n this.lumaEndP = pb.sub(this.lumaEndP, pb.mul(this.lumaNN, 0.5));\r\n });\r\n this.doneN = pb.greaterThanEqual(pb.abs(this.lumaEndN), this.gradientScaled);\r\n this.doneP = pb.greaterThanEqual(pb.abs(this.lumaEndP), this.gradientScaled);\r\n this.$if(pb.not(this.doneN), function () {\r\n this.posN = pb.sub(this.posN, pb.mul(this.offNP, 2.0));\r\n });\r\n this.$if(pb.not(this.doneP), function () {\r\n this.posP = pb.add(this.posP, pb.mul(this.offNP, 2.0));\r\n });\r\n });\r\n });\r\n });\r\n });\r\n this.$l.dstN = pb.sub(this.posM.x, this.posN.x);\r\n this.$l.dstP = pb.sub(this.posP.x, this.posM.x);\r\n this.$if(pb.not(this.horzSpan), function () {\r\n this.dstN = pb.sub(this.posM.y, this.posN.y);\r\n this.dstP = pb.sub(this.posP.y, this.posM.y);\r\n });\r\n\r\n this.$l.goodSpanN = pb.notEqual(pb.lessThan(this.lumaEndN, 0), this.lumaMLTZero);\r\n this.$l.spanLength = pb.add(this.dstP, this.dstN);\r\n this.$l.goodSpanP = pb.notEqual(pb.lessThan(this.lumaEndP, 0), this.lumaMLTZero);\r\n this.$l.spanLengthRcp = pb.div(1, this.spanLength);\r\n\r\n this.$l.directionN = pb.lessThan(this.dstN, this.dstP);\r\n this.$l.dst = pb.min(this.dstN, this.dstP);\r\n this.$l.goodSpan = this.$choice(this.directionN, this.goodSpanN, this.goodSpanP);\r\n this.$l.subpixG = pb.mul(this.subpixF, this.subpixF);\r\n this.$l.pixelOffset = pb.add(pb.mul(this.dst, pb.neg(this.spanLengthRcp)), 0.5);\r\n this.$l.subpixH = pb.mul(this.subpixG, 0.75);\r\n\r\n this.$l.pixelOffsetGood = this.$choice(this.goodSpan, this.pixelOffset, 0);\r\n this.$l.pixelOffsetSubpix = pb.max(this.pixelOffsetGood, this.subpixH);\r\n this.$if(pb.not(this.horzSpan), function () {\r\n this.posM.x = pb.add(this.posM.x, pb.mul(this.pixelOffsetSubpix, this.lengthSign));\r\n }).$else(function () {\r\n this.posM.y = pb.add(this.posM.y, pb.mul(this.pixelOffsetSubpix, this.lengthSign));\r\n });\r\n this.$return(pb.textureSampleLevel(this.srcTex, this.posM, 0).xyzw);\r\n });\r\n pb.main(function () {\r\n this.$l.color = this.FXAA(this.$inputs.uv);\r\n this.$if(pb.equal(this.srgbOut, 0), function () {\r\n this.$outputs.outColor = this.color;\r\n }).$else(function () {\r\n this.$outputs.outColor = pb.vec4(linearToGamma(this, this.color.rgb), this.color.a);\r\n });\r\n });\r\n }\r\n });\r\n FXAA._bindgroup = device.createBindGroup(FXAA._program.bindGroupLayouts[0]);\r\n }\r\n }\r\n}\r\n"],"names":["FXAA","AbstractPostEffect","_program","_bindgroup","_invTexSize","_layer","PostEffectLayer","transparent","Vector2","requireLinearDepthTexture","requireDepthAttachment","apply","ctx","inputColorTexture","sceneDepthTexture","srgbOutput","device","_prepare","setXY","width","height","setTexture","fetchSampler","setValue","needFlip","setProgram","setBindGroup","drawFullscreenQuad","buildRenderProgram","vertex","pb","flip","int","uniform","$inputs","pos","vec2","attrib","$outputs","uv","main","$builtins","position","vec4","add","mul","xy","$if","notEqual","y","neg","fragment","srcTex","tex2D","srgbOut","invTexSize","outColor","func","vec3","$return","dot","vSample","$l","posM","rgbyM","textureSampleLevel","lumaM","getLuma","rgb","lumaN","lumaW","lumaE","lumaS","rangeMin","min","rangeMax","max","range","sub","lessThan","div","lumaNW","lumaNE","lumaSW","lumaSE","lumaNS","lumaWE","subpixRcpRange","subpixNSWE","edgeHorz1","edgeVert1","lumaNESE","lumaNWNE","edgeHorz2","edgeVert2","lumaNWSW","lumaSWSE","edgeHorz4","abs","edgeVert4","edgeHorz3","edgeVert3","edgeHorz","edgeVert","subpixNWSWNESE","lengthSign","x","horzSpan","greaterThanEqual","subpixA","not","$else","subpixB","gradientN","gradientS","lumaNN","lumaSS","pairN","gradient","subpixC","clamp","posB","offNP","posN","posP","subpixD","lumaEndN","subpixE","lumaEndP","gradientScaled","lumaMM","subpixF","lumaMLTZero","doneN","doneP","doneNP","or","dstN","dstP","goodSpanN","spanLength","goodSpanP","spanLengthRcp","directionN","dst","goodSpan","$choice","subpixG","pixelOffset","subpixH","pixelOffsetGood","pixelOffsetSubpix","xyzw","color","equal","linearToGamma","a","createBindGroup","bindGroupLayouts"],"mappings":";;;;;AAOA;;;IAIO,MAAMA,IAAaC,SAAAA,kBAAAA,CAAAA;AACxB,IAAA,OAAeC,WAAuB,IAAK;AAC3C,IAAA,OAAeC,aAAwB,IAAK;IAC3BC,WAAqB;AACtC;;AAEC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAACC,MAAM,GAAGC,eAAAA,CAAgBC,WAAW;QACzC,IAAI,CAACH,WAAW,GAAG,IAAII,OAAAA,EAAAA;AACzB;AACA,sEACAC,yBAAqC,GAAA;QACnC,OAAO,KAAA;AACT;AACA,mEACAC,sBAAkC,GAAA;QAChC,OAAO,KAAA;AACT;kDAEAC,MAAMC,GAAgB,EAAEC,iBAA4B,EAAEC,iBAA4B,EAAEC,UAAmB,EAAE;QACvG,MAAMC,MAAAA,GAASJ,IAAII,MAAM;QACzB,IAAI,CAACC,QAAQ,CAACD,MAAAA,CAAAA;QACd,IAAI,CAACZ,WAAW,CAACc,KAAK,CAAC,CAAIL,GAAAA,iBAAAA,CAAkBM,KAAK,EAAE,CAAIN,GAAAA,iBAAAA,CAAkBO,MAAM,CAAA;AAChFpB,QAAAA,IAAAA,CAAKG,UAAU,CAACkB,UAAU,CAAC,QAAA,EAAUR,mBAAmBS,YAAa,CAAA,oBAAA,CAAA,CAAA;QACrEtB,IAAKG,CAAAA,UAAU,CAACoB,QAAQ,CAAC,MAAA,EAAQ,IAAI,CAACC,QAAQ,CAACR,MAAAA,CAAAA,GAAU,CAAI,GAAA,CAAA,CAAA;AAC7DhB,QAAAA,IAAAA,CAAKG,UAAU,CAACoB,QAAQ,CAAC,SA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1C,KAAK,CAAC,WAAA;4BACP,IAAI,CAACzE,QAAQ,CAACkB,QAAQ,GAAG1B,EAAGa,CAAAA,IAAI,CAACgH,aAAc,CAAA,IAAI,EAAE,IAAI,CAACF,KAAK,CAACrF,GAAG,GAAG,IAAI,CAACqF,KAAK,CAACG,CAAC,CAAA;AACpF,yBAAA,CAAA;AACF,qBAAA,CAAA;AACF;AACF,aAAA,CAAA;YACA5J,IAAKG,CAAAA,UAAU,GAAGa,MAAAA,CAAO6I,eAAe,CAAC7J,KAAKE,QAAQ,CAAC4J,gBAAgB,CAAC,CAAE,CAAA,CAAA;AAC5E;AACF;AACF;;;;"}
@@ -0,0 +1,69 @@
1
+ import { AbstractPostEffect, PostEffectLayer } from './posteffect.js';
2
+ import { linearToGamma } from '../shaders/misc.js';
3
+ import { fetchSampler } from '../utility/misc.js';
4
+
5
+ /**
6
+ * Grayscale post effect
7
+ * @public
8
+ */ class Grayscale extends AbstractPostEffect {
9
+ static _program = null;
10
+ static _bindgroup = null;
11
+ /**
12
+ * Creates an instance of grayscale post effect
13
+ */ constructor(){
14
+ super();
15
+ this._layer = PostEffectLayer.transparent;
16
+ }
17
+ /** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */ requireLinearDepthTexture() {
18
+ return false;
19
+ }
20
+ /** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */ requireDepthAttachment() {
21
+ return false;
22
+ }
23
+ /** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
24
+ const device = ctx.device;
25
+ this._prepare(device);
26
+ Grayscale._bindgroup.setTexture('srcTex', inputColorTexture, fetchSampler('clamp_nearest_nomip'));
27
+ Grayscale._bindgroup.setValue('flip', this.needFlip(device) ? 1 : 0);
28
+ Grayscale._bindgroup.setValue('srgbOut', srgbOutput ? 1 : 0);
29
+ device.setProgram(Grayscale._program);
30
+ device.setBindGroup(0, Grayscale._bindgroup);
31
+ this.drawFullscreenQuad();
32
+ }
33
+ /** @internal */ _prepare(device) {
34
+ if (!Grayscale._program) {
35
+ Grayscale._program = device.buildRenderProgram({
36
+ vertex (pb) {
37
+ this.flip = pb.int().uniform(0);
38
+ this.$inputs.pos = pb.vec2().attrib('position');
39
+ this.$outputs.uv = pb.vec2();
40
+ pb.main(function() {
41
+ this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
42
+ this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
43
+ this.$if(pb.notEqual(this.flip, 0), function() {
44
+ this.$builtins.position.y = pb.neg(this.$builtins.position.y);
45
+ });
46
+ });
47
+ },
48
+ fragment (pb) {
49
+ this.srcTex = pb.tex2D().sampleType('unfilterable-float').uniform(0);
50
+ this.srgbOut = pb.int().uniform(0);
51
+ this.$outputs.outColor = pb.vec4();
52
+ pb.main(function() {
53
+ this.$l.color = pb.textureSample(this.srcTex, this.$inputs.uv);
54
+ this.$l.grayscaleColor = pb.vec3(pb.dot(this.$l.color.rgb, pb.vec3(0.299, 0.587, 0.114)));
55
+ this.$if(pb.equal(this.srgbOut, 0), function() {
56
+ this.$outputs.outColor = pb.vec4(this.grayscaleColor, this.color.a);
57
+ }).$else(function() {
58
+ this.$outputs.outColor = pb.vec4(linearToGamma(this, this.grayscaleColor), this.color.a);
59
+ });
60
+ });
61
+ }
62
+ });
63
+ Grayscale._bindgroup = device.createBindGroup(Grayscale._program.bindGroupLayouts[0]);
64
+ }
65
+ }
66
+ }
67
+
68
+ export { Grayscale };
69
+ //# sourceMappingURL=grayscale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grayscale.js","sources":["../../../src/posteffect/grayscale.ts"],"sourcesContent":["import { AbstractPostEffect, PostEffectLayer } from './posteffect';\r\nimport { linearToGamma } from '../shaders/misc';\r\nimport type { AbstractDevice, BindGroup, GPUProgram, Texture2D } from '@zephyr3d/device';\r\nimport type { DrawContext } from '../render';\r\nimport { fetchSampler } from '../utility/misc';\r\n\r\n/**\r\n * Grayscale post effect\r\n * @public\r\n */\r\nexport class Grayscale extends AbstractPostEffect {\r\n private static _program: GPUProgram = null;\r\n private static _bindgroup: BindGroup = null;\r\n /**\r\n * Creates an instance of grayscale post effect\r\n */\r\n constructor() {\r\n super();\r\n this._layer = PostEffectLayer.transparent;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */\r\n requireLinearDepthTexture(): boolean {\r\n return false;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */\r\n requireDepthAttachment(): boolean {\r\n return false;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.apply} */\r\n apply(ctx: DrawContext, inputColorTexture: Texture2D, sceneDepthTexture: Texture2D, srgbOutput: boolean) {\r\n const device = ctx.device;\r\n this._prepare(device);\r\n Grayscale._bindgroup.setTexture('srcTex', inputColorTexture, fetchSampler('clamp_nearest_nomip'));\r\n Grayscale._bindgroup.setValue('flip', this.needFlip(device) ? 1 : 0);\r\n Grayscale._bindgroup.setValue('srgbOut', srgbOutput ? 1 : 0);\r\n device.setProgram(Grayscale._program);\r\n device.setBindGroup(0, Grayscale._bindgroup);\r\n this.drawFullscreenQuad();\r\n }\r\n /** @internal */\r\n private _prepare(device: AbstractDevice) {\r\n if (!Grayscale._program) {\r\n Grayscale._program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.flip = pb.int().uniform(0);\r\n this.$inputs.pos = pb.vec2().attrib('position');\r\n this.$outputs.uv = pb.vec2();\r\n pb.main(function () {\r\n this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);\r\n this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));\r\n this.$if(pb.notEqual(this.flip, 0), function () {\r\n this.$builtins.position.y = pb.neg(this.$builtins.position.y);\r\n });\r\n });\r\n },\r\n fragment(pb) {\r\n this.srcTex = pb.tex2D().sampleType('unfilterable-float').uniform(0);\r\n this.srgbOut = pb.int().uniform(0);\r\n this.$outputs.outColor = pb.vec4();\r\n pb.main(function () {\r\n this.$l.color = pb.textureSample(this.srcTex, this.$inputs.uv);\r\n this.$l.grayscaleColor = pb.vec3(pb.dot(this.$l.color.rgb, pb.vec3(0.299, 0.587, 0.114)));\r\n this.$if(pb.equal(this.srgbOut, 0), function () {\r\n this.$outputs.outColor = pb.vec4(this.grayscaleColor, this.color.a);\r\n }).$else(function () {\r\n this.$outputs.outColor = pb.vec4(linearToGamma(this, this.grayscaleColor), this.color.a);\r\n });\r\n });\r\n }\r\n });\r\n Grayscale._bindgroup = device.createBindGroup(Grayscale._program.bindGroupLayouts[0]);\r\n }\r\n }\r\n}\r\n"],"names":["Grayscale","AbstractPostEffect","_program","_bindgroup","_layer","PostEffectLayer","transparent","requireLinearDepthTexture","requireDepthAttachment","apply","ctx","inputColorTexture","sceneDepthTexture","srgbOutput","device","_prepare","setTexture","fetchSampler","setValue","needFlip","setProgram","setBindGroup","drawFullscreenQuad","buildRenderProgram","vertex","pb","flip","int","uniform","$inputs","pos","vec2","attrib","$outputs","uv","main","$builtins","position","vec4","add","mul","xy","$if","notEqual","y","neg","fragment","srcTex","tex2D","sampleType","srgbOut","outColor","$l","color","textureSample","grayscaleColor","vec3","dot","rgb","equal","a","$else","linearToGamma","createBindGroup","bindGroupLayouts"],"mappings":";;;;AAMA;;;IAIO,MAAMA,SAAkBC,SAAAA,kBAAAA,CAAAA;AAC7B,IAAA,OAAeC,WAAuB,IAAK;AAC3C,IAAA,OAAeC,aAAwB,IAAK;AAC5C;;AAEC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAACC,MAAM,GAAGC,eAAAA,CAAgBC,WAAW;AAC3C;AACA,sEACAC,yBAAqC,GAAA;QACnC,OAAO,KAAA;AACT;AACA,mEACAC,sBAAkC,GAAA;QAChC,OAAO,KAAA;AACT;kDAEAC,MAAMC,GAAgB,EAAEC,iBAA4B,EAAEC,iBAA4B,EAAEC,UAAmB,EAAE;QACvG,MAAMC,MAAAA,GAAS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AC,KAAA,EAAO,KAAO,EAAA,KAAA,CAAA,CAAA,CAAA;wBACjF,IAAI,CAACd,GAAG,CAACjB,EAAGkC,CAAAA,KAAK,CAAC,IAAI,CAACT,OAAO,EAAE,CAAI,CAAA,EAAA,WAAA;AAClC,4BAAA,IAAI,CAACjB,QAAQ,CAACkB,QAAQ,GAAG1B,GAAGa,IAAI,CAAC,IAAI,CAACiB,cAAc,EAAE,IAAI,CAACF,KAAK,CAACO,CAAC,CAAA;AACpE,yBAAA,CAAA,CAAGC,KAAK,CAAC,WAAA;AACP,4BAAA,IAAI,CAAC5B,QAAQ,CAACkB,QAAQ,GAAG1B,EAAAA,CAAGa,IAAI,CAACwB,aAAAA,CAAc,IAAI,EAAE,IAAI,CAACP,cAAc,CAAA,EAAG,IAAI,CAACF,KAAK,CAACO,CAAC,CAAA;AACzF,yBAAA,CAAA;AACF,qBAAA,CAAA;AACF;AACF,aAAA,CAAA;YACA5D,SAAUG,CAAAA,UAAU,GAAGW,MAAAA,CAAOiD,eAAe,CAAC/D,UAAUE,QAAQ,CAAC8D,gBAAgB,CAAC,CAAE,CAAA,CAAA;AACtF;AACF;AACF;;;;"}
@@ -0,0 +1,96 @@
1
+ import { AbstractPostEffect, PostEffectLayer } from './posteffect.js';
2
+ import { linearToGamma } from '../shaders/misc.js';
3
+ import { fetchSampler } from '../utility/misc.js';
4
+
5
+ /**
6
+ * The motion blur post effect
7
+ * @public
8
+ */ class MotionBlur extends AbstractPostEffect {
9
+ static _programMotionBlur = null;
10
+ static _bindgroupMotionBlur = null;
11
+ /** @internal */ _intensity;
12
+ /**
13
+ * Creates an instance of tonemap post effect
14
+ */ constructor(){
15
+ super();
16
+ this._intensity = 1;
17
+ this._layer = PostEffectLayer.transparent;
18
+ }
19
+ /** Motion blur strength */ get strength() {
20
+ return this._intensity;
21
+ }
22
+ set strength(val) {
23
+ this._intensity = val;
24
+ }
25
+ /** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */ requireLinearDepthTexture() {
26
+ return false;
27
+ }
28
+ /** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */ requireDepthAttachment() {
29
+ return false;
30
+ }
31
+ /** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
32
+ const device = ctx.device;
33
+ this._prepare(device);
34
+ MotionBlur._bindgroupMotionBlur.setTexture('inputTexture', inputColorTexture, fetchSampler('clamp_nearest_nomip'));
35
+ MotionBlur._bindgroupMotionBlur.setTexture('motionVectorTexture', ctx.motionVectorTexture, fetchSampler('clamp_nearest_nomip'));
36
+ MotionBlur._bindgroupMotionBlur.setValue('flip', this.needFlip(device) ? 1 : 0);
37
+ MotionBlur._bindgroupMotionBlur.setValue('srgbOut', srgbOutput ? 1 : 0);
38
+ MotionBlur._bindgroupMotionBlur.setValue('frameDeltaTime', device.frameInfo.elapsedFrame * 0.001);
39
+ MotionBlur._bindgroupMotionBlur.setValue('intensity', this._intensity);
40
+ device.setProgram(MotionBlur._programMotionBlur);
41
+ device.setBindGroup(0, MotionBlur._bindgroupMotionBlur);
42
+ this.drawFullscreenQuad();
43
+ }
44
+ /** @internal */ _prepare(device) {
45
+ if (!MotionBlur._programMotionBlur) {
46
+ MotionBlur._programMotionBlur = device.buildRenderProgram({
47
+ vertex (pb) {
48
+ this.flip = pb.int().uniform(0);
49
+ this.$inputs.pos = pb.vec2().attrib('position');
50
+ this.$outputs.uv = pb.vec2();
51
+ pb.main(function() {
52
+ this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
53
+ this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
54
+ this.$if(pb.notEqual(this.flip, 0), function() {
55
+ this.$builtins.position.y = pb.neg(this.$builtins.position.y);
56
+ });
57
+ });
58
+ },
59
+ fragment (pb) {
60
+ this.srgbOut = pb.int().uniform(0);
61
+ this.frameDeltaTime = pb.float().uniform(0);
62
+ this.inputTexture = pb.tex2D().uniform(0);
63
+ this.motionVectorTexture = pb.tex2D().uniform(0);
64
+ this.intensity = pb.float().uniform(0);
65
+ this.$outputs.outColor = pb.vec4();
66
+ pb.main(function() {
67
+ this.$l.color = pb.vec3();
68
+ this.$l.velocity = pb.textureSampleLevel(this.motionVectorTexture, this.$inputs.uv, 0).xy;
69
+ this.$l.sourceSample = pb.textureSampleLevel(this.inputTexture, this.$inputs.uv, 0);
70
+ this.$l.color = this.sourceSample.rgb;
71
+ this.$if(pb.greaterThan(pb.dot(this.velocity, this.velocity), 1e-7), function() {
72
+ this.velocity = pb.mul(this.velocity, this.intensity, 0.5);
73
+ this.velocity = pb.mul(this.velocity, pb.div(0.01, this.frameDeltaTime));
74
+ this.$l.uv0 = pb.clamp(pb.sub(this.$inputs.uv, this.velocity), pb.vec2(0), pb.vec2(1));
75
+ this.$l.uv1 = pb.clamp(pb.add(this.$inputs.uv, this.velocity), pb.vec2(0), pb.vec2(1));
76
+ const NUM_SAMPLES = 16;
77
+ this.$for(pb.float('i'), 0, NUM_SAMPLES, function() {
78
+ this.color = pb.add(this.color, pb.textureSampleLevel(this.inputTexture, pb.mix(this.uv0, this.uv1, pb.mul(this.i, 1 / (NUM_SAMPLES - 1))), 0).rgb);
79
+ });
80
+ this.color = pb.mul(this.color, 1 / (NUM_SAMPLES + 1));
81
+ });
82
+ //this.color = pb.vec3(this.velocity, 0);
83
+ this.$if(pb.notEqual(this.srgbOut, 0), function() {
84
+ this.$l.color = linearToGamma(this, this.color);
85
+ });
86
+ this.$outputs.outColor = pb.vec4(this.color, this.sourceSample.a);
87
+ });
88
+ }
89
+ });
90
+ MotionBlur._bindgroupMotionBlur = device.createBindGroup(MotionBlur._programMotionBlur.bindGroupLayouts[0]);
91
+ }
92
+ }
93
+ }
94
+
95
+ export { MotionBlur };
96
+ //# sourceMappingURL=motionblur.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motionblur.js","sources":["../../../src/posteffect/motionblur.ts"],"sourcesContent":["import { AbstractPostEffect, PostEffectLayer } from './posteffect';\r\nimport { linearToGamma } from '../shaders/misc';\r\nimport type { AbstractDevice, BindGroup, GPUProgram, Texture2D } from '@zephyr3d/device';\r\nimport type { DrawContext } from '../render';\r\nimport { fetchSampler } from '../utility/misc';\r\n\r\n/**\r\n * The motion blur post effect\r\n * @public\r\n */\r\nexport class MotionBlur extends AbstractPostEffect {\r\n private static _programMotionBlur: GPUProgram = null;\r\n private static _bindgroupMotionBlur: BindGroup = null;\r\n /** @internal */\r\n private _intensity: number;\r\n /**\r\n * Creates an instance of tonemap post effect\r\n */\r\n constructor() {\r\n super();\r\n this._intensity = 1;\r\n this._layer = PostEffectLayer.transparent;\r\n }\r\n /** Motion blur strength */\r\n get strength() {\r\n return this._intensity;\r\n }\r\n set strength(val: number) {\r\n this._intensity = val;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */\r\n requireLinearDepthTexture(): boolean {\r\n return false;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */\r\n requireDepthAttachment(): boolean {\r\n return false;\r\n }\r\n /** {@inheritDoc AbstractPostEffect.apply} */\r\n apply(ctx: DrawContext, inputColorTexture: Texture2D, sceneDepthTexture: Texture2D, srgbOutput: boolean) {\r\n const device = ctx.device;\r\n this._prepare(device);\r\n MotionBlur._bindgroupMotionBlur.setTexture(\r\n 'inputTexture',\r\n inputColorTexture,\r\n fetchSampler('clamp_nearest_nomip')\r\n );\r\n MotionBlur._bindgroupMotionBlur.setTexture(\r\n 'motionVectorTexture',\r\n ctx.motionVectorTexture,\r\n fetchSampler('clamp_nearest_nomip')\r\n );\r\n MotionBlur._bindgroupMotionBlur.setValue('flip', this.needFlip(device) ? 1 : 0);\r\n MotionBlur._bindgroupMotionBlur.setValue('srgbOut', srgbOutput ? 1 : 0);\r\n MotionBlur._bindgroupMotionBlur.setValue('frameDeltaTime', device.frameInfo.elapsedFrame * 0.001);\r\n MotionBlur._bindgroupMotionBlur.setValue('intensity', this._intensity);\r\n device.setProgram(MotionBlur._programMotionBlur);\r\n device.setBindGroup(0, MotionBlur._bindgroupMotionBlur);\r\n this.drawFullscreenQuad();\r\n }\r\n /** @internal */\r\n private _prepare(device: AbstractDevice) {\r\n if (!MotionBlur._programMotionBlur) {\r\n MotionBlur._programMotionBlur = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.flip = pb.int().uniform(0);\r\n this.$inputs.pos = pb.vec2().attrib('position');\r\n this.$outputs.uv = pb.vec2();\r\n pb.main(function () {\r\n this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);\r\n this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));\r\n this.$if(pb.notEqual(this.flip, 0), function () {\r\n this.$builtins.position.y = pb.neg(this.$builtins.position.y);\r\n });\r\n });\r\n },\r\n fragment(pb) {\r\n this.srgbOut = pb.int().uniform(0);\r\n this.frameDeltaTime = pb.float().uniform(0);\r\n this.inputTexture = pb.tex2D().uniform(0);\r\n this.motionVectorTexture = pb.tex2D().uniform(0);\r\n this.intensity = pb.float().uniform(0);\r\n this.$outputs.outColor = pb.vec4();\r\n pb.main(function () {\r\n this.$l.color = pb.vec3();\r\n this.$l.velocity = pb.textureSampleLevel(this.motionVectorTexture, this.$inputs.uv, 0).xy;\r\n this.$l.sourceSample = pb.textureSampleLevel(this.inputTexture, this.$inputs.uv, 0);\r\n this.$l.color = this.sourceSample.rgb;\r\n this.$if(pb.greaterThan(pb.dot(this.velocity, this.velocity), 1e-7), function () {\r\n this.velocity = pb.mul(this.velocity, this.intensity, 0.5);\r\n this.velocity = pb.mul(this.velocity, pb.div(0.01, this.frameDeltaTime));\r\n this.$l.uv0 = pb.clamp(pb.sub(this.$inputs.uv, this.velocity), pb.vec2(0), pb.vec2(1));\r\n this.$l.uv1 = pb.clamp(pb.add(this.$inputs.uv, this.velocity), pb.vec2(0), pb.vec2(1));\r\n const NUM_SAMPLES = 16;\r\n this.$for(pb.float('i'), 0, NUM_SAMPLES, function () {\r\n this.color = pb.add(\r\n this.color,\r\n pb.textureSampleLevel(\r\n this.inputTexture,\r\n pb.mix(this.uv0, this.uv1, pb.mul(this.i, 1 / (NUM_SAMPLES - 1))),\r\n 0\r\n ).rgb\r\n );\r\n });\r\n this.color = pb.mul(this.color, 1 / (NUM_SAMPLES + 1));\r\n });\r\n //this.color = pb.vec3(this.velocity, 0);\r\n this.$if(pb.notEqual(this.srgbOut, 0), function () {\r\n this.$l.color = linearToGamma(this, this.color);\r\n });\r\n this.$outputs.outColor = pb.vec4(this.color, this.sourceSample.a);\r\n });\r\n }\r\n });\r\n MotionBlur._bindgroupMotionBlur = device.createBindGroup(\r\n MotionBlur._programMotionBlur.bindGroupLayouts[0]\r\n );\r\n }\r\n }\r\n}\r\n"],"names":["MotionBlur","AbstractPostEffect","_programMotionBlur","_bindgroupMotionBlur","_intensity","_layer","PostEffectLayer","transparent","strength","val","requireLinearDepthTexture","requireDepthAttachment","apply","ctx","inputColorTexture","sceneDepthTexture","srgbOutput","device","_prepare","setTexture","fetchSampler","motionVectorTexture","setValue","needFlip","frameInfo","elapsedFrame","setProgram","setBindGroup","drawFullscreenQuad","buildRenderProgram","vertex","pb","flip","int","uniform","$inputs","pos","vec2","attrib","$outputs","uv","main","$builtins","position","vec4","add","mul","xy","$if","notEqual","y","neg","fragment","srgbOut","frameDeltaTime","float","inputTexture","tex2D","intensity","outColor","$l","color","vec3","velocity","textureSampleLevel","sourceSample","rgb","greaterThan","dot","div","uv0","clamp","sub","uv1","NUM_SAMPLES","$for","mix","i","linearToGamma","a","createBindGroup","bindGroupLayouts"],"mappings":";;;;AAMA;;;IAIO,MAAMA,UAAmBC,SAAAA,kBAAAA,CAAAA;AAC9B,IAAA,OAAeC,qBAAiC,IAAK;AACrD,IAAA,OAAeC,uBAAkC,IAAK;qBAEtD,UAA2B;AAC3B;;AAEC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;QACL,IAAI,CAACC,UAAU,GAAG,CAAA;AAClB,QAAA,IAAI,CAACC,M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1C,GAAGe,GAAG,CAAC,IAAI,CAAC+B,CAAC,EAAE,CAAKH,IAAAA,cAAc,CAAA,CAAA,CAAA,CAAA,EAC7D,GACAR,GAAG,CAAA;AAET,6BAAA,CAAA;AACA,4BAAA,IAAI,CAACL,KAAK,GAAG9B,EAAAA,CAAGe,GAAG,CAAC,IAAI,CAACe,KAAK,EAAE,CAAKa,IAAAA,cAAc,CAAA,CAAA,CAAA;AACrD,yBAAA,CAAA;;wBAEA,IAAI,CAAC1B,GAAG,CAACjB,EAAGkB,CAAAA,QAAQ,CAAC,IAAI,CAACI,OAAO,EAAE,CAAI,CAAA,EAAA,WAAA;4BACrC,IAAI,CAACO,EAAE,CAACC,KAAK,GAAGiB,cAAc,IAAI,EAAE,IAAI,CAACjB,KAAK,CAAA;AAChD,yBAAA,CAAA;AACA,wBAAA,IAAI,CAACtB,QAAQ,CAACoB,QAAQ,GAAG5B,GAAGa,IAAI,CAAC,IAAI,CAACiB,KAAK,EAAE,IAAI,CAACI,YAAY,CAACc,CAAC,CAAA;AAClE,qBAAA,CAAA;AACF;AACF,aAAA,CAAA;YACA/E,UAAWG,CAAAA,oBAAoB,GAAGc,MAAAA,CAAO+D,eAAe,CACtDhF,WAAWE,kBAAkB,CAAC+E,gBAAgB,CAAC,CAAE,CAAA,CAAA;AAErD;AACF;AACF;;;;"}
@@ -0,0 +1,126 @@
1
+ import { drawFullscreenQuad } from '../render/fullscreenquad.js';
2
+ import { copyTexture, fetchSampler } from '../utility/misc.js';
3
+ import { Disposable } from '@zephyr3d/base';
4
+
5
+ /**
6
+ * Rendering layer of post processing effects
7
+ * @public
8
+ *
9
+ */ var PostEffectLayer = /*#__PURE__*/ function(PostEffectLayer) {
10
+ PostEffectLayer[PostEffectLayer["opaque"] = 0] = "opaque";
11
+ PostEffectLayer[PostEffectLayer["transparent"] = 1] = "transparent";
12
+ PostEffectLayer[PostEffectLayer["end"] = 2] = "end";
13
+ return PostEffectLayer;
14
+ }({});
15
+ /**
16
+ * Base class for any type of post effect
17
+ * @public
18
+ */ class AbstractPostEffect extends Disposable {
19
+ static _defaultRenderStates = {};
20
+ _enabled;
21
+ _layer;
22
+ /**
23
+ * Creates an instance of a post effect
24
+ * @param name - Name of the post effect
25
+ */ constructor(){
26
+ super();
27
+ this._enabled = true;
28
+ this._layer = 2;
29
+ }
30
+ /** Whether this post effect is enabled */ get enabled() {
31
+ return this._enabled;
32
+ }
33
+ set enabled(val) {
34
+ this._enabled = !!val;
35
+ }
36
+ /** Whether this post effect will be rendered at opaque phase */ get layer() {
37
+ return this._layer;
38
+ }
39
+ /**
40
+ * Check if the post effect should be rendered upside down.
41
+ * @param device - The device object
42
+ * @returns true if the post effect should be rendered upside down
43
+ */ needFlip(device) {
44
+ return device.type === 'webgpu' && !!device.getFramebuffer();
45
+ }
46
+ /**
47
+ * Checks whether this post effect requires the linear depth texture
48
+ * @returns true if the linear depth texture is required.
49
+ */ requireLinearDepthTexture(_ctx) {
50
+ return false;
51
+ }
52
+ /**
53
+ * Checks whether this post effect requires the scene depth buffer
54
+ * @returns true if the scene depth buffer is required.
55
+ */ requireDepthAttachment(_ctx) {
56
+ return false;
57
+ }
58
+ /**
59
+ * Apply the post effect
60
+ * @param camera - Camera used the render the scene
61
+ * @param inputColorTexture - The previous scene color texture
62
+ * @param sceneDepthTexture - The linear scene depth texture
63
+ * @param srgbOutput - Whether the result should be gamma corrected
64
+ *
65
+ * @remarks
66
+ * The frame buffer of the post effect is already set when apply() is called.
67
+ */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
68
+ this.passThrough(ctx, inputColorTexture, srgbOutput);
69
+ }
70
+ /**
71
+ *
72
+ * @param ctx - Draw context
73
+ * @param inputColorTexture - Input color texture
74
+ * @param srgbOutput - Whether the result should be gamma corrected
75
+ */ passThrough(ctx, inputColorTexture, srgbOutput, renderStates) {
76
+ copyTexture(inputColorTexture, ctx.device.getFramebuffer(), fetchSampler('clamp_nearest_nomip'), renderStates, 0, srgbOutput);
77
+ }
78
+ /**
79
+ * Draws a fullscreen quad
80
+ * @param renderStateSet - Render states that will be used when drawing the fullscreen quad.
81
+ */ drawFullscreenQuad(renderStateSet) {
82
+ drawFullscreenQuad(renderStateSet);
83
+ }
84
+ /** @internal */ createVertexLayout(device) {
85
+ return device.createVertexLayout({
86
+ vertexBuffers: [
87
+ {
88
+ buffer: device.createVertexBuffer('position_f32x2', new Float32Array([
89
+ -1,
90
+ -1,
91
+ 1,
92
+ -1,
93
+ -1,
94
+ 1,
95
+ 1,
96
+ 1
97
+ ]))
98
+ }
99
+ ]
100
+ });
101
+ }
102
+ onDispose() {
103
+ super.onDispose();
104
+ this.destroy();
105
+ }
106
+ /** @internal */ createRenderStates(device) {
107
+ const renderStates = device.createRenderStateSet();
108
+ renderStates.useRasterizerState().setCullMode('none');
109
+ renderStates.useDepthState().enableTest(false).enableWrite(false);
110
+ return renderStates;
111
+ }
112
+ /** @internal */ destroy() {}
113
+ /** @internal */ static getDefaultRenderState(ctx, compareFunc) {
114
+ let renderState = this._defaultRenderStates[compareFunc];
115
+ if (!renderState) {
116
+ renderState = ctx.device.createRenderStateSet();
117
+ renderState.useRasterizerState().setCullMode('none');
118
+ renderState.useDepthState().enableTest(compareFunc !== 'always').enableWrite(false).setCompareFunc(compareFunc);
119
+ this._defaultRenderStates[compareFunc] = renderState;
120
+ }
121
+ return renderState;
122
+ }
123
+ }
124
+
125
+ export { AbstractPostEffect, PostEffectLayer };
126
+ //# sourceMappingURL=posteffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posteffect.js","sources":["../../../src/posteffect/posteffect.ts"],"sourcesContent":["import type { AbstractDevice, CompareFunc, RenderStateSet, Texture2D, VertexLayout } from '@zephyr3d/device';\r\nimport type { DrawContext } from '../render';\r\nimport { drawFullscreenQuad } from '../render/fullscreenquad';\r\nimport { copyTexture, fetchSampler } from '../utility/misc';\r\nimport { Disposable } from '@zephyr3d/base';\r\n\r\n/**\r\n * Rendering layer of post processing effects\r\n * @public\r\n *\r\n */\r\nexport enum PostEffectLayer {\r\n opaque = 0,\r\n transparent = 1,\r\n end = 2\r\n}\r\n\r\n/**\r\n * Base class for any type of post effect\r\n * @public\r\n */\r\nexport class AbstractPostEffect extends Disposable {\r\n private static _defaultRenderStates: { CompareFunc?: RenderStateSet } = {};\r\n protected _enabled: boolean;\r\n protected _layer: PostEffectLayer;\r\n /**\r\n * Creates an instance of a post effect\r\n * @param name - Name of the post effect\r\n */\r\n constructor() {\r\n super();\r\n this._enabled = true;\r\n this._layer = PostEffectLayer.end;\r\n }\r\n /** Whether this post effect is enabled */\r\n get enabled(): boolean {\r\n return this._enabled;\r\n }\r\n set enabled(val: boolean) {\r\n this._enabled = !!val;\r\n }\r\n /** Whether this post effect will be rendered at opaque phase */\r\n get layer(): PostEffectLayer {\r\n return this._layer;\r\n }\r\n /**\r\n * Check if the post effect should be rendered upside down.\r\n * @param device - The device object\r\n * @returns true if the post effect should be rendered upside down\r\n */\r\n needFlip(device: AbstractDevice): boolean {\r\n return device.type === 'webgpu' && !!device.getFramebuffer();\r\n }\r\n /**\r\n * Checks whether this post effect requires the linear depth texture\r\n * @returns true if the linear depth texture is required.\r\n */\r\n requireLinearDepthTexture(_ctx: DrawContext): boolean {\r\n return false;\r\n }\r\n /**\r\n * Checks whether this post effect requires the scene depth buffer\r\n * @returns true if the scene depth buffer is required.\r\n */\r\n requireDepthAttachment(_ctx: DrawContext): boolean {\r\n return false;\r\n }\r\n /**\r\n * Apply the post effect\r\n * @param camera - Camera used the render the scene\r\n * @param inputColorTexture - The previous scene color texture\r\n * @param sceneDepthTexture - The linear scene depth texture\r\n * @param srgbOutput - Whether the result should be gamma corrected\r\n *\r\n * @remarks\r\n * The frame buffer of the post effect is already set when apply() is called.\r\n */\r\n apply(\r\n ctx: DrawContext,\r\n inputColorTexture: Texture2D,\r\n sceneDepthTexture: Texture2D,\r\n srgbOutput: boolean\r\n ): void {\r\n this.passThrough(ctx, inputColorTexture, srgbOutput);\r\n }\r\n /**\r\n *\r\n * @param ctx - Draw context\r\n * @param inputColorTexture - Input color texture\r\n * @param srgbOutput - Whether the result should be gamma corrected\r\n */\r\n protected passThrough(\r\n ctx: DrawContext,\r\n inputColorTexture: Texture2D,\r\n srgbOutput: boolean,\r\n renderStates?: RenderStateSet\r\n ) {\r\n copyTexture(\r\n inputColorTexture,\r\n ctx.device.getFramebuffer(),\r\n fetchSampler('clamp_nearest_nomip'),\r\n renderStates,\r\n 0,\r\n srgbOutput\r\n );\r\n }\r\n /**\r\n * Draws a fullscreen quad\r\n * @param renderStateSet - Render states that will be used when drawing the fullscreen quad.\r\n */\r\n protected drawFullscreenQuad(renderStateSet?: RenderStateSet) {\r\n drawFullscreenQuad(renderStateSet);\r\n }\r\n /** @internal */\r\n protected createVertexLayout(device: AbstractDevice): VertexLayout {\r\n return device.createVertexLayout({\r\n vertexBuffers: [\r\n {\r\n buffer: device.createVertexBuffer('position_f32x2', new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]))\r\n }\r\n ]\r\n });\r\n }\r\n protected onDispose() {\r\n super.onDispose();\r\n this.destroy();\r\n }\r\n /** @internal */\r\n protected createRenderStates(device: AbstractDevice): RenderStateSet {\r\n const renderStates = device.createRenderStateSet();\r\n renderStates.useRasterizerState().setCullMode('none');\r\n renderStates.useDepthState().enableTest(false).enableWrite(false);\r\n return renderStates;\r\n }\r\n /** @internal */\r\n protected destroy() {}\r\n /** @internal */\r\n static getDefaultRenderState(ctx: DrawContext, compareFunc: CompareFunc) {\r\n let renderState = this._defaultRenderStates[compareFunc];\r\n if (!renderState) {\r\n renderState = ctx.device.createRenderStateSet();\r\n renderState.useRasterizerState().setCullMode('none');\r\n renderState\r\n .useDepthState()\r\n .enableTest(compareFunc !== 'always')\r\n .enableWrite(false)\r\n .setCompareFunc(compareFunc);\r\n this._defaultRenderStates[compareFunc] = renderState;\r\n }\r\n return renderState;\r\n }\r\n}\r\n"],"names":["PostEffectLayer","AbstractPostEffect","Disposable","_defaultRenderStates","_enabled","_layer","enabled","val","layer","needFlip","device","type","getFramebuffer","requireLinearDepthTexture","_ctx","requireDepthAttachment","apply","ctx","inputColorTexture","sceneDepthTexture","srgbOutput","passThrough","renderStates","copyTexture","fetchSampler","drawFullscreenQuad","renderStateSet","createVertexLayout","vertexBuffers","buffer","createVertexBuffer","Float32Array","onDispose","destroy","createRenderStates","createRenderStateSet","useRasterizerState","setCullMode","useDepthState","enableTest","enableWrite","getDefaultRenderState","compareFunc","renderState","setCompareFunc"],"mappings":";;;;AAMA;;;;IAKO,IAAKA,eAAAA,iBAAAA,SAAAA,eAAAA,EAAAA;;;;AAAAA,IAAAA,OAAAA,eAAAA;AAIX,CAAA,CAAA,EAAA;AAED;;;IAIO,MAAMC,kBAA2BC,SAAAA,UAAAA,CAAAA;IACtC,OAAeC,oBAAAA,GAAyD,EAAG;IACjEC,QAAkB;IAClBC,MAAwB;AAClC;;;AAGC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;QACL,IAAI,CAACD,QAAQ,GAAG,IAAA;AAChB,QAAA,IAAI,CAACC,MAAM,GAAA,CAAA;AACb;+CAEA,IAAIC,OAAmB,GAAA;QACrB,OAAO,IAAI,CAACF,QAAQ;AACtB;IACA,IAAIE,OAAAA,CAAQC,GAAY,EAAE;AACxB,QAAA,IAAI,CAACH,QAAQ,GAAG,CAAC,CAACG,GAAAA;AACpB;qEAEA,IAAIC,KAAyB,GAAA;QAC3B,OAAO,IAAI,CAACH,MAAM;AACpB;AACA;;;;MAKAI,QAAAA,CAASC,MAAsB,EAAW;AACxC,QAAA,OAAOA,OAAOC,IAAI,KAAK,YAAY,CAAC,CAACD,OAAOE,cAAc,EAAA;AAC5D;AACA;;;MAIAC,yBAAAA,CAA0BC,IAAiB,EAAW;QACpD,OAAO,KAAA;AACT;AACA;;;MAIAC,sBAAAA,CAAuBD,IAAiB,EAAW;QACjD,OAAO,KAAA;AACT;AACA;;;;;;;;;MAUAE,KAAAA,CACEC,GAAgB,EAChBC,iBAA4B,EAC5BC,iB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