@zephyr3d/scene 0.9.2 → 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 (420) hide show
  1. package/dist/animation/animationset.js +135 -135
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/ik/ik_chain_builder.js +68 -0
  4. package/dist/animation/ik/ik_chain_builder.js.map +1 -0
  5. package/dist/animation/ik/ik_pole_constraint.js +2 -7
  6. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  7. package/dist/animation/joint_dynamics/controller.js +146 -146
  8. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  9. package/dist/animation/joint_dynamics/math.js +16 -0
  10. package/dist/animation/joint_dynamics/math.js.map +1 -0
  11. package/dist/animation/spring/spring_particle.js +4 -4
  12. package/dist/animation/spring/spring_particle.js.map +1 -1
  13. package/dist/animation/spring/spring_system.js +75 -75
  14. package/dist/animation/spring/spring_system.js.map +1 -1
  15. package/dist/animation/spring2/constraints.js.map +1 -1
  16. package/dist/animation/spring2/controller.js +64 -64
  17. package/dist/animation/spring2/controller.js.map +1 -1
  18. package/dist/animation/spring2/math.js.map +1 -1
  19. package/dist/animation/spring2/spring_system.js +8 -8
  20. package/dist/animation/spring2/spring_system.js.map +1 -1
  21. package/dist/asset/model.js +57 -57
  22. package/dist/asset/model.js.map +1 -1
  23. package/dist/camera/camera.js +184 -184
  24. package/dist/camera/camera.js.map +1 -1
  25. package/dist/index.d.ts +2 -6
  26. package/dist/index.js +1 -1
  27. package/dist/material/material.js +288 -288
  28. package/dist/material/material.js.map +1 -1
  29. package/dist/material/shader/helper.js +281 -278
  30. package/dist/material/shader/helper.js.map +1 -1
  31. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  32. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  33. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  34. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  35. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  36. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  37. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  38. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  39. package/dist/render/cluster_light.js +3 -4
  40. package/dist/render/cluster_light.js.map +1 -1
  41. package/dist/render/rendergraph/history_resource_manager.js +93 -93
  42. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  43. package/dist/render/rendergraph/history_resources.js +3 -3
  44. package/dist/render/rendergraph/history_resources.js.map +1 -1
  45. package/dist/render/rendergraph/types.js +22 -22
  46. package/dist/render/rendergraph/types.js.map +1 -1
  47. package/dist/scene/mesh.js +80 -80
  48. package/dist/scene/mesh.js.map +1 -1
  49. package/dist/scene/scene_node.js +228 -228
  50. package/dist/scene/scene_node.js.map +1 -1
  51. package/dist/shapes/torus.js +90 -59
  52. package/dist/shapes/torus.js.map +1 -1
  53. package/dist/src/animation/animation.js +127 -0
  54. package/dist/src/animation/animation.js.map +1 -0
  55. package/dist/src/animation/animationset.js +255 -0
  56. package/dist/src/animation/animationset.js.map +1 -0
  57. package/dist/src/animation/animationtrack.js +34 -0
  58. package/dist/src/animation/animationtrack.js.map +1 -0
  59. package/dist/src/animation/eulerrotationtrack.js +52 -0
  60. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  61. package/dist/src/animation/morphtarget.js +93 -0
  62. package/dist/src/animation/morphtarget.js.map +1 -0
  63. package/dist/src/animation/morphtrack.js +70 -0
  64. package/dist/src/animation/morphtrack.js.map +1 -0
  65. package/dist/src/animation/proptrack.js +161 -0
  66. package/dist/src/animation/proptrack.js.map +1 -0
  67. package/dist/src/animation/rotationtrack.js +51 -0
  68. package/dist/src/animation/rotationtrack.js.map +1 -0
  69. package/dist/src/animation/scaletrack.js +50 -0
  70. package/dist/src/animation/scaletrack.js.map +1 -0
  71. package/dist/src/animation/skeleton.js +204 -0
  72. package/dist/src/animation/skeleton.js.map +1 -0
  73. package/dist/src/animation/translationtrack.js +50 -0
  74. package/dist/src/animation/translationtrack.js.map +1 -0
  75. package/dist/src/app/app.js +129 -0
  76. package/dist/src/app/app.js.map +1 -0
  77. package/dist/src/app/inputmgr.js +267 -0
  78. package/dist/src/app/inputmgr.js.map +1 -0
  79. package/dist/src/asset/assetmanager.js +404 -0
  80. package/dist/src/asset/assetmanager.js.map +1 -0
  81. package/dist/src/asset/builtin.js +337 -0
  82. package/dist/src/asset/builtin.js.map +1 -0
  83. package/dist/src/asset/loaders/dds/dds.js +470 -0
  84. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  85. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  86. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  87. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  88. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  89. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  90. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  91. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  92. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  93. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  94. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  95. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  96. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  97. package/dist/src/asset/loaders/loader.js +45 -0
  98. package/dist/src/asset/loaders/loader.js.map +1 -0
  99. package/dist/src/asset/model.js +414 -0
  100. package/dist/src/asset/model.js.map +1 -0
  101. package/dist/src/blitter/bilateralblur.js +221 -0
  102. package/dist/src/blitter/bilateralblur.js.map +1 -0
  103. package/dist/src/blitter/blitter.js +390 -0
  104. package/dist/src/blitter/blitter.js.map +1 -0
  105. package/dist/src/blitter/box.js +118 -0
  106. package/dist/src/blitter/box.js.map +1 -0
  107. package/dist/src/blitter/copy.js +22 -0
  108. package/dist/src/blitter/copy.js.map +1 -0
  109. package/dist/src/blitter/gaussianblur.js +228 -0
  110. package/dist/src/blitter/gaussianblur.js.map +1 -0
  111. package/dist/src/camera/base.js +92 -0
  112. package/dist/src/camera/base.js.map +1 -0
  113. package/dist/src/camera/camera.js +1005 -0
  114. package/dist/src/camera/camera.js.map +1 -0
  115. package/dist/src/camera/fps.js +238 -0
  116. package/dist/src/camera/fps.js.map +1 -0
  117. package/dist/src/camera/orbit.js +245 -0
  118. package/dist/src/camera/orbit.js.map +1 -0
  119. package/dist/src/camera/orthocamera.js +167 -0
  120. package/dist/src/camera/orthocamera.js.map +1 -0
  121. package/dist/src/camera/perspectivecamera.js +141 -0
  122. package/dist/src/camera/perspectivecamera.js.map +1 -0
  123. package/dist/src/index.js +120 -0
  124. package/dist/src/index.js.map +1 -0
  125. package/dist/src/material/blinn.js +81 -0
  126. package/dist/src/material/blinn.js.map +1 -0
  127. package/dist/src/material/grassmaterial.js +113 -0
  128. package/dist/src/material/grassmaterial.js.map +1 -0
  129. package/dist/src/material/lambert.js +92 -0
  130. package/dist/src/material/lambert.js.map +1 -0
  131. package/dist/src/material/material.js +301 -0
  132. package/dist/src/material/material.js.map +1 -0
  133. package/dist/src/material/meshmaterial.js +704 -0
  134. package/dist/src/material/meshmaterial.js.map +1 -0
  135. package/dist/src/material/mixins/albedocolor.js +76 -0
  136. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  137. package/dist/src/material/mixins/foliage.js +47 -0
  138. package/dist/src/material/mixins/foliage.js.map +1 -0
  139. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  140. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  141. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  142. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  143. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  144. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  145. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  146. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  147. package/dist/src/material/mixins/lit.js +476 -0
  148. package/dist/src/material/mixins/lit.js.map +1 -0
  149. package/dist/src/material/mixins/pbr/common.js +918 -0
  150. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  151. package/dist/src/material/mixins/texture.js +172 -0
  152. package/dist/src/material/mixins/texture.js.map +1 -0
  153. package/dist/src/material/mixins/vertexcolor.js +56 -0
  154. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  155. package/dist/src/material/particle.js +178 -0
  156. package/dist/src/material/particle.js.map +1 -0
  157. package/dist/src/material/pbrmr.js +97 -0
  158. package/dist/src/material/pbrmr.js.map +1 -0
  159. package/dist/src/material/pbrsg.js +97 -0
  160. package/dist/src/material/pbrsg.js.map +1 -0
  161. package/dist/src/material/shader/helper.js +1209 -0
  162. package/dist/src/material/shader/helper.js.map +1 -0
  163. package/dist/src/material/terrain-cm.js +606 -0
  164. package/dist/src/material/terrain-cm.js.map +1 -0
  165. package/dist/src/material/terrainmaterial.js +375 -0
  166. package/dist/src/material/terrainmaterial.js.map +1 -0
  167. package/dist/src/material/unlit.js +41 -0
  168. package/dist/src/material/unlit.js.map +1 -0
  169. package/dist/src/material/water.js +417 -0
  170. package/dist/src/material/water.js.map +1 -0
  171. package/dist/src/posteffect/bloom.js +361 -0
  172. package/dist/src/posteffect/bloom.js.map +1 -0
  173. package/dist/src/posteffect/compositor.js +226 -0
  174. package/dist/src/posteffect/compositor.js.map +1 -0
  175. package/dist/src/posteffect/fxaa.js +273 -0
  176. package/dist/src/posteffect/fxaa.js.map +1 -0
  177. package/dist/src/posteffect/grayscale.js +69 -0
  178. package/dist/src/posteffect/grayscale.js.map +1 -0
  179. package/dist/src/posteffect/motionblur.js +96 -0
  180. package/dist/src/posteffect/motionblur.js.map +1 -0
  181. package/dist/src/posteffect/posteffect.js +126 -0
  182. package/dist/src/posteffect/posteffect.js.map +1 -0
  183. package/dist/src/posteffect/sao.js +324 -0
  184. package/dist/src/posteffect/sao.js.map +1 -0
  185. package/dist/src/posteffect/ssr.js +489 -0
  186. package/dist/src/posteffect/ssr.js.map +1 -0
  187. package/dist/src/posteffect/taa.js +172 -0
  188. package/dist/src/posteffect/taa.js.map +1 -0
  189. package/dist/src/posteffect/tonemap.js +94 -0
  190. package/dist/src/posteffect/tonemap.js.map +1 -0
  191. package/dist/src/render/abuffer_oit.js +361 -0
  192. package/dist/src/render/abuffer_oit.js.map +1 -0
  193. package/dist/src/render/clipmap.js +851 -0
  194. package/dist/src/render/clipmap.js.map +1 -0
  195. package/dist/src/render/cluster_light.js +333 -0
  196. package/dist/src/render/cluster_light.js.map +1 -0
  197. package/dist/src/render/cull_visitor.js +187 -0
  198. package/dist/src/render/cull_visitor.js.map +1 -0
  199. package/dist/src/render/depthpass.js +68 -0
  200. package/dist/src/render/depthpass.js.map +1 -0
  201. package/dist/src/render/drawable_mixin.js +227 -0
  202. package/dist/src/render/drawable_mixin.js.map +1 -0
  203. package/dist/src/render/envlight.js +463 -0
  204. package/dist/src/render/envlight.js.map +1 -0
  205. package/dist/src/render/fbm_wavegenerator.js +251 -0
  206. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  207. package/dist/src/render/fft_wavegenerator.js +1006 -0
  208. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  209. package/dist/src/render/fullscreenquad.js +38 -0
  210. package/dist/src/render/fullscreenquad.js.map +1 -0
  211. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  212. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  213. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  214. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  215. package/dist/src/render/hzb.js +273 -0
  216. package/dist/src/render/hzb.js.map +1 -0
  217. package/dist/src/render/lightpass.js +172 -0
  218. package/dist/src/render/lightpass.js.map +1 -0
  219. package/dist/src/render/objectcolorpass.js +51 -0
  220. package/dist/src/render/objectcolorpass.js.map +1 -0
  221. package/dist/src/render/primitive.js +364 -0
  222. package/dist/src/render/primitive.js.map +1 -0
  223. package/dist/src/render/render_queue.js +467 -0
  224. package/dist/src/render/render_queue.js.map +1 -0
  225. package/dist/src/render/renderbundle_wrapper.js +152 -0
  226. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  227. package/dist/src/render/renderer.js +455 -0
  228. package/dist/src/render/renderer.js.map +1 -0
  229. package/dist/src/render/renderpass.js +200 -0
  230. package/dist/src/render/renderpass.js.map +1 -0
  231. package/dist/src/render/shadowmap_pass.js +56 -0
  232. package/dist/src/render/shadowmap_pass.js.map +1 -0
  233. package/dist/src/render/sky.js +1103 -0
  234. package/dist/src/render/sky.js.map +1 -0
  235. package/dist/src/render/weightedblended_oit.js +168 -0
  236. package/dist/src/render/weightedblended_oit.js.map +1 -0
  237. package/dist/src/scene/batchgroup.js +162 -0
  238. package/dist/src/scene/batchgroup.js.map +1 -0
  239. package/dist/src/scene/environment.js +209 -0
  240. package/dist/src/scene/environment.js.map +1 -0
  241. package/dist/src/scene/graph_node.js +72 -0
  242. package/dist/src/scene/graph_node.js.map +1 -0
  243. package/dist/src/scene/light.js +416 -0
  244. package/dist/src/scene/light.js.map +1 -0
  245. package/dist/src/scene/mesh.js +341 -0
  246. package/dist/src/scene/mesh.js.map +1 -0
  247. package/dist/src/scene/octree.js +649 -0
  248. package/dist/src/scene/octree.js.map +1 -0
  249. package/dist/src/scene/particlesys.js +738 -0
  250. package/dist/src/scene/particlesys.js.map +1 -0
  251. package/dist/src/scene/raycast_visitor.js +103 -0
  252. package/dist/src/scene/raycast_visitor.js.map +1 -0
  253. package/dist/src/scene/scene.js +284 -0
  254. package/dist/src/scene/scene.js.map +1 -0
  255. package/dist/src/scene/scene_node.js +732 -0
  256. package/dist/src/scene/scene_node.js.map +1 -0
  257. package/dist/src/scene/terrain/grass.js +278 -0
  258. package/dist/src/scene/terrain/grass.js.map +1 -0
  259. package/dist/src/scene/terrain/heightfield.js +475 -0
  260. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  261. package/dist/src/scene/terrain/patch.js +530 -0
  262. package/dist/src/scene/terrain/patch.js.map +1 -0
  263. package/dist/src/scene/terrain/quadtree.js +461 -0
  264. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  265. package/dist/src/scene/terrain/terrain.js +246 -0
  266. package/dist/src/scene/terrain/terrain.js.map +1 -0
  267. package/dist/src/scene/terrain-cm/grass.js +594 -0
  268. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  269. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  270. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  271. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  272. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  273. package/dist/src/scene/water.js +374 -0
  274. package/dist/src/scene/water.js.map +1 -0
  275. package/dist/src/shaders/atmosphere.js +957 -0
  276. package/dist/src/shaders/atmosphere.js.map +1 -0
  277. package/dist/src/shaders/fog.js +112 -0
  278. package/dist/src/shaders/fog.js.map +1 -0
  279. package/dist/src/shaders/misc.js +266 -0
  280. package/dist/src/shaders/misc.js.map +1 -0
  281. package/dist/src/shaders/noise.js +222 -0
  282. package/dist/src/shaders/noise.js.map +1 -0
  283. package/dist/src/shaders/pbr.js +51 -0
  284. package/dist/src/shaders/pbr.js.map +1 -0
  285. package/dist/src/shaders/shadow.js +636 -0
  286. package/dist/src/shaders/shadow.js.map +1 -0
  287. package/dist/src/shaders/ssr.js +490 -0
  288. package/dist/src/shaders/ssr.js.map +1 -0
  289. package/dist/src/shaders/temporal.js +215 -0
  290. package/dist/src/shaders/temporal.js.map +1 -0
  291. package/dist/src/shaders/water.js +756 -0
  292. package/dist/src/shaders/water.js.map +1 -0
  293. package/dist/src/shadow/esm.js +237 -0
  294. package/dist/src/shadow/esm.js.map +1 -0
  295. package/dist/src/shadow/pcf_opt.js +181 -0
  296. package/dist/src/shadow/pcf_opt.js.map +1 -0
  297. package/dist/src/shadow/pcf_pd.js +189 -0
  298. package/dist/src/shadow/pcf_pd.js.map +1 -0
  299. package/dist/src/shadow/shader.js +37 -0
  300. package/dist/src/shadow/shader.js.map +1 -0
  301. package/dist/src/shadow/shadow_impl.js +15 -0
  302. package/dist/src/shadow/shadow_impl.js.map +1 -0
  303. package/dist/src/shadow/shadowmapper.js +790 -0
  304. package/dist/src/shadow/shadowmapper.js.map +1 -0
  305. package/dist/src/shadow/ssm.js +159 -0
  306. package/dist/src/shadow/ssm.js.map +1 -0
  307. package/dist/src/shadow/vsm.js +297 -0
  308. package/dist/src/shadow/vsm.js.map +1 -0
  309. package/dist/src/shapes/box.js +386 -0
  310. package/dist/src/shapes/box.js.map +1 -0
  311. package/dist/src/shapes/cylinder.js +125 -0
  312. package/dist/src/shapes/cylinder.js.map +1 -0
  313. package/dist/src/shapes/plane.js +88 -0
  314. package/dist/src/shapes/plane.js.map +1 -0
  315. package/dist/src/shapes/shape.js +87 -0
  316. package/dist/src/shapes/shape.js.map +1 -0
  317. package/dist/src/shapes/sphere.js +114 -0
  318. package/dist/src/shapes/sphere.js.map +1 -0
  319. package/dist/src/shapes/tetrahedron.js +188 -0
  320. package/dist/src/shapes/tetrahedron.js.map +1 -0
  321. package/dist/src/shapes/torus.js +111 -0
  322. package/dist/src/shapes/torus.js.map +1 -0
  323. package/dist/src/utility/aabbtree.js +400 -0
  324. package/dist/src/utility/aabbtree.js.map +1 -0
  325. package/dist/src/utility/bounding_volume.js +29 -0
  326. package/dist/src/utility/bounding_volume.js.map +1 -0
  327. package/dist/src/utility/debug.js +28 -0
  328. package/dist/src/utility/debug.js.map +1 -0
  329. package/dist/src/utility/draco/decoder.js +116 -0
  330. package/dist/src/utility/draco/decoder.js.map +1 -0
  331. package/dist/src/utility/misc.js +105 -0
  332. package/dist/src/utility/misc.js.map +1 -0
  333. package/dist/src/utility/panorama.js +163 -0
  334. package/dist/src/utility/panorama.js.map +1 -0
  335. package/dist/src/utility/pmrem.js +354 -0
  336. package/dist/src/utility/pmrem.js.map +1 -0
  337. package/dist/src/utility/rendermipmap.js +115 -0
  338. package/dist/src/utility/rendermipmap.js.map +1 -0
  339. package/dist/src/utility/serialization/json.js +402 -0
  340. package/dist/src/utility/serialization/json.js.map +1 -0
  341. package/dist/src/utility/serialization/manager.js +623 -0
  342. package/dist/src/utility/serialization/manager.js.map +1 -0
  343. package/dist/src/utility/serialization/scene/animation.js +248 -0
  344. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  345. package/dist/src/utility/serialization/scene/batch.js +59 -0
  346. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  347. package/dist/src/utility/serialization/scene/camera.js +790 -0
  348. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  349. package/dist/src/utility/serialization/scene/common.js +222 -0
  350. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  351. package/dist/src/utility/serialization/scene/light.js +575 -0
  352. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  353. package/dist/src/utility/serialization/scene/material.js +1111 -0
  354. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  355. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  356. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  357. package/dist/src/utility/serialization/scene/misc.js +39 -0
  358. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  359. package/dist/src/utility/serialization/scene/node.js +451 -0
  360. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  361. package/dist/src/utility/serialization/scene/particle.js +425 -0
  362. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  363. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  364. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  365. package/dist/src/utility/serialization/scene/scene.js +704 -0
  366. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  367. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  368. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  369. package/dist/src/utility/serialization/scene/water.js +465 -0
  370. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  371. package/dist/src/utility/shprojector.js +297 -0
  372. package/dist/src/utility/shprojector.js.map +1 -0
  373. package/dist/src/utility/textures/ggxlut.js +213 -0
  374. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  375. package/dist/src/utility/textures/gradientnoise.js +62 -0
  376. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  377. package/dist/src/utility/textures/randomnoise.js +41 -0
  378. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  379. package/dist/src/values.js +162 -0
  380. package/dist/src/values.js.map +1 -0
  381. package/dist/utility/blueprint/material/common.js +7 -0
  382. package/dist/utility/blueprint/material/common.js.map +1 -0
  383. package/dist/utility/blueprint/material/ir.js +489 -489
  384. package/dist/utility/blueprint/material/ir.js.map +1 -1
  385. package/dist/utility/serialization/blueprint/constants.js +255 -0
  386. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  387. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  388. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  389. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  390. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  391. package/dist/utility/serialization/manager.js +271 -271
  392. package/dist/utility/serialization/manager.js.map +1 -1
  393. package/dist/utility/serialization/scene/animation.js.map +1 -1
  394. package/dist/utility/serialization/scene/camera.js.map +1 -1
  395. package/dist/utility/serialization/scene/common.js.map +1 -1
  396. package/dist/utility/serialization/scene/light.js.map +1 -1
  397. package/dist/utility/serialization/scene/material.js.map +1 -1
  398. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  399. package/dist/utility/serialization/scene/node.js.map +1 -1
  400. package/dist/utility/serialization/scene/particle.js.map +1 -1
  401. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  402. package/dist/utility/serialization/scene/scene.js.map +1 -1
  403. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  404. package/dist/utility/serialization/types.js +4 -4
  405. package/dist/utility/serialization/types.js.map +1 -1
  406. package/dist/values.js +49 -53
  407. package/dist/values.js.map +1 -1
  408. package/package.json +1 -1
  409. package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
  410. package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
  411. package/dist/animation/spring/spring_bone.js +0 -240
  412. package/dist/animation/spring/spring_bone.js.map +0 -1
  413. package/dist/animation/spring/spring_bone_collider.js +0 -198
  414. package/dist/animation/spring/spring_bone_collider.js.map +0 -1
  415. package/dist/animation/spring/spring_bone_constraint.js +0 -170
  416. package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
  417. package/dist/animation/spring/spring_bone_system.js +0 -328
  418. package/dist/animation/spring/spring_bone_system.js.map +0 -1
  419. package/dist/render/sky_motion_vector.js +0 -85
  420. package/dist/render/sky_motion_vector.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbr.js","sources":["../../../src/shaders/pbr.ts"],"sourcesContent":["import type { PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\n\r\n/** @internal */\r\nexport function fresnelSchlick(\r\n scope: PBInsideFunctionScope,\r\n VdotH: PBShaderExp,\r\n f0: PBShaderExp,\r\n f90: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'fresnelSchlick';\r\n pb.func(funcName, [pb.float('VdotH'), pb.vec3('F0'), pb.vec3('F90')], function () {\r\n this.$return(\r\n pb.add(this.F0, pb.mul(pb.sub(this.F90, this.F0), pb.pow(pb.clamp(pb.sub(1, this.VdotH), 0, 1), 5)))\r\n );\r\n });\r\n return pb.getGlobalScope()[funcName](VdotH, f0, f90);\r\n}\r\n\r\n/** @internal */\r\nexport function distributionGGX(\r\n scope: PBInsideFunctionScope,\r\n NdotH: PBShaderExp,\r\n alphaRoughness: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'distributionGGX';\r\n pb.func(funcName, [pb.float('NdotH'), pb.float('roughness')], function () {\r\n this.$l.a2 = pb.mul(this.roughness, this.roughness);\r\n this.$l.NdotH2 = pb.mul(this.NdotH, this.NdotH);\r\n this.$l.num = this.a2;\r\n this.$l.denom = pb.add(pb.mul(this.NdotH2, pb.sub(this.a2, 1)), 1);\r\n this.denom = pb.mul(pb.mul(3.14159265, this.denom), this.denom);\r\n this.$return(pb.div(this.num, this.denom));\r\n });\r\n return pb.getGlobalScope()[funcName](NdotH, alphaRoughness);\r\n}\r\n\r\n/** @internal */\r\nexport function visGGX(\r\n scope: PBInsideFunctionScope,\r\n NdotV: PBShaderExp,\r\n NdotL: PBShaderExp,\r\n alphaRoughness: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'visGGX';\r\n pb.func(funcName, [pb.float('NdotV'), pb.float('NdotL'), pb.float('roughness')], function () {\r\n this.$l.a2 = pb.mul(this.roughness, this.roughness);\r\n this.$l.ggxV = pb.mul(\r\n this.NdotL,\r\n pb.sqrt(pb.add(pb.mul(this.NdotV, this.NdotV, pb.sub(1, this.a2)), this.a2))\r\n );\r\n this.$l.ggxL = pb.mul(\r\n this.NdotV,\r\n pb.sqrt(pb.add(pb.mul(this.NdotL, this.NdotL, pb.sub(1, this.a2)), this.a2))\r\n );\r\n this.$l.ggx = pb.add(this.ggxV, this.ggxL);\r\n this.$if(pb.greaterThan(this.ggx, 0), function () {\r\n this.$return(pb.div(0.5, this.ggx));\r\n }).$else(function () {\r\n this.$return(pb.float(0));\r\n });\r\n });\r\n return pb.getGlobalScope()[funcName](NdotV, NdotL, alphaRoughness);\r\n}\r\n"],"names":["fresnelSchlick","scope","VdotH","f0","f90","pb","$builder","funcName","func","float","vec3","$return","add","F0","mul","sub","F90","pow","clamp","getGlobalScope","distributionGGX","NdotH","alphaRoughness","$l","a2","roughness","NdotH2","num","denom","div","visGGX","NdotV","NdotL","ggxV","sqrt","ggxL","ggx","$if","greaterThan","$else"],"mappings":"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"}
@@ -0,0 +1,636 @@
1
+ import { hasDepthChannel } from '@zephyr3d/device';
2
+ import { Application } from '../app/app.js';
3
+ import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
4
+ import { encodeNormalizedFloatToRGBA, decode2HalfFromRGBA, decodeNormalizedFloatFromRGBA } from './misc.js';
5
+ import { ShaderHelper } from '../material/shader/helper.js';
6
+ import { interleavedGradientNoise } from './noise.js';
7
+
8
+ /*
9
+ const PCF_KERNEL_3x3 = [
10
+ [0.5, 1.0, 0.5],
11
+ [1.0, 1.0, 1.0],
12
+ [0.5, 1.0, 0.5]
13
+ ];
14
+ const PCF_KERNEL_SUM_3x3 = 7;
15
+
16
+ const PCF_KERNEL_5x5 = [
17
+ [0.0, 0.5, 1.0, 0.5, 0.0],
18
+ [0.5, 1.0, 1.0, 1.0, 0.5],
19
+ [1.0, 1.0, 1.0, 1.0, 1.0],
20
+ [0.5, 1.0, 1.0, 1.0, 0.5],
21
+ [0.0, 0.5, 1.0, 0.5, 0.0]
22
+ ];
23
+ const PCF_KERNEL_SUM_5x5 = 17;
24
+
25
+ const PCF_KERNEL_7x7 = [
26
+ [0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0],
27
+ [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
28
+ [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
29
+ [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
30
+ [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
31
+ [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
32
+ [0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0]
33
+ ];
34
+ const PCF_KERNEL_SUM_7x7 = 33;
35
+
36
+ const PCF_KERNEL_9x9 = [
37
+ [0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0],
38
+ [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
39
+ [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
40
+ [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
41
+ [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
42
+ [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
43
+ [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
44
+ [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
45
+ [0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0]
46
+ ];
47
+ const PCF_KERNEL_SUM_9x9 = 53;
48
+ */ const PCF_POISSON_DISC = [
49
+ [
50
+ 0.511749,
51
+ 0.547686
52
+ ],
53
+ [
54
+ 0.58929,
55
+ 0.257224
56
+ ],
57
+ [
58
+ 0.165018,
59
+ 0.57663
60
+ ],
61
+ [
62
+ 0.407692,
63
+ 0.742285
64
+ ],
65
+ [
66
+ 0.707012,
67
+ 0.646523
68
+ ],
69
+ [
70
+ 0.31463,
71
+ 0.466825
72
+ ],
73
+ [
74
+ 0.801257,
75
+ 0.485186
76
+ ],
77
+ [
78
+ 0.418136,
79
+ 0.146517
80
+ ],
81
+ [
82
+ 0.579889,
83
+ 0.0368284
84
+ ],
85
+ [
86
+ 0.79801,
87
+ 0.140114
88
+ ],
89
+ [
90
+ -0.0413185,
91
+ 0.371455
92
+ ],
93
+ [
94
+ -0.0529108,
95
+ 0.627352
96
+ ],
97
+ [
98
+ 0.0821375,
99
+ 0.882071
100
+ ],
101
+ [
102
+ 0.17308,
103
+ 0.301207
104
+ ],
105
+ [
106
+ -0.120452,
107
+ 0.867216
108
+ ],
109
+ [
110
+ 0.371096,
111
+ 0.916454
112
+ ],
113
+ [
114
+ -0.178381,
115
+ 0.146101
116
+ ],
117
+ [
118
+ -0.276489,
119
+ 0.550525
120
+ ],
121
+ [
122
+ 0.12542,
123
+ 0.126643
124
+ ],
125
+ [
126
+ -0.296654,
127
+ 0.286879
128
+ ],
129
+ [
130
+ 0.261744,
131
+ -604975e-8
132
+ ],
133
+ [
134
+ -0.213417,
135
+ 0.715776
136
+ ],
137
+ [
138
+ 0.425684,
139
+ -0.153211
140
+ ],
141
+ [
142
+ -0.480054,
143
+ 0.321357
144
+ ],
145
+ [
146
+ -0.0717878,
147
+ -0.0250567
148
+ ],
149
+ [
150
+ -0.328775,
151
+ -0.169666
152
+ ],
153
+ [
154
+ -0.394923,
155
+ 0.130802
156
+ ],
157
+ [
158
+ -0.553681,
159
+ -0.176777
160
+ ],
161
+ [
162
+ -0.722615,
163
+ 0.120616
164
+ ],
165
+ [
166
+ -0.693065,
167
+ 0.309017
168
+ ],
169
+ [
170
+ 0.603193,
171
+ 0.791471
172
+ ],
173
+ [
174
+ -0.0754941,
175
+ -0.297988
176
+ ],
177
+ [
178
+ 0.109303,
179
+ -0.156472
180
+ ],
181
+ [
182
+ 0.260605,
183
+ -0.280111
184
+ ],
185
+ [
186
+ 0.129731,
187
+ -0.487954
188
+ ],
189
+ [
190
+ -0.537315,
191
+ 0.520494
192
+ ],
193
+ [
194
+ -0.42758,
195
+ 0.800607
196
+ ],
197
+ [
198
+ 0.77309,
199
+ -0.0728102
200
+ ],
201
+ [
202
+ 0.908777,
203
+ 0.328356
204
+ ],
205
+ [
206
+ 0.985341,
207
+ 0.0759158
208
+ ],
209
+ [
210
+ 0.947536,
211
+ -0.11837
212
+ ],
213
+ [
214
+ -0.103315,
215
+ -0.610747
216
+ ],
217
+ [
218
+ 0.337171,
219
+ -0.584
220
+ ],
221
+ [
222
+ 0.210919,
223
+ -0.720055
224
+ ],
225
+ [
226
+ 0.41894,
227
+ -0.36769
228
+ ],
229
+ [
230
+ -0.254228,
231
+ -0.49368
232
+ ],
233
+ [
234
+ -0.428562,
235
+ -0.404037
236
+ ],
237
+ [
238
+ -0.831732,
239
+ -0.189615
240
+ ],
241
+ [
242
+ -0.922642,
243
+ 0.0888026
244
+ ],
245
+ [
246
+ -0.865914,
247
+ 0.427795
248
+ ],
249
+ [
250
+ 0.706117,
251
+ -0.311662
252
+ ],
253
+ [
254
+ 0.545465,
255
+ -0.520942
256
+ ],
257
+ [
258
+ -0.695738,
259
+ 0.664492
260
+ ],
261
+ [
262
+ 0.389421,
263
+ -0.899007
264
+ ],
265
+ [
266
+ 0.48842,
267
+ -0.708054
268
+ ],
269
+ [
270
+ 0.760298,
271
+ -0.62735
272
+ ],
273
+ [
274
+ -0.390788,
275
+ -0.707388
276
+ ],
277
+ [
278
+ -0.591046,
279
+ -0.686721
280
+ ],
281
+ [
282
+ -0.769903,
283
+ -0.413775
284
+ ],
285
+ [
286
+ -0.604457,
287
+ -0.502571
288
+ ],
289
+ [
290
+ -0.557234,
291
+ 0.00451362
292
+ ],
293
+ [
294
+ 0.147572,
295
+ -0.924353
296
+ ],
297
+ [
298
+ -0.0662488,
299
+ -0.892081
300
+ ],
301
+ [
302
+ 0.863832,
303
+ -0.4072
304
+ ]
305
+ ];
306
+ function getShadowMapTexelSize(scope) {
307
+ return scope.$builder.div(1, ShaderHelper.getShadowCameraParams(scope).z);
308
+ }
309
+ function getShadowMapSize(scope) {
310
+ return ShaderHelper.getShadowCameraParams(scope).z;
311
+ }
312
+ /** @internal */ function computeShadowMapDepth(scope, worldPos, targetFormat) {
313
+ const funcNameComputeShadowMapDepth = 'Z_computeShadowMapDepth';
314
+ const pb = scope.$builder;
315
+ pb.func(funcNameComputeShadowMapDepth, [
316
+ pb.vec3('worldPos')
317
+ ], function() {
318
+ if (hasDepthChannel(targetFormat)) {
319
+ // use native shadowmap
320
+ this.$return(pb.vec4(pb.emulateDepthClamp ? pb.clamp(scope.$inputs.clamppedDepth, 0, 1) : scope.$builtins.fragCoord.z, 0, 0, 1));
321
+ } else {
322
+ this.$l.depth = pb.float();
323
+ this.$l.lightType = ShaderHelper.getLightTypeForShadow(this);
324
+ this.$if(pb.equal(this.lightType, LIGHT_TYPE_DIRECTIONAL), function() {
325
+ this.depth = pb.emulateDepthClamp ? pb.clamp(this.$inputs.clamppedDepth, 0, 1) : this.$builtins.fragCoord.z;
326
+ }).$elseif(pb.equal(this.lightType, LIGHT_TYPE_POINT), function() {
327
+ this.$l.lightSpacePos = pb.mul(ShaderHelper.getLightViewMatrixForShadow(this), pb.vec4(this.worldPos, 1));
328
+ this.depth = pb.clamp(pb.div(pb.length(this.lightSpacePos.xyz), ShaderHelper.getLightPositionAndRangeForShadow(this).w), 0, 1);
329
+ }).$else(function() {
330
+ this.$l.lightSpacePos = pb.mul(ShaderHelper.getLightViewMatrixForShadow(this), pb.vec4(this.worldPos, 1));
331
+ this.depth = pb.clamp(pb.div(pb.neg(this.lightSpacePos.z), ShaderHelper.getLightPositionAndRangeForShadow(this).w), 0, 1);
332
+ });
333
+ this.$return(targetFormat === 'rgba8unorm' ? encodeNormalizedFloatToRGBA(this, this.depth) : pb.vec4(this.depth, 0, 0, 1));
334
+ }
335
+ });
336
+ return pb.getGlobalScope()[funcNameComputeShadowMapDepth](worldPos);
337
+ }
338
+ /** @internal */ function computeReceiverPlaneDepthBias(scope, texCoord) {
339
+ const funcNameComputeReceiverPlaneDepthBias = 'lib_computeReceiverPlaneDepthBias';
340
+ const pb = scope.$builder;
341
+ pb.func(funcNameComputeReceiverPlaneDepthBias, [
342
+ pb.vec4('coords')
343
+ ], function() {
344
+ this.$l.dx = pb.dpdx(this.coords);
345
+ this.$l.dy = pb.dpdy(this.coords);
346
+ this.$l.biasMultiply = pb.float(1);
347
+ this.$l.uv = pb.vec2(pb.sub(pb.mul(this.dy.y, this.dx.z), pb.mul(this.dx.y, this.dy.z)), pb.sub(pb.mul(this.dx.x, this.dy.z), pb.mul(this.dy.x, this.dx.z)));
348
+ this.$l.uv = pb.mul(this.$l.uv, pb.div(this.biasMultiply, pb.sub(pb.mul(this.dx.x, this.dy.y), pb.mul(this.dx.y, this.dy.x))));
349
+ // from unity shader
350
+ this.$l.minFractionalError = pb.float(0.01);
351
+ this.$l.fractionalSamplingError = pb.dot(pb.vec2(getShadowMapTexelSize(this)), pb.abs(this.$l.uv));
352
+ this.$l.staticBias = pb.min(this.$l.fractionalSamplingError, this.$l.minFractionalError);
353
+ // return
354
+ this.$return(pb.vec3(this.$l.uv, this.$l.staticBias));
355
+ });
356
+ return pb.getGlobalScope()[funcNameComputeReceiverPlaneDepthBias](texCoord);
357
+ }
358
+ function getRandomRotationMatrix(scope, fragCoord) {
359
+ const funcNameGetRandomRotationMatrix = 'lib_getRandomRotationMatrix';
360
+ const pb = scope.$builder;
361
+ pb.func(funcNameGetRandomRotationMatrix, [
362
+ pb.vec2('fragCoord')
363
+ ], function() {
364
+ this.$l.randomAngle = pb.mul(interleavedGradientNoise(this, fragCoord), 2 * Math.PI);
365
+ this.$l.randomBase = pb.vec2(pb.cos(this.randomAngle), pb.sin(this.randomAngle));
366
+ this.$return(pb.mat2(this.randomBase.x, this.randomBase.y, pb.neg(this.randomBase.y), this.randomBase.x));
367
+ });
368
+ return pb.getGlobalScope()[funcNameGetRandomRotationMatrix](fragCoord);
369
+ }
370
+ function getPoissonDiscSampleRadius(scope) {
371
+ return ShaderHelper.getDepthBiasValues(scope).z;
372
+ }
373
+ function sampleShadowMapPCF(scope, shadowMapFormat, pos, offset, depth, cascade) {
374
+ const funcName = cascade ? 'lib_sampleShadowMapCascadePCF' : 'lib_sampleShadowMapPCF';
375
+ const pb = scope.$builder;
376
+ const nativeShadowMap = hasDepthChannel(shadowMapFormat);
377
+ pb.func(funcName, [
378
+ pb.vec2('coords'),
379
+ pb.float('z'),
380
+ pb.vec2('offset'),
381
+ ...cascade ? [
382
+ pb.int('cascade')
383
+ ] : []
384
+ ], function() {
385
+ const sampleDepth = this.z;
386
+ const uv = pb.add(this.coords, this.offset);
387
+ if (nativeShadowMap) {
388
+ this.$return(cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), uv, this.cascade, sampleDepth) : pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), uv, sampleDepth));
389
+ } else {
390
+ this.$l.shadowTex = cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), uv, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), uv, 0);
391
+ if (shadowMapFormat === 'rgba8unorm') {
392
+ this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
393
+ }
394
+ this.$return(pb.step(sampleDepth, this.shadowTex.x));
395
+ }
396
+ });
397
+ return pb.getGlobalScope()[funcName](pos, depth, offset, ...cascade ? [
398
+ cascade
399
+ ] : []);
400
+ }
401
+ function sampleShadowMap(scope, lightType, shadowMapFormat, pos, depth, cascade) {
402
+ const funcNameSampleShadowMap = 'lib_sampleShadowMap';
403
+ const pb = scope.$builder;
404
+ const nativeShadowMap = hasDepthChannel(shadowMapFormat);
405
+ pb.func(funcNameSampleShadowMap, [
406
+ lightType === LIGHT_TYPE_POINT ? pb.vec3('coords') : pb.vec2('coords'),
407
+ pb.float('z'),
408
+ ...cascade ? [
409
+ pb.int('cascade')
410
+ ] : []
411
+ ], function() {
412
+ if (lightType === LIGHT_TYPE_POINT) {
413
+ if (nativeShadowMap) {
414
+ this.$return(pb.clamp(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, this.z), 0, 1));
415
+ } else {
416
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords, 0);
417
+ if (shadowMapFormat === 'rgba8unorm') {
418
+ this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
419
+ }
420
+ this.$return(pb.step(this.z, this.shadowTex.x));
421
+ }
422
+ } else {
423
+ if (nativeShadowMap) {
424
+ this.$return(cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, this.cascade, this.z) : pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, this.z));
425
+ } else {
426
+ this.$l.shadowTex = cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.coords, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords, 0);
427
+ if (shadowMapFormat === 'rgba8unorm') {
428
+ this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
429
+ }
430
+ this.$return(pb.step(this.z, this.shadowTex.x));
431
+ }
432
+ }
433
+ });
434
+ return cascade ? pb.getGlobalScope()[funcNameSampleShadowMap](pos, depth, cascade) : pb.getGlobalScope()[funcNameSampleShadowMap](pos, depth);
435
+ }
436
+ function chebyshevUpperBound(scope, distance, occluder) {
437
+ const funcNameChebyshevUpperBound = 'lib_chebyshevUpperBound';
438
+ const pb = scope.$builder;
439
+ pb.func(funcNameChebyshevUpperBound, [
440
+ pb.float('distance'),
441
+ pb.vec2('occluder')
442
+ ], function() {
443
+ this.$l.shadow = pb.float(1);
444
+ this.$l.test = pb.step(this.distance, this.occluder.x);
445
+ this.$if(pb.notEqual(this.test, 1), function() {
446
+ this.$l.d = pb.sub(this.distance, this.occluder.x);
447
+ this.$l.variance = pb.max(pb.mul(this.occluder.y, this.occluder.y), 0);
448
+ const darkness = ShaderHelper.getDepthBiasValues(this).z;
449
+ this.shadow = pb.div(this.variance, pb.add(this.variance, pb.mul(this.d, this.d)));
450
+ this.shadow = pb.clamp(pb.div(pb.sub(this.shadow, darkness), pb.sub(1, darkness)), 0, 1);
451
+ });
452
+ this.$return(this.shadow);
453
+ });
454
+ return pb.getGlobalScope()[funcNameChebyshevUpperBound](distance, occluder);
455
+ }
456
+ /** @internal */ function filterShadowVSM(scope, lightType, shadowMapFormat, texCoord, cascade) {
457
+ const funcNameFilterShadowVSM = 'lib_filterShadowVSM';
458
+ const pb = scope.$builder;
459
+ pb.func(funcNameFilterShadowVSM, [
460
+ pb.vec4('texCoord'),
461
+ ...cascade ? [
462
+ pb.int('cascade')
463
+ ] : []
464
+ ], function() {
465
+ if (lightType === LIGHT_TYPE_POINT) {
466
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xyz, 0);
467
+ this.$return(chebyshevUpperBound(this, this.texCoord.w, shadowMapFormat === 'rgba8unorm' ? decode2HalfFromRGBA(this, this.shadowTex) : this.shadowTex.rg));
468
+ } else {
469
+ if (Application.instance.device.type !== 'webgl' && cascade) {
470
+ this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xy, this.cascade, 0);
471
+ } else {
472
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xy, 0);
473
+ }
474
+ this.$return(chebyshevUpperBound(this, this.texCoord.z, shadowMapFormat === 'rgba8unorm' ? decode2HalfFromRGBA(this, this.shadowTex) : this.shadowTex.rg));
475
+ }
476
+ });
477
+ return pb.getGlobalScope()[funcNameFilterShadowVSM](texCoord, ...cascade ? [
478
+ cascade
479
+ ] : []);
480
+ }
481
+ /** @internal */ function filterShadowESM(scope, lightType, shadowMapFormat, shadowVertex, cascade) {
482
+ const funcNameFilterShadowESM = 'lib_filterShadowESM';
483
+ const pb = scope.$builder;
484
+ pb.func(funcNameFilterShadowESM, [
485
+ lightType === LIGHT_TYPE_POINT ? pb.vec3('shadowVertex') : pb.vec4('shadowVertex'),
486
+ ...cascade ? [
487
+ pb.int('cascade')
488
+ ] : []
489
+ ], function() {
490
+ if (lightType === LIGHT_TYPE_POINT) {
491
+ this.$l.depth = pb.div(pb.length(this.shadowVertex.xyz), ShaderHelper.getLightPositionAndRangeForShadow(this).w);
492
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xyz, 0);
493
+ if (shadowMapFormat === 'rgba8unorm') {
494
+ this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
495
+ }
496
+ } else {
497
+ if (cascade && Application.instance.device.type !== 'webgl') {
498
+ this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xy, this.cascade, 0);
499
+ } else {
500
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xy, 0);
501
+ }
502
+ if (shadowMapFormat === 'rgba8unorm') {
503
+ this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
504
+ }
505
+ if (lightType === LIGHT_TYPE_SPOT) {
506
+ this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
507
+ this.$l.depth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.shadowVertex.z, this.nearFar);
508
+ } else {
509
+ this.$l.depth = this.shadowVertex.z;
510
+ }
511
+ }
512
+ const depthScale = ShaderHelper.getDepthBiasValues(this).z;
513
+ this.$return(pb.clamp(pb.exp(pb.min(87, pb.mul(depthScale, pb.sub(this.shadowTex.x, this.depth)))), 0, 1));
514
+ });
515
+ return pb.getGlobalScope()[funcNameFilterShadowESM](shadowVertex, ...cascade ? [
516
+ cascade
517
+ ] : []);
518
+ }
519
+ /** @internal */ function filterShadowPCF(scope, lightType, shadowMapFormat, kernelSize, texCoord, receiverPlaneDepthBias, cascade) {
520
+ const funcNameFilterShadowPCF = `lib_filterShadowPCF${kernelSize}x${kernelSize}`;
521
+ const pb = scope.$builder;
522
+ pb.func(funcNameFilterShadowPCF, [
523
+ pb.vec4('texCoord'),
524
+ ...receiverPlaneDepthBias ? [
525
+ pb.vec3('receiverPlaneDepthBias')
526
+ ] : [],
527
+ ...cascade ? [
528
+ pb.int('cascade')
529
+ ] : []
530
+ ], function() {
531
+ this.$l.lightDepth = this.texCoord.z;
532
+ if (receiverPlaneDepthBias) {
533
+ this.lightDepth = pb.sub(this.lightDepth, this.receiverPlaneDepthBias.z);
534
+ }
535
+ const shadowMapTexelSize = getShadowMapTexelSize(this);
536
+ this.$l.uv = pb.add(pb.mul(this.texCoord.xy, pb.vec2(getShadowMapSize(this))), pb.vec2(0));
537
+ this.$l.st = pb.fract(this.uv);
538
+ this.$l.baseUV = pb.sub(pb.floor(this.uv), pb.vec2(0.5));
539
+ this.baseUV = pb.mul(this.baseUV, shadowMapTexelSize);
540
+ this.$l.shadow = pb.float(0);
541
+ if (kernelSize === 3) {
542
+ this.$l.uvw0 = pb.sub(pb.vec2(3), pb.mul(2, this.st));
543
+ this.$l.uvw1 = pb.add(pb.vec2(1), pb.mul(2, this.st));
544
+ this.$l.u = pb.mul(pb.vec2(pb.sub(pb.div(pb.sub(2, this.st.x), this.uvw0.x), 1), pb.add(pb.div(this.st.x, this.uvw1.x), 1)), shadowMapTexelSize);
545
+ this.$l.v = pb.mul(pb.vec2(pb.sub(pb.div(pb.sub(2, this.st.y), this.uvw0.y), 1), pb.add(pb.div(this.st.y, this.uvw1.y), 1)), shadowMapTexelSize);
546
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.x), this.lightDepth, this.cascade), this.uvw0.x, this.uvw0.y));
547
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.x), this.lightDepth, this.cascade), this.uvw1.x, this.uvw0.y));
548
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.y), this.lightDepth, this.cascade), this.uvw0.x, this.uvw1.y));
549
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.y), this.lightDepth, this.cascade), this.uvw1.x, this.uvw1.y));
550
+ this.shadow = pb.div(this.shadow, 16);
551
+ } else if (kernelSize === 5) {
552
+ this.$l.uvw0 = pb.sub(pb.vec2(4), pb.mul(this.st, 3));
553
+ this.$l.uvw1 = pb.vec2(7);
554
+ this.$l.uvw2 = pb.add(pb.vec2(1), pb.mul(this.st, 3));
555
+ this.$l.u = pb.mul(pb.vec3(pb.sub(pb.div(pb.sub(3, pb.mul(this.st.x, 2)), this.uvw0.x), 2), pb.div(pb.add(this.st.x, 3), this.uvw1.x), pb.add(pb.div(this.st.x, this.uvw2.x), 2)), shadowMapTexelSize);
556
+ this.$l.v = pb.mul(pb.vec3(pb.sub(pb.div(pb.sub(3, pb.mul(this.st.y, 2)), this.uvw0.y), 2), pb.div(pb.add(this.st.y, 3), this.uvw1.y), pb.add(pb.div(this.st.y, this.uvw2.y), 2)), shadowMapTexelSize);
557
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.x), this.lightDepth, this.cascade), this.uvw0.x, this.uvw0.y));
558
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.x), this.lightDepth, this.cascade), this.uvw1.x, this.uvw0.y));
559
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.z, this.v.x), this.lightDepth, this.cascade), this.uvw2.x, this.uvw0.y));
560
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.y), this.lightDepth, this.cascade), this.uvw0.x, this.uvw1.y));
561
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.y), this.lightDepth, this.cascade), this.uvw1.x, this.uvw1.y));
562
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.z, this.v.y), this.lightDepth, this.cascade), this.uvw2.x, this.uvw1.y));
563
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.z), this.lightDepth, this.cascade), this.uvw0.x, this.uvw2.y));
564
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.z), this.lightDepth, this.cascade), this.uvw1.x, this.uvw2.y));
565
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.z, this.v.z), this.lightDepth, this.cascade), this.uvw2.x, this.uvw2.y));
566
+ this.shadow = pb.div(this.shadow, 144);
567
+ } else if (kernelSize === 7) {
568
+ this.$l.uvw0 = pb.sub(pb.mul(this.st, 5), pb.vec2(6));
569
+ this.$l.uvw1 = pb.sub(pb.mul(this.st, 11), pb.vec2(28));
570
+ this.$l.uvw2 = pb.sub(pb.mul(this.st, -11), pb.vec2(17));
571
+ this.$l.uvw3 = pb.sub(pb.mul(this.st, -5), 1);
572
+ this.$l.u = pb.vec4(pb.sub(pb.div(pb.sub(pb.mul(this.st.x, 4), 5), this.uvw0.x), 3), pb.sub(pb.div(pb.sub(pb.mul(this.st.x, 4), 16), this.uvw1.x), 1), pb.add(pb.div(pb.sub(pb.mul(this.st.x, -7), 5), this.uvw2.x), 1), pb.add(pb.div(pb.neg(this.st.x), this.uvw3.x), 3));
573
+ this.$l.v = pb.vec4(pb.sub(pb.div(pb.sub(pb.mul(this.st.y, 4), 5), this.uvw0.y), 3), pb.sub(pb.div(pb.sub(pb.mul(this.st.y, 4), 16), this.uvw1.y), 1), pb.add(pb.div(pb.sub(pb.mul(this.st.y, -7), 5), this.uvw2.y), 1), pb.add(pb.div(pb.neg(this.st.y), this.uvw3.y), 3));
574
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw0.y));
575
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw0.y));
576
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw0.y));
577
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw0.y));
578
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw1.y));
579
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw1.y));
580
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw1.y));
581
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw1.y));
582
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw2.y));
583
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw2.y));
584
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw2.y));
585
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw2.y));
586
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw3.y));
587
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw3.y));
588
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw3.y));
589
+ this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw3.y));
590
+ this.shadow = pb.div(this.shadow, 2704);
591
+ }
592
+ this.$return(this.shadow);
593
+ });
594
+ return pb.getGlobalScope()[funcNameFilterShadowPCF](texCoord, ...receiverPlaneDepthBias ? [
595
+ receiverPlaneDepthBias
596
+ ] : [], ...cascade ? [
597
+ cascade
598
+ ] : []);
599
+ }
600
+ /** @internal */ function filterShadowPoissonDisc(scope, lightType, shadowMapFormat, tapCount, texCoord, receiverPlaneDepthBias, cascade) {
601
+ const funcNameFilterShadowPoissonDisc = 'lib_filterShadowPoissonDisc';
602
+ const pb = scope.$builder;
603
+ pb.func(funcNameFilterShadowPoissonDisc, [
604
+ pb.vec4('texCoord'),
605
+ ...receiverPlaneDepthBias ? [
606
+ pb.vec3('receiverPlaneDepthBias')
607
+ ] : [],
608
+ ...cascade ? [
609
+ pb.int('cascade')
610
+ ] : []
611
+ ], function() {
612
+ this.$l.lightDepth = this.texCoord.z;
613
+ if (receiverPlaneDepthBias) {
614
+ this.lightDepth = pb.sub(this.lightDepth, this.receiverPlaneDepthBias.z);
615
+ }
616
+ this.$l.duv = pb.vec2();
617
+ this.$l.filterRadius = pb.mul(getShadowMapTexelSize(this), getPoissonDiscSampleRadius(this));
618
+ this.$l.matrix = getRandomRotationMatrix(this, this.$builtins.fragCoord.xy);
619
+ this.$l.shadow = pb.float(0);
620
+ for(let i = 0; i < tapCount; i++){
621
+ this.duv = pb.mul(this.matrix, pb.mul(pb.vec2(PCF_POISSON_DISC[i][0], PCF_POISSON_DISC[i][1]), this.filterRadius));
622
+ const sampleDepth = receiverPlaneDepthBias ? pb.add(this.lightDepth, pb.dot(this.duv, this.receiverPlaneDepthBias.xy)) : this.lightDepth;
623
+ this.shadow = pb.add(this.shadow, sampleShadowMap(this, lightType, shadowMapFormat, pb.add(this.texCoord.xy, this.duv), sampleDepth, this.cascade));
624
+ }
625
+ this.shadow = pb.div(this.shadow, tapCount);
626
+ this.$return(this.shadow);
627
+ });
628
+ return pb.getGlobalScope()[funcNameFilterShadowPoissonDisc](texCoord, ...receiverPlaneDepthBias ? [
629
+ receiverPlaneDepthBias
630
+ ] : [], ...cascade ? [
631
+ cascade
632
+ ] : []);
633
+ }
634
+
635
+ export { computeReceiverPlaneDepthBias, computeShadowMapDepth, filterShadowESM, filterShadowPCF, filterShadowPoissonDisc, filterShadowVSM };
636
+ //# sourceMappingURL=shadow.js.map