@zephyr3d/scene 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/dist/animation/animationset.js +220 -1
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/ik/ccd_solver.js +3 -4
  4. package/dist/animation/ik/ccd_solver.js.map +1 -1
  5. package/dist/animation/ik/fabrik_solver.js +3 -4
  6. package/dist/animation/ik/fabrik_solver.js.map +1 -1
  7. package/dist/animation/ik/ik_pole_constraint.js +7 -2
  8. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  9. package/dist/animation/ik/ik_utils.js +0 -79
  10. package/dist/animation/ik/ik_utils.js.map +1 -1
  11. package/dist/animation/ik/two_bone_ik_solver.js +3 -4
  12. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
  13. package/dist/animation/skeleton.js +157 -125
  14. package/dist/animation/skeleton.js.map +1 -1
  15. package/dist/animation/spring/spring_bone.js +240 -0
  16. package/dist/animation/spring/spring_bone.js.map +1 -0
  17. package/dist/animation/spring/spring_bone_collider.js +198 -0
  18. package/dist/animation/spring/spring_bone_collider.js.map +1 -0
  19. package/dist/animation/spring/spring_bone_constraint.js +170 -0
  20. package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
  21. package/dist/animation/spring/spring_bone_system.js +328 -0
  22. package/dist/animation/spring/spring_bone_system.js.map +1 -0
  23. package/dist/asset/model.js +2 -2
  24. package/dist/index.d.ts +17 -0
  25. package/dist/material/mixins/pbr/common.js +20 -17
  26. package/dist/material/mixins/pbr/common.js.map +1 -1
  27. package/dist/render/gpu_picking.js +100 -0
  28. package/dist/render/gpu_picking.js.map +1 -0
  29. package/dist/render/rendergraph/device_pool_allocator.js +41 -0
  30. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
  31. package/dist/render/rendergraph/executor.js +146 -0
  32. package/dist/render/rendergraph/executor.js.map +1 -0
  33. package/dist/render/rendergraph/forward_plus_builder.js +414 -0
  34. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
  35. package/dist/render/rendergraph/rendergraph.js +306 -0
  36. package/dist/render/rendergraph/rendergraph.js.map +1 -0
  37. package/dist/render/rendergraph/types.js +57 -0
  38. package/dist/render/rendergraph/types.js.map +1 -0
  39. package/dist/render/sky_motion_vector.js +85 -0
  40. package/dist/render/sky_motion_vector.js.map +1 -0
  41. package/dist/utility/serialization/scene/animation.js +3 -3
  42. package/dist/utility/serialization/scene/node.js +1 -1
  43. package/package.json +2 -2
  44. package/dist/animation/ik/ik_chain_builder.js +0 -68
  45. package/dist/animation/ik/ik_chain_builder.js.map +0 -1
  46. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  47. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  48. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  49. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  50. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  51. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  52. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  53. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  54. package/dist/src/animation/animation.js +0 -127
  55. package/dist/src/animation/animation.js.map +0 -1
  56. package/dist/src/animation/animationset.js +0 -255
  57. package/dist/src/animation/animationset.js.map +0 -1
  58. package/dist/src/animation/animationtrack.js +0 -34
  59. package/dist/src/animation/animationtrack.js.map +0 -1
  60. package/dist/src/animation/eulerrotationtrack.js +0 -52
  61. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  62. package/dist/src/animation/morphtarget.js +0 -93
  63. package/dist/src/animation/morphtarget.js.map +0 -1
  64. package/dist/src/animation/morphtrack.js +0 -70
  65. package/dist/src/animation/morphtrack.js.map +0 -1
  66. package/dist/src/animation/proptrack.js +0 -161
  67. package/dist/src/animation/proptrack.js.map +0 -1
  68. package/dist/src/animation/rotationtrack.js +0 -51
  69. package/dist/src/animation/rotationtrack.js.map +0 -1
  70. package/dist/src/animation/scaletrack.js +0 -50
  71. package/dist/src/animation/scaletrack.js.map +0 -1
  72. package/dist/src/animation/skeleton.js +0 -204
  73. package/dist/src/animation/skeleton.js.map +0 -1
  74. package/dist/src/animation/translationtrack.js +0 -50
  75. package/dist/src/animation/translationtrack.js.map +0 -1
  76. package/dist/src/app/app.js +0 -129
  77. package/dist/src/app/app.js.map +0 -1
  78. package/dist/src/app/inputmgr.js +0 -267
  79. package/dist/src/app/inputmgr.js.map +0 -1
  80. package/dist/src/asset/assetmanager.js +0 -404
  81. package/dist/src/asset/assetmanager.js.map +0 -1
  82. package/dist/src/asset/builtin.js +0 -337
  83. package/dist/src/asset/builtin.js.map +0 -1
  84. package/dist/src/asset/loaders/dds/dds.js +0 -470
  85. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  86. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  87. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  88. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  89. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  90. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  91. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  92. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  93. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  94. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  95. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  96. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  97. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  98. package/dist/src/asset/loaders/loader.js +0 -45
  99. package/dist/src/asset/loaders/loader.js.map +0 -1
  100. package/dist/src/asset/model.js +0 -414
  101. package/dist/src/asset/model.js.map +0 -1
  102. package/dist/src/blitter/bilateralblur.js +0 -221
  103. package/dist/src/blitter/bilateralblur.js.map +0 -1
  104. package/dist/src/blitter/blitter.js +0 -390
  105. package/dist/src/blitter/blitter.js.map +0 -1
  106. package/dist/src/blitter/box.js +0 -118
  107. package/dist/src/blitter/box.js.map +0 -1
  108. package/dist/src/blitter/copy.js +0 -22
  109. package/dist/src/blitter/copy.js.map +0 -1
  110. package/dist/src/blitter/gaussianblur.js +0 -228
  111. package/dist/src/blitter/gaussianblur.js.map +0 -1
  112. package/dist/src/camera/base.js +0 -92
  113. package/dist/src/camera/base.js.map +0 -1
  114. package/dist/src/camera/camera.js +0 -1005
  115. package/dist/src/camera/camera.js.map +0 -1
  116. package/dist/src/camera/fps.js +0 -238
  117. package/dist/src/camera/fps.js.map +0 -1
  118. package/dist/src/camera/orbit.js +0 -245
  119. package/dist/src/camera/orbit.js.map +0 -1
  120. package/dist/src/camera/orthocamera.js +0 -167
  121. package/dist/src/camera/orthocamera.js.map +0 -1
  122. package/dist/src/camera/perspectivecamera.js +0 -141
  123. package/dist/src/camera/perspectivecamera.js.map +0 -1
  124. package/dist/src/index.js +0 -120
  125. package/dist/src/index.js.map +0 -1
  126. package/dist/src/material/blinn.js +0 -81
  127. package/dist/src/material/blinn.js.map +0 -1
  128. package/dist/src/material/grassmaterial.js +0 -113
  129. package/dist/src/material/grassmaterial.js.map +0 -1
  130. package/dist/src/material/lambert.js +0 -92
  131. package/dist/src/material/lambert.js.map +0 -1
  132. package/dist/src/material/material.js +0 -301
  133. package/dist/src/material/material.js.map +0 -1
  134. package/dist/src/material/meshmaterial.js +0 -704
  135. package/dist/src/material/meshmaterial.js.map +0 -1
  136. package/dist/src/material/mixins/albedocolor.js +0 -76
  137. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  138. package/dist/src/material/mixins/foliage.js +0 -47
  139. package/dist/src/material/mixins/foliage.js.map +0 -1
  140. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  141. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  142. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  143. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  144. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  145. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  146. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  147. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  148. package/dist/src/material/mixins/lit.js +0 -476
  149. package/dist/src/material/mixins/lit.js.map +0 -1
  150. package/dist/src/material/mixins/pbr/common.js +0 -918
  151. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  152. package/dist/src/material/mixins/texture.js +0 -172
  153. package/dist/src/material/mixins/texture.js.map +0 -1
  154. package/dist/src/material/mixins/vertexcolor.js +0 -56
  155. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  156. package/dist/src/material/particle.js +0 -178
  157. package/dist/src/material/particle.js.map +0 -1
  158. package/dist/src/material/pbrmr.js +0 -97
  159. package/dist/src/material/pbrmr.js.map +0 -1
  160. package/dist/src/material/pbrsg.js +0 -97
  161. package/dist/src/material/pbrsg.js.map +0 -1
  162. package/dist/src/material/shader/helper.js +0 -1209
  163. package/dist/src/material/shader/helper.js.map +0 -1
  164. package/dist/src/material/terrain-cm.js +0 -606
  165. package/dist/src/material/terrain-cm.js.map +0 -1
  166. package/dist/src/material/terrainmaterial.js +0 -375
  167. package/dist/src/material/terrainmaterial.js.map +0 -1
  168. package/dist/src/material/unlit.js +0 -41
  169. package/dist/src/material/unlit.js.map +0 -1
  170. package/dist/src/material/water.js +0 -417
  171. package/dist/src/material/water.js.map +0 -1
  172. package/dist/src/posteffect/bloom.js +0 -361
  173. package/dist/src/posteffect/bloom.js.map +0 -1
  174. package/dist/src/posteffect/compositor.js +0 -226
  175. package/dist/src/posteffect/compositor.js.map +0 -1
  176. package/dist/src/posteffect/fxaa.js +0 -273
  177. package/dist/src/posteffect/fxaa.js.map +0 -1
  178. package/dist/src/posteffect/grayscale.js +0 -69
  179. package/dist/src/posteffect/grayscale.js.map +0 -1
  180. package/dist/src/posteffect/motionblur.js +0 -96
  181. package/dist/src/posteffect/motionblur.js.map +0 -1
  182. package/dist/src/posteffect/posteffect.js +0 -126
  183. package/dist/src/posteffect/posteffect.js.map +0 -1
  184. package/dist/src/posteffect/sao.js +0 -324
  185. package/dist/src/posteffect/sao.js.map +0 -1
  186. package/dist/src/posteffect/ssr.js +0 -489
  187. package/dist/src/posteffect/ssr.js.map +0 -1
  188. package/dist/src/posteffect/taa.js +0 -172
  189. package/dist/src/posteffect/taa.js.map +0 -1
  190. package/dist/src/posteffect/tonemap.js +0 -94
  191. package/dist/src/posteffect/tonemap.js.map +0 -1
  192. package/dist/src/render/abuffer_oit.js +0 -361
  193. package/dist/src/render/abuffer_oit.js.map +0 -1
  194. package/dist/src/render/clipmap.js +0 -851
  195. package/dist/src/render/clipmap.js.map +0 -1
  196. package/dist/src/render/cluster_light.js +0 -333
  197. package/dist/src/render/cluster_light.js.map +0 -1
  198. package/dist/src/render/cull_visitor.js +0 -187
  199. package/dist/src/render/cull_visitor.js.map +0 -1
  200. package/dist/src/render/depthpass.js +0 -68
  201. package/dist/src/render/depthpass.js.map +0 -1
  202. package/dist/src/render/drawable_mixin.js +0 -227
  203. package/dist/src/render/drawable_mixin.js.map +0 -1
  204. package/dist/src/render/envlight.js +0 -463
  205. package/dist/src/render/envlight.js.map +0 -1
  206. package/dist/src/render/fbm_wavegenerator.js +0 -251
  207. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  208. package/dist/src/render/fft_wavegenerator.js +0 -1006
  209. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  210. package/dist/src/render/fullscreenquad.js +0 -38
  211. package/dist/src/render/fullscreenquad.js.map +0 -1
  212. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  213. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  214. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  215. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  216. package/dist/src/render/hzb.js +0 -273
  217. package/dist/src/render/hzb.js.map +0 -1
  218. package/dist/src/render/lightpass.js +0 -172
  219. package/dist/src/render/lightpass.js.map +0 -1
  220. package/dist/src/render/objectcolorpass.js +0 -51
  221. package/dist/src/render/objectcolorpass.js.map +0 -1
  222. package/dist/src/render/primitive.js +0 -364
  223. package/dist/src/render/primitive.js.map +0 -1
  224. package/dist/src/render/render_queue.js +0 -467
  225. package/dist/src/render/render_queue.js.map +0 -1
  226. package/dist/src/render/renderbundle_wrapper.js +0 -152
  227. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  228. package/dist/src/render/renderer.js +0 -455
  229. package/dist/src/render/renderer.js.map +0 -1
  230. package/dist/src/render/renderpass.js +0 -200
  231. package/dist/src/render/renderpass.js.map +0 -1
  232. package/dist/src/render/shadowmap_pass.js +0 -56
  233. package/dist/src/render/shadowmap_pass.js.map +0 -1
  234. package/dist/src/render/sky.js +0 -1103
  235. package/dist/src/render/sky.js.map +0 -1
  236. package/dist/src/render/weightedblended_oit.js +0 -168
  237. package/dist/src/render/weightedblended_oit.js.map +0 -1
  238. package/dist/src/scene/batchgroup.js +0 -162
  239. package/dist/src/scene/batchgroup.js.map +0 -1
  240. package/dist/src/scene/environment.js +0 -209
  241. package/dist/src/scene/environment.js.map +0 -1
  242. package/dist/src/scene/graph_node.js +0 -72
  243. package/dist/src/scene/graph_node.js.map +0 -1
  244. package/dist/src/scene/light.js +0 -416
  245. package/dist/src/scene/light.js.map +0 -1
  246. package/dist/src/scene/mesh.js +0 -341
  247. package/dist/src/scene/mesh.js.map +0 -1
  248. package/dist/src/scene/octree.js +0 -649
  249. package/dist/src/scene/octree.js.map +0 -1
  250. package/dist/src/scene/particlesys.js +0 -738
  251. package/dist/src/scene/particlesys.js.map +0 -1
  252. package/dist/src/scene/raycast_visitor.js +0 -103
  253. package/dist/src/scene/raycast_visitor.js.map +0 -1
  254. package/dist/src/scene/scene.js +0 -284
  255. package/dist/src/scene/scene.js.map +0 -1
  256. package/dist/src/scene/scene_node.js +0 -732
  257. package/dist/src/scene/scene_node.js.map +0 -1
  258. package/dist/src/scene/terrain/grass.js +0 -278
  259. package/dist/src/scene/terrain/grass.js.map +0 -1
  260. package/dist/src/scene/terrain/heightfield.js +0 -475
  261. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  262. package/dist/src/scene/terrain/patch.js +0 -530
  263. package/dist/src/scene/terrain/patch.js.map +0 -1
  264. package/dist/src/scene/terrain/quadtree.js +0 -461
  265. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  266. package/dist/src/scene/terrain/terrain.js +0 -246
  267. package/dist/src/scene/terrain/terrain.js.map +0 -1
  268. package/dist/src/scene/terrain-cm/grass.js +0 -594
  269. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  270. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  271. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  272. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  273. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  274. package/dist/src/scene/water.js +0 -374
  275. package/dist/src/scene/water.js.map +0 -1
  276. package/dist/src/shaders/atmosphere.js +0 -957
  277. package/dist/src/shaders/atmosphere.js.map +0 -1
  278. package/dist/src/shaders/fog.js +0 -112
  279. package/dist/src/shaders/fog.js.map +0 -1
  280. package/dist/src/shaders/misc.js +0 -266
  281. package/dist/src/shaders/misc.js.map +0 -1
  282. package/dist/src/shaders/noise.js +0 -222
  283. package/dist/src/shaders/noise.js.map +0 -1
  284. package/dist/src/shaders/pbr.js +0 -51
  285. package/dist/src/shaders/pbr.js.map +0 -1
  286. package/dist/src/shaders/shadow.js +0 -636
  287. package/dist/src/shaders/shadow.js.map +0 -1
  288. package/dist/src/shaders/ssr.js +0 -490
  289. package/dist/src/shaders/ssr.js.map +0 -1
  290. package/dist/src/shaders/temporal.js +0 -215
  291. package/dist/src/shaders/temporal.js.map +0 -1
  292. package/dist/src/shaders/water.js +0 -756
  293. package/dist/src/shaders/water.js.map +0 -1
  294. package/dist/src/shadow/esm.js +0 -237
  295. package/dist/src/shadow/esm.js.map +0 -1
  296. package/dist/src/shadow/pcf_opt.js +0 -181
  297. package/dist/src/shadow/pcf_opt.js.map +0 -1
  298. package/dist/src/shadow/pcf_pd.js +0 -189
  299. package/dist/src/shadow/pcf_pd.js.map +0 -1
  300. package/dist/src/shadow/shader.js +0 -37
  301. package/dist/src/shadow/shader.js.map +0 -1
  302. package/dist/src/shadow/shadow_impl.js +0 -15
  303. package/dist/src/shadow/shadow_impl.js.map +0 -1
  304. package/dist/src/shadow/shadowmapper.js +0 -790
  305. package/dist/src/shadow/shadowmapper.js.map +0 -1
  306. package/dist/src/shadow/ssm.js +0 -159
  307. package/dist/src/shadow/ssm.js.map +0 -1
  308. package/dist/src/shadow/vsm.js +0 -297
  309. package/dist/src/shadow/vsm.js.map +0 -1
  310. package/dist/src/shapes/box.js +0 -386
  311. package/dist/src/shapes/box.js.map +0 -1
  312. package/dist/src/shapes/cylinder.js +0 -125
  313. package/dist/src/shapes/cylinder.js.map +0 -1
  314. package/dist/src/shapes/plane.js +0 -88
  315. package/dist/src/shapes/plane.js.map +0 -1
  316. package/dist/src/shapes/shape.js +0 -87
  317. package/dist/src/shapes/shape.js.map +0 -1
  318. package/dist/src/shapes/sphere.js +0 -114
  319. package/dist/src/shapes/sphere.js.map +0 -1
  320. package/dist/src/shapes/tetrahedron.js +0 -188
  321. package/dist/src/shapes/tetrahedron.js.map +0 -1
  322. package/dist/src/shapes/torus.js +0 -111
  323. package/dist/src/shapes/torus.js.map +0 -1
  324. package/dist/src/utility/aabbtree.js +0 -400
  325. package/dist/src/utility/aabbtree.js.map +0 -1
  326. package/dist/src/utility/bounding_volume.js +0 -29
  327. package/dist/src/utility/bounding_volume.js.map +0 -1
  328. package/dist/src/utility/debug.js +0 -28
  329. package/dist/src/utility/debug.js.map +0 -1
  330. package/dist/src/utility/draco/decoder.js +0 -116
  331. package/dist/src/utility/draco/decoder.js.map +0 -1
  332. package/dist/src/utility/misc.js +0 -105
  333. package/dist/src/utility/misc.js.map +0 -1
  334. package/dist/src/utility/panorama.js +0 -163
  335. package/dist/src/utility/panorama.js.map +0 -1
  336. package/dist/src/utility/pmrem.js +0 -354
  337. package/dist/src/utility/pmrem.js.map +0 -1
  338. package/dist/src/utility/rendermipmap.js +0 -115
  339. package/dist/src/utility/rendermipmap.js.map +0 -1
  340. package/dist/src/utility/serialization/json.js +0 -402
  341. package/dist/src/utility/serialization/json.js.map +0 -1
  342. package/dist/src/utility/serialization/manager.js +0 -623
  343. package/dist/src/utility/serialization/manager.js.map +0 -1
  344. package/dist/src/utility/serialization/scene/animation.js +0 -248
  345. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  346. package/dist/src/utility/serialization/scene/batch.js +0 -59
  347. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  348. package/dist/src/utility/serialization/scene/camera.js +0 -790
  349. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  350. package/dist/src/utility/serialization/scene/common.js +0 -222
  351. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  352. package/dist/src/utility/serialization/scene/light.js +0 -575
  353. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  354. package/dist/src/utility/serialization/scene/material.js +0 -1111
  355. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  356. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  357. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  358. package/dist/src/utility/serialization/scene/misc.js +0 -39
  359. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  360. package/dist/src/utility/serialization/scene/node.js +0 -451
  361. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  362. package/dist/src/utility/serialization/scene/particle.js +0 -425
  363. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  364. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  365. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  366. package/dist/src/utility/serialization/scene/scene.js +0 -704
  367. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  368. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  369. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  370. package/dist/src/utility/serialization/scene/water.js +0 -465
  371. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  372. package/dist/src/utility/shprojector.js +0 -297
  373. package/dist/src/utility/shprojector.js.map +0 -1
  374. package/dist/src/utility/textures/ggxlut.js +0 -213
  375. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  376. package/dist/src/utility/textures/gradientnoise.js +0 -62
  377. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  378. package/dist/src/utility/textures/randomnoise.js +0 -41
  379. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  380. package/dist/src/values.js +0 -162
  381. package/dist/src/values.js.map +0 -1
  382. package/dist/utility/blueprint/material/common.js +0 -7
  383. package/dist/utility/blueprint/material/common.js.map +0 -1
  384. package/dist/utility/serialization/blueprint/constants.js +0 -255
  385. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  386. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  387. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  388. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  389. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
@@ -1 +0,0 @@
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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"}
@@ -1,636 +0,0 @@
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