@zephyr3d/scene 0.9.5 → 0.9.7

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 (621) hide show
  1. package/dist/animation/joint_dynamics/controller.js +92 -32
  2. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  3. package/dist/animation/joint_dynamics/convex_collider.js +320 -0
  4. package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
  5. package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
  6. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  7. package/dist/animation/joint_dynamics/solver.js +71 -27
  8. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  9. package/dist/animation/joint_dynamics_modifier.js +21 -20
  10. package/dist/animation/joint_dynamics_modifier.js.map +1 -1
  11. package/dist/animation/skeleton.js +7 -10
  12. package/dist/animation/skeleton.js.map +1 -1
  13. package/dist/app/engine.js +134 -140
  14. package/dist/app/engine.js.map +1 -1
  15. package/dist/app/scriptregistry.js +47 -16
  16. package/dist/app/scriptregistry.js.map +1 -1
  17. package/dist/asset/assetmanager.js +3 -1
  18. package/dist/asset/assetmanager.js.map +1 -1
  19. package/dist/asset/model.js +346 -7
  20. package/dist/asset/model.js.map +1 -1
  21. package/dist/avatar/wardrobe.js +20 -16
  22. package/dist/avatar/wardrobe.js.map +1 -1
  23. package/dist/camera/camera.js +416 -210
  24. package/dist/camera/camera.js.map +1 -1
  25. package/dist/index.d.ts +1350 -621
  26. package/dist/index.js +6 -11
  27. package/dist/index.js.map +1 -1
  28. package/dist/material/blinn.js +1 -1
  29. package/dist/material/blinn.js.map +1 -1
  30. package/dist/material/lambert.js +1 -1
  31. package/dist/material/lambert.js.map +1 -1
  32. package/dist/material/material.js +23 -1
  33. package/dist/material/material.js.map +1 -1
  34. package/dist/material/meshmaterial.js +178 -23
  35. package/dist/material/meshmaterial.js.map +1 -1
  36. package/dist/material/mixins/albedocolor.js +4 -4
  37. package/dist/material/mixins/albedocolor.js.map +1 -1
  38. package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
  39. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  40. package/dist/material/mixins/lightmodel/lambert.js +2 -1
  41. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  42. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
  43. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  44. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
  45. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  46. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
  47. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  48. package/dist/material/mixins/lit.js +1 -1
  49. package/dist/material/mixins/lit.js.map +1 -1
  50. package/dist/material/mixins/pbr/common.js +276 -65
  51. package/dist/material/mixins/pbr/common.js.map +1 -1
  52. package/dist/material/mixins/texture.js +3 -3
  53. package/dist/material/mixins/texture.js.map +1 -1
  54. package/dist/material/mixins/vertexcolor.js +2 -2
  55. package/dist/material/mixins/vertexcolor.js.map +1 -1
  56. package/dist/material/msdf_text.js +3 -3
  57. package/dist/material/msdf_text.js.map +1 -1
  58. package/dist/material/mtoon.js +574 -0
  59. package/dist/material/mtoon.js.map +1 -0
  60. package/dist/material/pbrblueprint.js +499 -336
  61. package/dist/material/pbrblueprint.js.map +1 -1
  62. package/dist/material/pbrmr.js +118 -100
  63. package/dist/material/pbrmr.js.map +1 -1
  64. package/dist/material/pbrsg.js +1 -1
  65. package/dist/material/pbrsg.js.map +1 -1
  66. package/dist/material/shader/helper.js +324 -294
  67. package/dist/material/shader/helper.js.map +1 -1
  68. package/dist/material/subsurfaceprofile.js +812 -0
  69. package/dist/material/subsurfaceprofile.js.map +1 -0
  70. package/dist/material/unlit.js +1 -1
  71. package/dist/material/unlit.js.map +1 -1
  72. package/dist/posteffect/compositor.js +46 -11
  73. package/dist/posteffect/compositor.js.map +1 -1
  74. package/dist/posteffect/ssr.js +422 -96
  75. package/dist/posteffect/ssr.js.map +1 -1
  76. package/dist/posteffect/sss.js +1053 -0
  77. package/dist/posteffect/sss.js.map +1 -0
  78. package/dist/posteffect/taa.js +61 -60
  79. package/dist/posteffect/taa.js.map +1 -1
  80. package/dist/render/abuffer_oit.js +63 -12
  81. package/dist/render/abuffer_oit.js.map +1 -1
  82. package/dist/render/cluster_light.js +6 -5
  83. package/dist/render/cluster_light.js.map +1 -1
  84. package/dist/render/drawable.js +1 -5
  85. package/dist/render/drawable.js.map +1 -1
  86. package/dist/render/drawable_mixin.js +2 -1
  87. package/dist/render/drawable_mixin.js.map +1 -1
  88. package/dist/render/fbm_wavegenerator.js +2 -1
  89. package/dist/render/fbm_wavegenerator.js.map +1 -1
  90. package/dist/render/gerstner_wavegenerator.js +2 -1
  91. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  92. package/dist/render/globalbindgroup_allocator.js +2 -1
  93. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  94. package/dist/render/lightpass.js +110 -23
  95. package/dist/render/lightpass.js.map +1 -1
  96. package/dist/render/render_queue.js +51 -8
  97. package/dist/render/render_queue.js.map +1 -1
  98. package/dist/render/renderer.js +80 -66
  99. package/dist/render/renderer.js.map +1 -1
  100. package/dist/render/rendergraph/device_pool_allocator.js +8 -0
  101. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  102. package/dist/render/rendergraph/forward_plus_builder.js +481 -95
  103. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  104. package/dist/render/rendergraph/history_resource_manager.js +55 -0
  105. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  106. package/dist/render/rendergraph/history_resources.js +3 -1
  107. package/dist/render/rendergraph/history_resources.js.map +1 -1
  108. package/dist/render/rendergraph/types.js.map +1 -1
  109. package/dist/render/renderpass.js +10 -4
  110. package/dist/render/renderpass.js.map +1 -1
  111. package/dist/render/sky.js +31 -1
  112. package/dist/render/sky.js.map +1 -1
  113. package/dist/render/weightedblended_oit.js +23 -5
  114. package/dist/render/weightedblended_oit.js.map +1 -1
  115. package/dist/scene/basesprite.js +4 -2
  116. package/dist/scene/basesprite.js.map +1 -1
  117. package/dist/scene/batchgroup.js +3 -1
  118. package/dist/scene/batchgroup.js.map +1 -1
  119. package/dist/scene/environment.js +11 -1
  120. package/dist/scene/environment.js.map +1 -1
  121. package/dist/scene/light.js +21 -3
  122. package/dist/scene/light.js.map +1 -1
  123. package/dist/scene/mesh.js +29 -14
  124. package/dist/scene/mesh.js.map +1 -1
  125. package/dist/scene/meshdrawable.js +6 -0
  126. package/dist/scene/meshdrawable.js.map +1 -1
  127. package/dist/scene/msdftext.js +5 -2
  128. package/dist/scene/msdftext.js.map +1 -1
  129. package/dist/scene/msdftextsprite.js +5 -3
  130. package/dist/scene/msdftextsprite.js.map +1 -1
  131. package/dist/scene/particlesys.js +3 -1
  132. package/dist/scene/particlesys.js.map +1 -1
  133. package/dist/scene/scene.js +6 -5
  134. package/dist/scene/scene.js.map +1 -1
  135. package/dist/scene/terrain-cm/grass.js +4 -2
  136. package/dist/scene/terrain-cm/grass.js.map +1 -1
  137. package/dist/scene/terrain-cm/grassmaterial.js +2 -1
  138. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  139. package/dist/scene/terrain-cm/terrain-cm.js +4 -2
  140. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  141. package/dist/scene/water.js +4 -2
  142. package/dist/scene/water.js.map +1 -1
  143. package/dist/shaders/shadow.js +26 -393
  144. package/dist/shaders/shadow.js.map +1 -1
  145. package/dist/shadow/esm.js +112 -12
  146. package/dist/shadow/esm.js.map +1 -1
  147. package/dist/shadow/pcf_opt.js +2 -2
  148. package/dist/shadow/pcf_opt.js.map +1 -1
  149. package/dist/shadow/pcf_pd.js +19 -10
  150. package/dist/shadow/pcf_pd.js.map +1 -1
  151. package/dist/shadow/shader.js +58 -7
  152. package/dist/shadow/shader.js.map +1 -1
  153. package/dist/shadow/shadow_impl.js +6 -0
  154. package/dist/shadow/shadow_impl.js.map +1 -1
  155. package/dist/shadow/shadow_region.js +229 -0
  156. package/dist/shadow/shadow_region.js.map +1 -0
  157. package/dist/shadow/shadowmapper.js +67 -59
  158. package/dist/shadow/shadowmapper.js.map +1 -1
  159. package/dist/shadow/vsm.js +45 -19
  160. package/dist/shadow/vsm.js.map +1 -1
  161. package/dist/text/font/cff_font.js +890 -0
  162. package/dist/text/font/cff_font.js.map +1 -0
  163. package/dist/text/font/font_asset.js +17 -3
  164. package/dist/text/font/font_asset.js.map +1 -1
  165. package/dist/utility/blueprint/common/constants.js +8 -8
  166. package/dist/utility/blueprint/common/constants.js.map +1 -1
  167. package/dist/utility/blueprint/material/pbr.js +31 -4
  168. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  169. package/dist/utility/blueprint/material/texture.js +1 -17
  170. package/dist/utility/blueprint/material/texture.js.map +1 -1
  171. package/dist/utility/serialization/manager.js +327 -359
  172. package/dist/utility/serialization/manager.js.map +1 -1
  173. package/dist/utility/serialization/scene/animation.js +5 -2
  174. package/dist/utility/serialization/scene/animation.js.map +1 -1
  175. package/dist/utility/serialization/scene/batch.js +4 -1
  176. package/dist/utility/serialization/scene/batch.js.map +1 -1
  177. package/dist/utility/serialization/scene/camera.js +249 -54
  178. package/dist/utility/serialization/scene/camera.js.map +1 -1
  179. package/dist/utility/serialization/scene/common.js +37 -1
  180. package/dist/utility/serialization/scene/common.js.map +1 -1
  181. package/dist/utility/serialization/scene/light.js +42 -3
  182. package/dist/utility/serialization/scene/light.js.map +1 -1
  183. package/dist/utility/serialization/scene/material.js +1112 -646
  184. package/dist/utility/serialization/scene/material.js.map +1 -1
  185. package/dist/utility/serialization/scene/mesh.js +7 -4
  186. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  187. package/dist/utility/serialization/scene/node.js +31 -12
  188. package/dist/utility/serialization/scene/node.js.map +1 -1
  189. package/dist/utility/serialization/scene/particle.js +4 -1
  190. package/dist/utility/serialization/scene/particle.js.map +1 -1
  191. package/dist/utility/serialization/scene/primitive.js +3 -1
  192. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  193. package/dist/utility/serialization/scene/scene.js +18 -0
  194. package/dist/utility/serialization/scene/scene.js.map +1 -1
  195. package/dist/utility/serialization/scene/sprite.js +6 -3
  196. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  197. package/dist/utility/serialization/scene/terrain.js +5 -2
  198. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  199. package/dist/utility/serialization/scene/text.js +3 -1
  200. package/dist/utility/serialization/scene/text.js.map +1 -1
  201. package/dist/utility/serialization/scene/water.js +4 -1
  202. package/dist/utility/serialization/scene/water.js.map +1 -1
  203. package/dist/utility/textures/ltcdata.js +6 -0
  204. package/dist/utility/textures/ltcdata.js.map +1 -0
  205. package/dist/utility/textures/ltclut.js +61 -0
  206. package/dist/utility/textures/ltclut.js.map +1 -0
  207. package/dist/values.js +9 -1
  208. package/dist/values.js.map +1 -1
  209. package/package.json +3 -3
  210. package/dist/animation/ik/ik_chain_builder.js +0 -68
  211. package/dist/animation/ik/ik_chain_builder.js.map +0 -1
  212. package/dist/animation/ik/ik_pole_constraint.js +0 -123
  213. package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
  214. package/dist/animation/ik/ik_track.js +0 -96
  215. package/dist/animation/ik/ik_track.js.map +0 -1
  216. package/dist/animation/ik_postprocessor.js +0 -71
  217. package/dist/animation/ik_postprocessor.js.map +0 -1
  218. package/dist/animation/joint_dynamics/math.js +0 -16
  219. package/dist/animation/joint_dynamics/math.js.map +0 -1
  220. package/dist/animation/manual_transform_processor.js +0 -156
  221. package/dist/animation/manual_transform_processor.js.map +0 -1
  222. package/dist/animation/skeleton_postprocessor.js +0 -50
  223. package/dist/animation/skeleton_postprocessor.js.map +0 -1
  224. package/dist/animation/spring2/collision.js +0 -469
  225. package/dist/animation/spring2/collision.js.map +0 -1
  226. package/dist/animation/spring2/constraints.js +0 -329
  227. package/dist/animation/spring2/constraints.js.map +0 -1
  228. package/dist/animation/spring2/controller.js +0 -434
  229. package/dist/animation/spring2/controller.js.map +0 -1
  230. package/dist/animation/spring2/math.js +0 -16
  231. package/dist/animation/spring2/math.js.map +0 -1
  232. package/dist/animation/spring2/solver.js +0 -624
  233. package/dist/animation/spring2/solver.js.map +0 -1
  234. package/dist/animation/spring2/spring_system.js +0 -118
  235. package/dist/animation/spring2/spring_system.js.map +0 -1
  236. package/dist/animation/spring2/types.js +0 -19
  237. package/dist/animation/spring2/types.js.map +0 -1
  238. package/dist/animation/spring_postprocessor.js +0 -54
  239. package/dist/animation/spring_postprocessor.js.map +0 -1
  240. package/dist/asset/loaders/gltf/gltf_loader.js +0 -1276
  241. package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
  242. package/dist/asset/loaders/gltf/helpers.js +0 -331
  243. package/dist/asset/loaders/gltf/helpers.js.map +0 -1
  244. package/dist/material/sprite3d.js +0 -301
  245. package/dist/material/sprite3d.js.map +0 -1
  246. package/dist/material/sprite3d_std.js +0 -116
  247. package/dist/material/sprite3d_std.js.map +0 -1
  248. package/dist/material/sprite3dblueprint.js +0 -235
  249. package/dist/material/sprite3dblueprint.js.map +0 -1
  250. package/dist/material/sprite_sdf.js +0 -106
  251. package/dist/material/sprite_sdf.js.map +0 -1
  252. package/dist/material/terrainmaterial.js +0 -368
  253. package/dist/material/terrainmaterial.js.map +0 -1
  254. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  255. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  256. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  257. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  258. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  259. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  260. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  261. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  262. package/dist/render/deferredlightpass.js +0 -510
  263. package/dist/render/deferredlightpass.js.map +0 -1
  264. package/dist/render/deferredshadowlightpass.js +0 -428
  265. package/dist/render/deferredshadowlightpass.js.map +0 -1
  266. package/dist/render/gbufferpass.js +0 -50
  267. package/dist/render/gbufferpass.js.map +0 -1
  268. package/dist/scene/sdftextsprite.js +0 -322
  269. package/dist/scene/sdftextsprite.js.map +0 -1
  270. package/dist/scene/sprite3d.js +0 -18
  271. package/dist/scene/sprite3d.js.map +0 -1
  272. package/dist/scene/terrain/grass.js +0 -280
  273. package/dist/scene/terrain/grass.js.map +0 -1
  274. package/dist/scene/terrain/heightfield.js +0 -475
  275. package/dist/scene/terrain/heightfield.js.map +0 -1
  276. package/dist/scene/terrain/patch.js +0 -532
  277. package/dist/scene/terrain/patch.js.map +0 -1
  278. package/dist/scene/terrain/quadtree.js +0 -461
  279. package/dist/scene/terrain/quadtree.js.map +0 -1
  280. package/dist/scene/terrain/terrain.js +0 -231
  281. package/dist/scene/terrain/terrain.js.map +0 -1
  282. package/dist/src/animation/animation.js +0 -127
  283. package/dist/src/animation/animation.js.map +0 -1
  284. package/dist/src/animation/animationset.js +0 -255
  285. package/dist/src/animation/animationset.js.map +0 -1
  286. package/dist/src/animation/animationtrack.js +0 -34
  287. package/dist/src/animation/animationtrack.js.map +0 -1
  288. package/dist/src/animation/eulerrotationtrack.js +0 -52
  289. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  290. package/dist/src/animation/morphtarget.js +0 -93
  291. package/dist/src/animation/morphtarget.js.map +0 -1
  292. package/dist/src/animation/morphtrack.js +0 -70
  293. package/dist/src/animation/morphtrack.js.map +0 -1
  294. package/dist/src/animation/proptrack.js +0 -161
  295. package/dist/src/animation/proptrack.js.map +0 -1
  296. package/dist/src/animation/rotationtrack.js +0 -51
  297. package/dist/src/animation/rotationtrack.js.map +0 -1
  298. package/dist/src/animation/scaletrack.js +0 -50
  299. package/dist/src/animation/scaletrack.js.map +0 -1
  300. package/dist/src/animation/skeleton.js +0 -204
  301. package/dist/src/animation/skeleton.js.map +0 -1
  302. package/dist/src/animation/translationtrack.js +0 -50
  303. package/dist/src/animation/translationtrack.js.map +0 -1
  304. package/dist/src/app/app.js +0 -129
  305. package/dist/src/app/app.js.map +0 -1
  306. package/dist/src/app/inputmgr.js +0 -267
  307. package/dist/src/app/inputmgr.js.map +0 -1
  308. package/dist/src/asset/assetmanager.js +0 -404
  309. package/dist/src/asset/assetmanager.js.map +0 -1
  310. package/dist/src/asset/builtin.js +0 -337
  311. package/dist/src/asset/builtin.js.map +0 -1
  312. package/dist/src/asset/loaders/dds/dds.js +0 -470
  313. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  314. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  315. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  316. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  317. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  318. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  319. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  320. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  321. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  322. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  323. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  324. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  325. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  326. package/dist/src/asset/loaders/loader.js +0 -45
  327. package/dist/src/asset/loaders/loader.js.map +0 -1
  328. package/dist/src/asset/model.js +0 -414
  329. package/dist/src/asset/model.js.map +0 -1
  330. package/dist/src/blitter/bilateralblur.js +0 -221
  331. package/dist/src/blitter/bilateralblur.js.map +0 -1
  332. package/dist/src/blitter/blitter.js +0 -390
  333. package/dist/src/blitter/blitter.js.map +0 -1
  334. package/dist/src/blitter/box.js +0 -118
  335. package/dist/src/blitter/box.js.map +0 -1
  336. package/dist/src/blitter/copy.js +0 -22
  337. package/dist/src/blitter/copy.js.map +0 -1
  338. package/dist/src/blitter/gaussianblur.js +0 -228
  339. package/dist/src/blitter/gaussianblur.js.map +0 -1
  340. package/dist/src/camera/base.js +0 -92
  341. package/dist/src/camera/base.js.map +0 -1
  342. package/dist/src/camera/camera.js +0 -1005
  343. package/dist/src/camera/camera.js.map +0 -1
  344. package/dist/src/camera/fps.js +0 -238
  345. package/dist/src/camera/fps.js.map +0 -1
  346. package/dist/src/camera/orbit.js +0 -245
  347. package/dist/src/camera/orbit.js.map +0 -1
  348. package/dist/src/camera/orthocamera.js +0 -167
  349. package/dist/src/camera/orthocamera.js.map +0 -1
  350. package/dist/src/camera/perspectivecamera.js +0 -141
  351. package/dist/src/camera/perspectivecamera.js.map +0 -1
  352. package/dist/src/index.js +0 -120
  353. package/dist/src/index.js.map +0 -1
  354. package/dist/src/material/blinn.js +0 -81
  355. package/dist/src/material/blinn.js.map +0 -1
  356. package/dist/src/material/grassmaterial.js +0 -113
  357. package/dist/src/material/grassmaterial.js.map +0 -1
  358. package/dist/src/material/lambert.js +0 -92
  359. package/dist/src/material/lambert.js.map +0 -1
  360. package/dist/src/material/material.js +0 -301
  361. package/dist/src/material/material.js.map +0 -1
  362. package/dist/src/material/meshmaterial.js +0 -704
  363. package/dist/src/material/meshmaterial.js.map +0 -1
  364. package/dist/src/material/mixins/albedocolor.js +0 -76
  365. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  366. package/dist/src/material/mixins/foliage.js +0 -47
  367. package/dist/src/material/mixins/foliage.js.map +0 -1
  368. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  369. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  370. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  371. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  372. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  373. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  374. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  375. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  376. package/dist/src/material/mixins/lit.js +0 -476
  377. package/dist/src/material/mixins/lit.js.map +0 -1
  378. package/dist/src/material/mixins/pbr/common.js +0 -918
  379. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  380. package/dist/src/material/mixins/texture.js +0 -172
  381. package/dist/src/material/mixins/texture.js.map +0 -1
  382. package/dist/src/material/mixins/vertexcolor.js +0 -56
  383. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  384. package/dist/src/material/particle.js +0 -178
  385. package/dist/src/material/particle.js.map +0 -1
  386. package/dist/src/material/pbrmr.js +0 -97
  387. package/dist/src/material/pbrmr.js.map +0 -1
  388. package/dist/src/material/pbrsg.js +0 -97
  389. package/dist/src/material/pbrsg.js.map +0 -1
  390. package/dist/src/material/shader/helper.js +0 -1209
  391. package/dist/src/material/shader/helper.js.map +0 -1
  392. package/dist/src/material/terrain-cm.js +0 -606
  393. package/dist/src/material/terrain-cm.js.map +0 -1
  394. package/dist/src/material/terrainmaterial.js +0 -375
  395. package/dist/src/material/terrainmaterial.js.map +0 -1
  396. package/dist/src/material/unlit.js +0 -41
  397. package/dist/src/material/unlit.js.map +0 -1
  398. package/dist/src/material/water.js +0 -417
  399. package/dist/src/material/water.js.map +0 -1
  400. package/dist/src/posteffect/bloom.js +0 -361
  401. package/dist/src/posteffect/bloom.js.map +0 -1
  402. package/dist/src/posteffect/compositor.js +0 -226
  403. package/dist/src/posteffect/compositor.js.map +0 -1
  404. package/dist/src/posteffect/fxaa.js +0 -273
  405. package/dist/src/posteffect/fxaa.js.map +0 -1
  406. package/dist/src/posteffect/grayscale.js +0 -69
  407. package/dist/src/posteffect/grayscale.js.map +0 -1
  408. package/dist/src/posteffect/motionblur.js +0 -96
  409. package/dist/src/posteffect/motionblur.js.map +0 -1
  410. package/dist/src/posteffect/posteffect.js +0 -126
  411. package/dist/src/posteffect/posteffect.js.map +0 -1
  412. package/dist/src/posteffect/sao.js +0 -324
  413. package/dist/src/posteffect/sao.js.map +0 -1
  414. package/dist/src/posteffect/ssr.js +0 -489
  415. package/dist/src/posteffect/ssr.js.map +0 -1
  416. package/dist/src/posteffect/taa.js +0 -172
  417. package/dist/src/posteffect/taa.js.map +0 -1
  418. package/dist/src/posteffect/tonemap.js +0 -94
  419. package/dist/src/posteffect/tonemap.js.map +0 -1
  420. package/dist/src/render/abuffer_oit.js +0 -361
  421. package/dist/src/render/abuffer_oit.js.map +0 -1
  422. package/dist/src/render/clipmap.js +0 -851
  423. package/dist/src/render/clipmap.js.map +0 -1
  424. package/dist/src/render/cluster_light.js +0 -333
  425. package/dist/src/render/cluster_light.js.map +0 -1
  426. package/dist/src/render/cull_visitor.js +0 -187
  427. package/dist/src/render/cull_visitor.js.map +0 -1
  428. package/dist/src/render/depthpass.js +0 -68
  429. package/dist/src/render/depthpass.js.map +0 -1
  430. package/dist/src/render/drawable_mixin.js +0 -227
  431. package/dist/src/render/drawable_mixin.js.map +0 -1
  432. package/dist/src/render/envlight.js +0 -463
  433. package/dist/src/render/envlight.js.map +0 -1
  434. package/dist/src/render/fbm_wavegenerator.js +0 -251
  435. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  436. package/dist/src/render/fft_wavegenerator.js +0 -1006
  437. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  438. package/dist/src/render/fullscreenquad.js +0 -38
  439. package/dist/src/render/fullscreenquad.js.map +0 -1
  440. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  441. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  442. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  443. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  444. package/dist/src/render/hzb.js +0 -273
  445. package/dist/src/render/hzb.js.map +0 -1
  446. package/dist/src/render/lightpass.js +0 -172
  447. package/dist/src/render/lightpass.js.map +0 -1
  448. package/dist/src/render/objectcolorpass.js +0 -51
  449. package/dist/src/render/objectcolorpass.js.map +0 -1
  450. package/dist/src/render/primitive.js +0 -364
  451. package/dist/src/render/primitive.js.map +0 -1
  452. package/dist/src/render/render_queue.js +0 -467
  453. package/dist/src/render/render_queue.js.map +0 -1
  454. package/dist/src/render/renderbundle_wrapper.js +0 -152
  455. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  456. package/dist/src/render/renderer.js +0 -455
  457. package/dist/src/render/renderer.js.map +0 -1
  458. package/dist/src/render/renderpass.js +0 -200
  459. package/dist/src/render/renderpass.js.map +0 -1
  460. package/dist/src/render/shadowmap_pass.js +0 -56
  461. package/dist/src/render/shadowmap_pass.js.map +0 -1
  462. package/dist/src/render/sky.js +0 -1103
  463. package/dist/src/render/sky.js.map +0 -1
  464. package/dist/src/render/weightedblended_oit.js +0 -168
  465. package/dist/src/render/weightedblended_oit.js.map +0 -1
  466. package/dist/src/scene/batchgroup.js +0 -162
  467. package/dist/src/scene/batchgroup.js.map +0 -1
  468. package/dist/src/scene/environment.js +0 -209
  469. package/dist/src/scene/environment.js.map +0 -1
  470. package/dist/src/scene/graph_node.js +0 -72
  471. package/dist/src/scene/graph_node.js.map +0 -1
  472. package/dist/src/scene/light.js +0 -416
  473. package/dist/src/scene/light.js.map +0 -1
  474. package/dist/src/scene/mesh.js +0 -341
  475. package/dist/src/scene/mesh.js.map +0 -1
  476. package/dist/src/scene/octree.js +0 -649
  477. package/dist/src/scene/octree.js.map +0 -1
  478. package/dist/src/scene/particlesys.js +0 -738
  479. package/dist/src/scene/particlesys.js.map +0 -1
  480. package/dist/src/scene/raycast_visitor.js +0 -103
  481. package/dist/src/scene/raycast_visitor.js.map +0 -1
  482. package/dist/src/scene/scene.js +0 -284
  483. package/dist/src/scene/scene.js.map +0 -1
  484. package/dist/src/scene/scene_node.js +0 -732
  485. package/dist/src/scene/scene_node.js.map +0 -1
  486. package/dist/src/scene/terrain/grass.js +0 -278
  487. package/dist/src/scene/terrain/grass.js.map +0 -1
  488. package/dist/src/scene/terrain/heightfield.js +0 -475
  489. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  490. package/dist/src/scene/terrain/patch.js +0 -530
  491. package/dist/src/scene/terrain/patch.js.map +0 -1
  492. package/dist/src/scene/terrain/quadtree.js +0 -461
  493. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  494. package/dist/src/scene/terrain/terrain.js +0 -246
  495. package/dist/src/scene/terrain/terrain.js.map +0 -1
  496. package/dist/src/scene/terrain-cm/grass.js +0 -594
  497. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  498. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  499. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  500. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  501. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  502. package/dist/src/scene/water.js +0 -374
  503. package/dist/src/scene/water.js.map +0 -1
  504. package/dist/src/shaders/atmosphere.js +0 -957
  505. package/dist/src/shaders/atmosphere.js.map +0 -1
  506. package/dist/src/shaders/fog.js +0 -112
  507. package/dist/src/shaders/fog.js.map +0 -1
  508. package/dist/src/shaders/misc.js +0 -266
  509. package/dist/src/shaders/misc.js.map +0 -1
  510. package/dist/src/shaders/noise.js +0 -222
  511. package/dist/src/shaders/noise.js.map +0 -1
  512. package/dist/src/shaders/pbr.js +0 -51
  513. package/dist/src/shaders/pbr.js.map +0 -1
  514. package/dist/src/shaders/shadow.js +0 -636
  515. package/dist/src/shaders/shadow.js.map +0 -1
  516. package/dist/src/shaders/ssr.js +0 -490
  517. package/dist/src/shaders/ssr.js.map +0 -1
  518. package/dist/src/shaders/temporal.js +0 -215
  519. package/dist/src/shaders/temporal.js.map +0 -1
  520. package/dist/src/shaders/water.js +0 -756
  521. package/dist/src/shaders/water.js.map +0 -1
  522. package/dist/src/shadow/esm.js +0 -237
  523. package/dist/src/shadow/esm.js.map +0 -1
  524. package/dist/src/shadow/pcf_opt.js +0 -181
  525. package/dist/src/shadow/pcf_opt.js.map +0 -1
  526. package/dist/src/shadow/pcf_pd.js +0 -189
  527. package/dist/src/shadow/pcf_pd.js.map +0 -1
  528. package/dist/src/shadow/shader.js +0 -37
  529. package/dist/src/shadow/shader.js.map +0 -1
  530. package/dist/src/shadow/shadow_impl.js +0 -15
  531. package/dist/src/shadow/shadow_impl.js.map +0 -1
  532. package/dist/src/shadow/shadowmapper.js +0 -790
  533. package/dist/src/shadow/shadowmapper.js.map +0 -1
  534. package/dist/src/shadow/ssm.js +0 -159
  535. package/dist/src/shadow/ssm.js.map +0 -1
  536. package/dist/src/shadow/vsm.js +0 -297
  537. package/dist/src/shadow/vsm.js.map +0 -1
  538. package/dist/src/shapes/box.js +0 -386
  539. package/dist/src/shapes/box.js.map +0 -1
  540. package/dist/src/shapes/cylinder.js +0 -125
  541. package/dist/src/shapes/cylinder.js.map +0 -1
  542. package/dist/src/shapes/plane.js +0 -88
  543. package/dist/src/shapes/plane.js.map +0 -1
  544. package/dist/src/shapes/shape.js +0 -87
  545. package/dist/src/shapes/shape.js.map +0 -1
  546. package/dist/src/shapes/sphere.js +0 -114
  547. package/dist/src/shapes/sphere.js.map +0 -1
  548. package/dist/src/shapes/tetrahedron.js +0 -188
  549. package/dist/src/shapes/tetrahedron.js.map +0 -1
  550. package/dist/src/shapes/torus.js +0 -111
  551. package/dist/src/shapes/torus.js.map +0 -1
  552. package/dist/src/utility/aabbtree.js +0 -400
  553. package/dist/src/utility/aabbtree.js.map +0 -1
  554. package/dist/src/utility/bounding_volume.js +0 -29
  555. package/dist/src/utility/bounding_volume.js.map +0 -1
  556. package/dist/src/utility/debug.js +0 -28
  557. package/dist/src/utility/debug.js.map +0 -1
  558. package/dist/src/utility/draco/decoder.js +0 -116
  559. package/dist/src/utility/draco/decoder.js.map +0 -1
  560. package/dist/src/utility/misc.js +0 -105
  561. package/dist/src/utility/misc.js.map +0 -1
  562. package/dist/src/utility/panorama.js +0 -163
  563. package/dist/src/utility/panorama.js.map +0 -1
  564. package/dist/src/utility/pmrem.js +0 -354
  565. package/dist/src/utility/pmrem.js.map +0 -1
  566. package/dist/src/utility/rendermipmap.js +0 -115
  567. package/dist/src/utility/rendermipmap.js.map +0 -1
  568. package/dist/src/utility/serialization/json.js +0 -402
  569. package/dist/src/utility/serialization/json.js.map +0 -1
  570. package/dist/src/utility/serialization/manager.js +0 -623
  571. package/dist/src/utility/serialization/manager.js.map +0 -1
  572. package/dist/src/utility/serialization/scene/animation.js +0 -248
  573. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  574. package/dist/src/utility/serialization/scene/batch.js +0 -59
  575. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  576. package/dist/src/utility/serialization/scene/camera.js +0 -790
  577. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  578. package/dist/src/utility/serialization/scene/common.js +0 -222
  579. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  580. package/dist/src/utility/serialization/scene/light.js +0 -575
  581. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  582. package/dist/src/utility/serialization/scene/material.js +0 -1111
  583. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  584. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  585. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  586. package/dist/src/utility/serialization/scene/misc.js +0 -39
  587. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  588. package/dist/src/utility/serialization/scene/node.js +0 -451
  589. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  590. package/dist/src/utility/serialization/scene/particle.js +0 -425
  591. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  592. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  593. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  594. package/dist/src/utility/serialization/scene/scene.js +0 -704
  595. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  596. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  597. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  598. package/dist/src/utility/serialization/scene/water.js +0 -465
  599. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  600. package/dist/src/utility/shprojector.js +0 -297
  601. package/dist/src/utility/shprojector.js.map +0 -1
  602. package/dist/src/utility/textures/ggxlut.js +0 -213
  603. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  604. package/dist/src/utility/textures/gradientnoise.js +0 -62
  605. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  606. package/dist/src/utility/textures/randomnoise.js +0 -41
  607. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  608. package/dist/src/values.js +0 -162
  609. package/dist/src/values.js.map +0 -1
  610. package/dist/utility/blueprint/material/common.js +0 -7
  611. package/dist/utility/blueprint/material/common.js.map +0 -1
  612. package/dist/utility/serialization/blueprint/constants.js +0 -255
  613. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  614. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  615. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  616. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  617. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
  618. package/dist/utility/serialization/scene/cloth_script.js +0 -834
  619. package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
  620. package/dist/utility/serialization/scene/spring_script.js +0 -596
  621. package/dist/utility/serialization/scene/spring_script.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Vector3, Vector4, Vector2 } from '@zephyr3d/base';
2
- import { RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_LIGHT, MaterialVaryingFlags, MORPH_WEIGHTS_VECTOR_COUNT, MORPH_TARGET_POSITION, MORPH_TARGET_NORMAL, MORPH_TARGET_TANGENT, MORPH_ATTRIBUTE_VECTOR_COUNT } from '../../values.js';
2
+ import { RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_LIGHT, MaterialVaryingFlags, MAX_CLUSTERED_LIGHTS, MORPH_WEIGHTS_VECTOR_COUNT, MORPH_TARGET_POSITION, MORPH_TARGET_NORMAL, MORPH_TARGET_TANGENT, MORPH_ATTRIBUTE_VECTOR_COUNT } from '../../values.js';
3
3
  import { ProgramBuilder } from '@zephyr3d/device';
4
4
  import { decodeNormalizedFloatFromRGBA, linearToGamma } from '../../shaders/misc.js';
5
5
  import { fetchSampler } from '../../utility/misc.js';
@@ -31,9 +31,9 @@ const UNIFORM_NAME_BONE_TEXTURE_SIZE = 'Z_UniformBoneTexSize';
31
31
  const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
32
32
  const UNIFORM_NAME_MORPH_DATA = 'Z_UniformMorphData';
33
33
  const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
34
- /**
35
- * Helper shader functions for the builtin material system
36
- * @public
34
+ /**
35
+ * Helper shader functions for the builtin material system
36
+ * @public
37
37
  */ class ShaderHelper {
38
38
  static BILLBOARD_SPHERICAL = 1;
39
39
  static BILLBOARD_SYLINDRAL = 2;
@@ -45,7 +45,6 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
45
45
  /** @internal */ static _drawableBindGroupLayouts = {};
46
46
  /** @internal */ static _lightUniformShadow = {
47
47
  sunDir: new Vector3(),
48
- envLightStrength: 1,
49
48
  shadowCascades: 1,
50
49
  positionAndRange: new Vector4(),
51
50
  directionAndCutoff: new Vector4(),
@@ -55,7 +54,10 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
55
54
  depthBiasValues: new Vector4(),
56
55
  shadowCameraParams: new Vector4(),
57
56
  depthBiasScales: new Vector4(),
58
- shadowMatrices: new Float32Array(16 * 4)
57
+ shadowMatrices: new Float32Array(16 * 4),
58
+ shadowStrength: 1,
59
+ envLightStrength: 1,
60
+ envLightSpecularStrength: 1
59
61
  };
60
62
  /** @internal */ static _fogUniforms = {
61
63
  withAerialPerspective: 0,
@@ -122,25 +124,25 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
122
124
  }
123
125
  return bindGroupLayout;
124
126
  }
125
- /**
126
- * Prepares the fragment shader which is going to be used in our material system
127
- *
128
- * @remarks
129
- * This function will setup all nessesary uniforms acoording to the drawing context
130
- *
131
- * @param pb - The program builder
132
- * @param ctx - The drawing context
127
+ /**
128
+ * Prepares the fragment shader which is going to be used in our material system
129
+ *
130
+ * @remarks
131
+ * This function will setup all nessesary uniforms acoording to the drawing context
132
+ *
133
+ * @param pb - The program builder
134
+ * @param ctx - The drawing context
133
135
  */ static prepareFragmentShader(pb, ctx) {
134
136
  this.setupGlobalUniforms(pb, ctx);
135
137
  }
136
- /**
137
- * Prepares the vertex shader which is going to be used in our material system
138
- *
139
- * @remarks
140
- * This function will setup all nessesary uniforms according to the drawing context
141
- *
142
- * @param pb - The program builder
143
- * @param ctx - The drawing context
138
+ /**
139
+ * Prepares the vertex shader which is going to be used in our material system
140
+ *
141
+ * @remarks
142
+ * This function will setup all nessesary uniforms according to the drawing context
143
+ *
144
+ * @param pb - The program builder
145
+ * @param ctx - The drawing context
144
146
  */ static prepareVertexShader(pb, ctx) {
145
147
  this.setupGlobalUniforms(pb, ctx);
146
148
  this.prepareVertexShaderCommon(pb, ctx);
@@ -164,6 +166,7 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
164
166
  pb.vec2('renderSize'),
165
167
  pb.vec2('jitterValue'),
166
168
  pb.float('roughnessFactor'),
169
+ pb.float('shadowDebugCascades'),
167
170
  pb.float('frameDeltaTime'),
168
171
  pb.float('elapsedTime'),
169
172
  pb.int('framestamp')
@@ -207,10 +210,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
207
210
  pb.vec4('shadowCameraParams'),
208
211
  pb.vec4('depthBiasScales'),
209
212
  pb.vec4[16]('shadowMatrices'),
210
- pb.float('envLightStrength')
213
+ pb.float('shadowStrength'),
214
+ pb.float('envLightStrength'),
215
+ pb.float('envLightSpecularStrength')
211
216
  ]) : pb.defineStruct([
212
217
  pb.vec3('sunDir'),
213
218
  pb.float('envLightStrength'),
219
+ pb.float('envLightSpecularStrength'),
214
220
  pb.vec4('clusterParams'),
215
221
  pb.ivec4('countParams'),
216
222
  pb.ivec2('lightIndexTexSize')
@@ -218,7 +224,7 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
218
224
  scope.camera = cameraStruct().uniform(0);
219
225
  scope.light = lightStruct().uniform(0);
220
226
  if (useClusteredLighting) {
221
- scope[UNIFORM_NAME_LIGHT_BUFFER] = pb.vec4[(this.getMaxClusteredLightCount() + 1) * 4]().uniformBuffer(0);
227
+ scope[UNIFORM_NAME_LIGHT_BUFFER] = pb.vec4[(MAX_CLUSTERED_LIGHTS + 1) * 4]().uniformBuffer(0);
222
228
  scope[UNIFORM_NAME_LIGHT_INDEX_TEXTURE] = (pb.getDevice().type === 'webgl' ? pb.tex2D() : pb.utex2D()).uniform(0);
223
229
  }
224
230
  scope[UNIFORM_NAME_BAKED_SKY_MAP] = pb.texCube().uniform(0);
@@ -248,30 +254,30 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
248
254
  }
249
255
  }
250
256
  }
251
- /**
252
- * This function checks if the shader needs to process skeletal animation.
253
- *
254
- * @param scope - Current shader scope
255
- *
256
- * @returns true if the shader needs to process skeletal animation, otherwise false.
257
+ /**
258
+ * This function checks if the shader needs to process skeletal animation.
259
+ *
260
+ * @param scope - Current shader scope
261
+ *
262
+ * @returns true if the shader needs to process skeletal animation, otherwise false.
257
263
  */ static hasSkinning(scope) {
258
264
  return !!scope[UNIFORM_NAME_BONE_MATRICES];
259
265
  }
260
- /**
261
- * This function checks if the shader needs to process morph target animation.
262
- *
263
- * @param scope - Current shader scope
264
- *
265
- * @returns true if the shader needs to process morph target animation, otherwise false.
266
+ /**
267
+ * This function checks if the shader needs to process morph target animation.
268
+ *
269
+ * @param scope - Current shader scope
270
+ *
271
+ * @returns true if the shader needs to process morph target animation, otherwise false.
266
272
  */ static hasMorphing(scope) {
267
273
  return !!scope[UNIFORM_NAME_MORPH_DATA];
268
274
  }
269
- /**
270
- * Calculate skinning matrix for current vertex
271
- *
272
- * @param scope - Current shader scope
273
- *
274
- * @returns Skinning matrix for current vertex, or null if there is not skeletal animation
275
+ /**
276
+ * Calculate skinning matrix for current vertex
277
+ *
278
+ * @param scope - Current shader scope
279
+ *
280
+ * @returns Skinning matrix for current vertex, or null if there is not skeletal animation
275
281
  */ static calculateSkinMatrix(scope) {
276
282
  if (!this.hasSkinning(scope)) {
277
283
  return null;
@@ -426,12 +432,12 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
426
432
  scope.$l[that.SKIN_PREV_MATRIX_NAME] = scope[funcNameGetSkinningMatrix](scope[that.SKIN_BONE_OFFSET].y);
427
433
  }
428
434
  }
429
- /**
430
- * Calculates the vertex position of type vec3 in object space
431
- *
432
- * @param scope - Current shader scope
433
- * @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
434
- * @returns The calculated vertex position in object space, or null if pos is null
435
+ /**
436
+ * Calculates the vertex position of type vec3 in object space
437
+ *
438
+ * @param scope - Current shader scope
439
+ * @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
440
+ * @returns The calculated vertex position in object space, or null if pos is null
435
441
  */ static resolveVertexPosition(scope) {
436
442
  const pb = scope.$builder;
437
443
  if (pb.shaderKind !== 'vertex') {
@@ -473,12 +479,12 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
473
479
  });
474
480
  return scope[that.SKIN_MATRIX_NAME] && scope[that.SKIN_PREV_MATRIX_NAME] ? scope.Z_resolveVertexPosition(scope[that.SKIN_MATRIX_NAME], scope[that.SKIN_PREV_MATRIX_NAME]) : scope[that.SKIN_MATRIX_NAME] ? scope.Z_resolveVertexPosition(scope[that.SKIN_MATRIX_NAME]) : scope.Z_resolveVertexPosition();
475
481
  }
476
- /**
477
- * Resolve motion vector
478
- *
479
- * @param scope - Current shader scope
480
- * @param worldPos - Current object position in world space
481
- * @param prevWorldPos - Previous object position in world space
482
+ /**
483
+ * Resolve motion vector
484
+ *
485
+ * @param scope - Current shader scope
486
+ * @param worldPos - Current object position in world space
487
+ * @param prevWorldPos - Previous object position in world space
482
488
  */ static resolveMotionVector(scope, worldPos, prevWorldPos) {
483
489
  const that = this;
484
490
  const pb = scope.$builder;
@@ -489,13 +495,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
489
495
  scope.$outputs.zMotionVectorPosPrev = pb.mul(prevUnjitteredVPMatrix, pb.vec4(prevWorldPos.xyz, 1));
490
496
  }
491
497
  }
492
- /**
493
- * Calculates the normal vector of type vec3 in object space
494
- *
495
- * @param scope - Current shader scope
496
- * @param normal - Vertex normal input, must be type of vec3, null if no vertex normal input
497
- * @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
498
- * @returns The calculated normal vector in object space, or null if normal is null
498
+ /**
499
+ * Calculates the normal vector of type vec3 in object space
500
+ *
501
+ * @param scope - Current shader scope
502
+ * @param normal - Vertex normal input, must be type of vec3, null if no vertex normal input
503
+ * @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
504
+ * @returns The calculated normal vector in object space, or null if normal is null
499
505
  */ static resolveVertexNormal(scope, normal) {
500
506
  const pb = scope.$builder;
501
507
  if (pb.shaderKind !== 'vertex') {
@@ -520,13 +526,13 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
520
526
  return normal;
521
527
  }
522
528
  }
523
- /**
524
- * Calculates the tangent vector of type vec3 in object space
525
- *
526
- * @param scope - Current shader scope
527
- * @param tangent - Vertex tangent input, must be type of vec4, null if no vertex tangent input
528
- * @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
529
- * @returns The calculated tangent vector of type vec4 in object space, or null if tangent is null
529
+ /**
530
+ * Calculates the tangent vector of type vec3 in object space
531
+ *
532
+ * @param scope - Current shader scope
533
+ * @param tangent - Vertex tangent input, must be type of vec4, null if no vertex tangent input
534
+ * @param skinMatrix - The skinning matrix if there is skeletal animation, otherwise null
535
+ * @returns The calculated tangent vector of type vec4 in object space, or null if tangent is null
530
536
  */ static resolveVertexTangent(scope, tangent) {
531
537
  const pb = scope.$builder;
532
538
  if (pb.shaderKind !== 'vertex') {
@@ -551,18 +557,18 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
551
557
  return tangent;
552
558
  }
553
559
  }
554
- /**
555
- * Gets the uniform variable of type mat4 which holds the world matrix of current object to be drawn
556
- * @param scope - Current shader scope
557
- * @returns The world matrix of current object to be drawn
560
+ /**
561
+ * Gets the uniform variable of type mat4 which holds the world matrix of current object to be drawn
562
+ * @param scope - Current shader scope
563
+ * @returns The world matrix of current object to be drawn
558
564
  */ static getWorldMatrix(scope) {
559
565
  const pb = scope.$builder;
560
566
  return scope[UNIFORM_NAME_WORLD_MATRIX] ?? pb.mat4(this.getInstancedUniform(scope, 0), this.getInstancedUniform(scope, 1), this.getInstancedUniform(scope, 2), this.getInstancedUniform(scope, 3));
561
567
  }
562
- /**
563
- * Gets the uniform variable of type mat4 which holds the world matrix at previous frame of current object to be drawn
564
- * @param scope - Current shader scope
565
- * @returns The world matrix at previous frame of current object to be drawn
568
+ /**
569
+ * Gets the uniform variable of type mat4 which holds the world matrix at previous frame of current object to be drawn
570
+ * @param scope - Current shader scope
571
+ * @returns The world matrix at previous frame of current object to be drawn
566
572
  */ static getPrevWorldMatrix(scope) {
567
573
  const pb = scope.$builder;
568
574
  const that = this;
@@ -593,28 +599,28 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
593
599
  return scope.Z_getPrevWorldMatrix(framestamp);
594
600
  }
595
601
  }
596
- /**
597
- * Gets the instance uniform value of type vec4 by uniform index
598
- * @param scope - Current shader scope
599
- * @returns instance uniform value
602
+ /**
603
+ * Gets the instance uniform value of type vec4 by uniform index
604
+ * @param scope - Current shader scope
605
+ * @returns instance uniform value
600
606
  */ static getInstancedUniform(scope, uniformIndex) {
601
607
  const pb = scope.$builder;
602
608
  return scope[UNIFORM_NAME_INSTANCE_DATA].at(pb.add(pb.mul(scope[UNIFORM_NAME_INSTANCE_DATA_STRIDE], pb.uint(scope.$builtins.instanceIndex)), scope[UNIFORM_NAME_INSTANCE_DATA_OFFSET], pb.uint(uniformIndex)));
603
609
  }
604
- /**
605
- * Gets the uniform variable of type mat4 which holds the normal matrix of current object to be drawn
606
- *
607
- * @param scope - Current shader scope
608
- * @returns The normal matrix of current object to be drawn
610
+ /**
611
+ * Gets the uniform variable of type mat4 which holds the normal matrix of current object to be drawn
612
+ *
613
+ * @param scope - Current shader scope
614
+ * @returns The normal matrix of current object to be drawn
609
615
  */ static getNormalMatrix(scope) {
610
616
  return this.getWorldMatrix(scope);
611
617
  }
612
- /**
613
- * Vertex shader drawable stuff
614
- *
615
- * @param scope - Current shader scope
616
- * @param skinning - true if skinning is used, otherwise false.
617
- * @param instanced - true if instancing is used, otherwise false.
618
+ /**
619
+ * Vertex shader drawable stuff
620
+ *
621
+ * @param scope - Current shader scope
622
+ * @param skinning - true if skinning is used, otherwise false.
623
+ * @param instanced - true if instancing is used, otherwise false.
618
624
  */ static vertexShaderDrawableStuff(scope, skinning, morphing, instanced) {
619
625
  const pb = scope.$builder;
620
626
  if (instanced) {
@@ -657,6 +663,7 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
657
663
  worldMatrix: camera.worldMatrix,
658
664
  params: new Vector4(camera.getNearPlane(), camera.getFarPlane(), ctx.flip ? -1 : 1, linear ? 0 : 1),
659
665
  roughnessFactor: camera.SSR ? camera.ssrRoughnessFactor : 1,
666
+ shadowDebugCascades: camera.shadowDebugCascades ? 1 : 0,
660
667
  frameDeltaTime: ctx.device.frameInfo.elapsedFrame * 0.001,
661
668
  elapsedTime: ctx.device.frameInfo.elapsedOverall * 0.001,
662
669
  framestamp: ctx.device.frameInfo.frameCounter
@@ -708,6 +715,7 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
708
715
  clusterParams: clusterParams,
709
716
  countParams: countParams,
710
717
  envLightStrength: ctx.env.light.strength ?? 0,
718
+ envLightSpecularStrength: ctx.env.light.specularStrength ?? 1,
711
719
  lightIndexTexSize: new Int32Array([
712
720
  lightIndexTexture.width,
713
721
  lightIndexTexture.height
@@ -723,7 +731,6 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
723
731
  /** @internal */ static setLightUniformsShadow(bindGroup, ctx, light) {
724
732
  const shadowMapParams = ctx.shadowMapInfo.get(light);
725
733
  this._lightUniformShadow.sunDir = ctx.sunLight ? ctx.sunLight.directionAndCutoff.xyz().scaleBy(-1) : this.defaultSunDir;
726
- this._lightUniformShadow.envLightStrength = ctx.env?.light.strength ?? 0;
727
734
  this._lightUniformShadow.shadowCascades = shadowMapParams.numShadowCascades;
728
735
  this._lightUniformShadow.positionAndRange.set(light.positionAndRange);
729
736
  this._lightUniformShadow.directionAndCutoff.set(light.directionAndCutoff);
@@ -734,6 +741,9 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
734
741
  this._lightUniformShadow.shadowCameraParams.set(shadowMapParams.cameraParams);
735
742
  this._lightUniformShadow.depthBiasScales.set(shadowMapParams.depthBiasScales);
736
743
  this._lightUniformShadow.shadowMatrices.set(shadowMapParams.shadowMatrices);
744
+ this._lightUniformShadow.shadowStrength = light.shadow.shadowStrength;
745
+ this._lightUniformShadow.envLightStrength = ctx.env?.light.strength ?? 0;
746
+ this._lightUniformShadow.envLightSpecularStrength = ctx.env?.light.specularStrength ?? 1;
737
747
  bindGroup.setValue('light', this._lightUniformShadow);
738
748
  bindGroup.setTexture(UNIFORM_NAME_SHADOW_MAP, shadowMapParams.shadowMap, shadowMapParams.shadowMapSampler);
739
749
  bindGroup.setTexture(UNIFORM_NAME_BAKED_SKY_MAP, ctx.scene.env.sky.getBakedSkyTexture(ctx));
@@ -741,133 +751,144 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
741
751
  ctx.env.light.envLight.updateBindGroup(bindGroup);
742
752
  }
743
753
  }
744
- /**
745
- * Gets the uniform variable of type float which holds the strength of the environment light
746
- *
747
- * @remarks
748
- * This function can only be used in the fragment shader
749
- *
750
- * @param scope - Current shader scope
751
- * @returns The uniform variable of which presents the strength of the environment light
754
+ /**
755
+ * Gets the uniform variable of type float which holds the strength of the environment light
756
+ *
757
+ * @remarks
758
+ * This function can only be used in the fragment shader
759
+ *
760
+ * @param scope - Current shader scope
761
+ * @returns The uniform variable of which presents the strength of the environment light
752
762
  */ static getEnvLightStrength(scope) {
753
763
  return scope.light.envLightStrength;
754
764
  }
755
- /**
756
- * Gets current scene color texture
757
- * @param scope - Current shader scope
758
- * @returns current scene color texture
765
+ /**
766
+ * Gets the uniform variable of type float which holds the specular strength of the environment light
767
+ *
768
+ * @remarks
769
+ * This function can only be used in the fragment shader
770
+ *
771
+ * @param scope - Current shader scope
772
+ * @returns The uniform variable which presents the specular strength of the environment light
773
+ */ static getEnvLightSpecularStrength(scope) {
774
+ return scope.light.envLightSpecularStrength ?? scope.$builder.float(1);
775
+ }
776
+ /**
777
+ * Gets current scene color texture
778
+ * @param scope - Current shader scope
779
+ * @returns current scene color texture
759
780
  */ static getSceneColorTexture(scope) {
760
781
  return scope[UNIFORM_NAME_SCENE_COLOR_MAP];
761
782
  }
762
- /**
763
- * Gets the size of current scene color texture
764
- * @param scope - Current shader scope
765
- * @returns The size of current scene color texture
783
+ /**
784
+ * Gets the size of current scene color texture
785
+ * @param scope - Current shader scope
786
+ * @returns The size of current scene color texture
766
787
  */ static getSceneColorTextureSize(scope) {
767
788
  return scope[UNIFORM_NAME_SCENE_COLOR_MAP_SIZE];
768
789
  }
769
- /**
770
- * Gets current linear depth texture
771
- * @param scope - Current shader scope
772
- * @returns current linear depth texture
790
+ /**
791
+ * Gets current linear depth texture
792
+ * @param scope - Current shader scope
793
+ * @returns current linear depth texture
773
794
  */ static getLinearDepthTexture(scope) {
774
795
  return scope[UNIFORM_NAME_LINEAR_DEPTH_MAP];
775
796
  }
776
- /**
777
- * Gets the size of current linear depth texture
778
- * @param scope - Current shader scope
779
- * @returns The size of current linear depth texture
797
+ /**
798
+ * Gets the size of current linear depth texture
799
+ * @param scope - Current shader scope
800
+ * @returns The size of current linear depth texture
780
801
  */ static getLinearDepthTextureSize(scope) {
781
802
  return scope[UNIFORM_NAME_LINEAR_DEPTH_MAP_SIZE];
782
803
  }
783
- /**
784
- * Gets current HiZ depth texture
785
- * @param scope - Current shader scope
786
- * @returns current HiZ depth texture
804
+ /**
805
+ * Gets current HiZ depth texture
806
+ * @param scope - Current shader scope
807
+ * @returns current HiZ depth texture
787
808
  */ static getHiZDepthTexture(scope) {
788
809
  return scope[UNIFORM_NAME_HIZ_DEPTH_MAP];
789
810
  }
790
- /**
791
- * Gets the size of current HiZ depth texture
792
- * @param scope - Current shader scope
793
- * @returns The size of current HiZ depth texture
811
+ /**
812
+ * Gets the size of current HiZ depth texture
813
+ * @param scope - Current shader scope
814
+ * @returns The size of current HiZ depth texture
794
815
  */ static getHiZDepthTextureSize(scope) {
795
816
  return scope[UNIFORM_NAME_HIZ_DEPTH_MAP_INFO].xy;
796
817
  }
797
- /**
798
- * Gets the mipmap levels count of current HiZ depth texture
799
- * @param scope - Current shader scope
800
- * @returns The mipmap levels count of current HiZ depth texture
818
+ /**
819
+ * Gets the mipmap levels count of current HiZ depth texture
820
+ * @param scope - Current shader scope
821
+ * @returns The mipmap levels count of current HiZ depth texture
801
822
  */ static getHiZDepthTextureMipLevelCount(scope) {
802
823
  return scope[UNIFORM_NAME_HIZ_DEPTH_MAP_INFO].z;
803
824
  }
804
- /**
805
- * Gets current baked skybox texture
806
- * @param scope - Current shader scope
807
- * @returns current baked skybox texture
825
+ /**
826
+ * Gets current baked skybox texture
827
+ * @param scope - Current shader scope
828
+ * @returns current baked skybox texture
808
829
  */ static getBakedSkyTexture(scope) {
809
830
  return scope[UNIFORM_NAME_BAKED_SKY_MAP];
810
831
  }
811
- /**
812
- * Gets the elapsed time in seconds
813
- * @param scope - Current shader scope
814
- * @returns The elapsed time in seconds
832
+ /**
833
+ * Gets the elapsed time in seconds
834
+ * @param scope - Current shader scope
835
+ * @returns The elapsed time in seconds
815
836
  */ static getElapsedTime(scope) {
816
837
  return scope.camera.elapsedTime;
817
838
  }
818
- /**
819
- * Gets the elapsed time since last frame in seconds
820
- * @param scope - Current shader scope
821
- * @returns The elapsed time since last frame in seconds
839
+ /**
840
+ * Gets the elapsed time since last frame in seconds
841
+ * @param scope - Current shader scope
842
+ * @returns The elapsed time since last frame in seconds
822
843
  */ static getElapsedTimeFrame(scope) {
823
844
  return scope.camera.frameDeltaTime;
824
845
  }
825
- /**
826
- * Gets the uniform variable of type vec3 which holds the camera position
827
- * @param scope - Current shader scope
828
- * @returns The camera position
846
+ /**
847
+ * Gets the uniform variable of type vec3 which holds the camera position
848
+ * @param scope - Current shader scope
849
+ * @returns The camera position
829
850
  */ static getCameraPosition(scope) {
830
851
  return scope.camera.position.xyz;
831
852
  }
832
- /**
833
- * Gets the uniform variable of type float which holds the roughness factor
834
- * @param scope - Current shader scope
835
- * @returns The roughness factor
853
+ /**
854
+ * Gets the uniform variable of type float which holds the roughness factor
855
+ * @param scope - Current shader scope
856
+ * @returns The roughness factor
836
857
  */ static getCameraRoughnessFactor(scope) {
837
858
  return scope.camera.roughnessFactor;
838
859
  }
839
- /**
840
- * Gets framebuffer size for rendering
841
- * @param scope - Current shader scope
842
- * @returns The roughness factor
860
+ /**
861
+ * Gets framebuffer size for rendering
862
+ * @param scope - Current shader scope
863
+ * @returns The roughness factor
843
864
  */ static getRenderSize(scope) {
844
865
  return scope.camera.renderSize;
845
866
  }
846
- /**
847
- * Gets the uniform variable of type uint which holds the framestamp
848
- * @param scope - Current shader scope
849
- * @returns The framestamp
867
+ /**
868
+ * Gets the uniform variable of type uint which holds the framestamp
869
+ * @param scope - Current shader scope
870
+ * @returns The framestamp
850
871
  */ static getFramestamp(scope) {
851
872
  return scope.camera.framestamp;
852
873
  }
853
- /**
854
- * Gets the clip plane flag
855
- * @param scope - Current shader scope
856
- * @returns A float value of 1 indices the clip plane presents, otherwise 0
874
+ /**
875
+ * Gets the clip plane flag
876
+ * @param scope - Current shader scope
877
+ * @returns A float value of 1 indices the clip plane presents, otherwise 0
857
878
  */ static getCameraClipPlaneFlag(scope) {
858
879
  return scope.camera.position.w;
859
880
  }
860
- /**
861
- * Gets the clip plane
862
- * @param scope - Current shader scope
863
- * @returns A vec4 presents the clip plane
881
+ /**
882
+ * Gets the clip plane
883
+ * @param scope - Current shader scope
884
+ * @returns A vec4 presents the clip plane
864
885
  */ static getCameraClipPlane(scope) {
865
886
  return scope.camera.clipPlane;
866
887
  }
867
- /**
868
- * Gets the uniform variable of type vec4 which holds the camera parameters
869
- * @param scope - Current shader scope
870
- * @returns The camera parameters
888
+ /**
889
+ * Gets the uniform variable of type vec4 which holds the camera parameters
890
+ * @param scope - Current shader scope
891
+ * @returns The camera parameters
871
892
  */ static getCameraParams(scope) {
872
893
  return scope.camera.params;
873
894
  }
@@ -880,87 +901,87 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
880
901
  /** @internal */ static getClusteredLightIndexTexture(scope) {
881
902
  return scope[UNIFORM_NAME_LIGHT_INDEX_TEXTURE];
882
903
  }
883
- /**
884
- * Gets the uniform variable that contains atmosphere parameters
885
- * @param scope - Current shader scope
886
- * @returns The atmosphere parameters
904
+ /**
905
+ * Gets the uniform variable that contains atmosphere parameters
906
+ * @param scope - Current shader scope
907
+ * @returns The atmosphere parameters
887
908
  */ static getAtmosphereParams(scope) {
888
909
  return scope.fog.atmosphereParams;
889
910
  }
890
- /**
891
- * Gets the aerial perspective LUT
892
- * @param scope - Current shader scope
893
- * @returns The aerial perspective LUT texture
911
+ /**
912
+ * Gets the aerial perspective LUT
913
+ * @param scope - Current shader scope
914
+ * @returns The aerial perspective LUT texture
894
915
  */ static getAerialPerspectiveLUT(scope) {
895
916
  return scope[UNIFORM_NAME_AERIALPERSPECTIVE_LUT];
896
917
  }
897
- /**
898
- * Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
899
- * @param scope - Current shader scope
900
- * @returns The view projection matrix of current camera
918
+ /**
919
+ * Gets the uniform variable of type mat4 which holds the view projection matrix of current camera
920
+ * @param scope - Current shader scope
921
+ * @returns The view projection matrix of current camera
901
922
  */ static getViewProjectionMatrix(scope) {
902
923
  return scope.camera.viewProjectionMatrix;
903
924
  }
904
- /**
905
- * Gets the uniform variable of type mat4 which holds the inversed view projection matrix of current camera
906
- * @param scope - Current shader scope
907
- * @returns The inversed view projection matrix of current camera
925
+ /**
926
+ * Gets the uniform variable of type mat4 which holds the inversed view projection matrix of current camera
927
+ * @param scope - Current shader scope
928
+ * @returns The inversed view projection matrix of current camera
908
929
  */ static getInvViewProjectionMatrix(scope) {
909
930
  return scope.camera.invViewProjectionMatrix;
910
931
  }
911
- /**
912
- * Gets the uniform variable of type mat4 which holds the projection matrix of current camera
913
- * @param scope - Current shader scope
914
- * @returns The projection matrix of current camera
932
+ /**
933
+ * Gets the uniform variable of type mat4 which holds the projection matrix of current camera
934
+ * @param scope - Current shader scope
935
+ * @returns The projection matrix of current camera
915
936
  */ static getProjectionMatrix(scope) {
916
937
  return scope.camera.projectionMatrix;
917
938
  }
918
- /**
919
- * Gets the uniform variable of type mat4 which holds the inversed projection matrix of current camera
920
- * @param scope - Current shader scope
921
- * @returns The inversed projection matrix of current camera
939
+ /**
940
+ * Gets the uniform variable of type mat4 which holds the inversed projection matrix of current camera
941
+ * @param scope - Current shader scope
942
+ * @returns The inversed projection matrix of current camera
922
943
  */ static getInvProjectionMatrix(scope) {
923
944
  return scope.camera.invProjectionMatrix;
924
945
  }
925
- /**
926
- * Gets the uniform variable of type mat4 which holds the unjittered view projection matrix of current camera
927
- * @param scope - Current shader scope
928
- * @returns The unjittered view projection matrix of current camera
946
+ /**
947
+ * Gets the uniform variable of type mat4 which holds the unjittered view projection matrix of current camera
948
+ * @param scope - Current shader scope
949
+ * @returns The unjittered view projection matrix of current camera
929
950
  */ static getUnjitteredViewProjectionMatrix(scope) {
930
951
  return scope.camera.unjitteredVPMatrix;
931
952
  }
932
- /**
933
- * Gets the uniform variable of type vec2 which holds the jitter value of the projection matrix of current camera
934
- * @param scope - Current shader scope
935
- * @returns The jitter value of projection matrix of current camera
953
+ /**
954
+ * Gets the uniform variable of type vec2 which holds the jitter value of the projection matrix of current camera
955
+ * @param scope - Current shader scope
956
+ * @returns The jitter value of projection matrix of current camera
936
957
  */ static getProjectionMatrixJitterValue(scope) {
937
958
  return scope.camera.jitterValue;
938
959
  }
939
- /**
940
- * Gets the uniform variable of type mat4 which holds the jittered inversed view-projection matrix
941
- * @param scope - Current shader scope
942
- * @returns The jittered inversed view-projection matrix
960
+ /**
961
+ * Gets the uniform variable of type mat4 which holds the jittered inversed view-projection matrix
962
+ * @param scope - Current shader scope
963
+ * @returns The jittered inversed view-projection matrix
943
964
  */ static getJitteredInvVPMatrix(scope) {
944
965
  return scope.camera.jitteredInvVPMatrix;
945
966
  }
946
- /**
947
- * Gets the uniform variable of type mat4 which holds the unjittered view projection at previous frame matrix of current camera
948
- * @param scope - Current shader scope
949
- * @returns The unjittered view projection matrix at previous frame of current camera
967
+ /**
968
+ * Gets the uniform variable of type mat4 which holds the unjittered view projection at previous frame matrix of current camera
969
+ * @param scope - Current shader scope
970
+ * @returns The unjittered view projection matrix at previous frame of current camera
950
971
  */ static getPrevUnjitteredViewProjectionMatrix(scope) {
951
972
  return scope.camera.prevUnjitteredVPMatrix;
952
973
  }
953
- /**
954
- * Gets the uniform variable of type mat4 which holds the view matrix of current camera (world space to camera space)
955
- * @param scope - Current shader scope
956
- * @returns The view matrix of current camera
974
+ /**
975
+ * Gets the uniform variable of type mat4 which holds the view matrix of current camera (world space to camera space)
976
+ * @param scope - Current shader scope
977
+ * @returns The view matrix of current camera
957
978
  */ static getViewMatrix(scope) {
958
979
  return scope.camera.viewMatrix;
959
980
  }
960
- /**
961
- * Gets the uniform variable of type mat4 which holds the inv-view matrix of current camera (camera space to world space)
962
- * @param scope - Current shader scope
963
- * @returns The inv-view matrix of current camera
981
+ /**
982
+ * Gets the uniform variable of type mat4 which holds the inv-view matrix of current camera (camera space to world space)
983
+ * @param scope - Current shader scope
984
+ * @returns The inv-view matrix of current camera
964
985
  */ static getInvViewMatrix(scope) {
965
986
  return scope.camera.worldMatrix;
966
987
  }
@@ -1011,20 +1032,20 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
1011
1032
  /** @internal */ static getLightExtra(scope, lightIndex) {
1012
1033
  return scope[UNIFORM_NAME_LIGHT_BUFFER].at(scope.$builder.add(scope.$builder.mul(lightIndex, 4), 3));
1013
1034
  }
1014
- /**
1015
- * Sets the clip space position in vertex shader
1016
- *
1017
- * @remarks
1018
- * Use this function instead of using
1019
- * <pre>
1020
- * // Do not use this
1021
- * this.$builtins.position = some_value;
1022
- * // Use this
1023
- * ShaderFramework.setClipSpacePosition(some_value);
1024
- * </pre>,
1025
- *
1026
- * @param scope - Current shader scope
1027
- * @param pos - The clip space position to be set
1035
+ /**
1036
+ * Sets the clip space position in vertex shader
1037
+ *
1038
+ * @remarks
1039
+ * Use this function instead of using
1040
+ * <pre>
1041
+ * // Do not use this
1042
+ * this.$builtins.position = some_value;
1043
+ * // Use this
1044
+ * ShaderFramework.setClipSpacePosition(some_value);
1045
+ * </pre>,
1046
+ *
1047
+ * @param scope - Current shader scope
1048
+ * @param pos - The clip space position to be set
1028
1049
  */ static setClipSpacePosition(scope, pos) {
1029
1050
  const pb = scope.$builder;
1030
1051
  const cameraParams = this.getCameraParams(scope);
@@ -1034,20 +1055,20 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
1034
1055
  scope.$builtins.position = pos;
1035
1056
  }
1036
1057
  }
1037
- /**
1038
- * Get shadow map uniform value
1039
- *
1040
- * @param scope - Shader scope
1041
- * @returns The shadow map texture uniform
1058
+ /**
1059
+ * Get shadow map uniform value
1060
+ *
1061
+ * @param scope - Shader scope
1062
+ * @returns The shadow map texture uniform
1042
1063
  */ static getShadowMap(scope) {
1043
1064
  return scope[UNIFORM_NAME_SHADOW_MAP];
1044
1065
  }
1045
- /**
1046
- * Calculates shadow of current fragment
1047
- *
1048
- * @param scope - Shader scope
1049
- * @param NoL - NdotL vector
1050
- * @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
1066
+ /**
1067
+ * Calculates shadow of current fragment
1068
+ *
1069
+ * @param scope - Shader scope
1070
+ * @param NoL - NdotL vector
1071
+ * @returns Shadow of current fragment, 1 means no shadow and 0 means full shadowed.
1051
1072
  */ static calculateShadow(scope, worldPos, NoL, ctx) {
1052
1073
  const pb = scope.$builder;
1053
1074
  const that = this;
@@ -1078,15 +1099,24 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
1078
1099
  }
1079
1100
  const shadowMapParams = ctx.shadowMapInfo.get(ctx.currentShadowLight);
1080
1101
  this.$l.shadow = shadowMapParams.impl.computeShadowCSM(shadowMapParams, this, this.shadowVertex, this.NoL, this.split);
1102
+ this.shadow = pb.clamp(this.shadow, 0, 1);
1081
1103
  this.$l.shadowDistance = that.getShadowCameraParams(scope).w;
1082
1104
  this.shadow = pb.mix(this.shadow, 1, pb.smoothStep(pb.mul(this.shadowDistance, 0.8), this.shadowDistance, pb.distance(that.getCameraPosition(this), this.worldPos)));
1105
+ this.shadow = pb.mix(1, this.shadow, this.light.shadowStrength);
1106
+ this.shadow = pb.clamp(this.shadow, 0, 1);
1107
+ this.$if(pb.greaterThan(this.camera.shadowDebugCascades, 0.5), function() {
1108
+ this.shadow = pb.add(pb.mul(pb.float(this.split), 0.2), 0.2);
1109
+ });
1083
1110
  this.$return(this.shadow);
1084
1111
  } else {
1085
1112
  this.$l.shadowVertex = that.calculateShadowSpaceVertex(this, pb.vec4(this.worldPos, 1));
1086
1113
  const shadowMapParams = ctx.shadowMapInfo.get(ctx.currentShadowLight);
1087
1114
  this.$l.shadow = shadowMapParams.impl.computeShadow(shadowMapParams, this, this.shadowVertex, this.NoL);
1115
+ this.shadow = pb.clamp(this.shadow, 0, 1);
1088
1116
  this.$l.shadowDistance = that.getShadowCameraParams(scope).w;
1089
1117
  this.shadow = pb.mix(this.shadow, 1, pb.smoothStep(pb.mul(this.shadowDistance, 0.8), this.shadowDistance, pb.distance(that.getCameraPosition(this), this.worldPos)));
1118
+ this.shadow = pb.mix(1, this.shadow, this.light.shadowStrength);
1119
+ this.shadow = pb.clamp(this.shadow, 0, 1);
1090
1120
  this.$return(this.shadow);
1091
1121
  }
1092
1122
  });
@@ -1101,59 +1131,62 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
1101
1131
  pb.vec3('worldPos'),
1102
1132
  pb.vec4('color').inout()
1103
1133
  ], function() {
1134
+ this.$if(pb.notEqual(this.fog.additive, 0), function() {
1135
+ this.$return();
1136
+ });
1104
1137
  this.$l.uv = pb.div(pb.vec2(this.$builtins.fragCoord.xy), that.getRenderSize(this));
1105
1138
  this.$l.fogging = calculateFog(this, this.fog.withAerialPerspective, this.fog.fogType, this.fog.atmosphereParams, this.fog.heightFogParams, this.uv, false, that.getCameraPosition(this).xyz, this.worldPos, this.fog.additive, this[UNIFORM_NAME_AERIALPERSPECTIVE_LUT], this[UNIFORM_NAME_SKYDISTANTLIGHT_LUT]);
1106
- this.color = pb.vec4(pb.add(pb.mul(this.color.rgb, this.fogging.a), pb.mul(this.fogging.rgb, this.color.a)), this.color.a);
1139
+ this.$l.foggingAlpha = pb.sub(1, pb.mul(pb.sub(1, this.fogging.a), this.color.a));
1140
+ this.$l.foggingRGB = pb.mul(this.fogging.rgb, this.color.a);
1141
+ this.color = pb.vec4(pb.add(pb.mul(this.color.rgb, this.foggingAlpha), this.foggingRGB), this.color.a);
1107
1142
  //this.color = pb.vec4(pb.vec3(pb.mix(this.u0, this.u1, this.factor)), this.color.a);
1108
1143
  });
1109
1144
  scope[funcName](worldPos, color);
1110
1145
  }
1111
1146
  }
1112
- /**
1113
- * Calculates the non-linear depth from linear depth
1114
- *
1115
- * @param scope - Current shader scope
1116
- * @param depth - The linear depth
1117
- * @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
1118
- * @returns The calculated non-linear depth
1147
+ /**
1148
+ * Calculates the non-linear depth from linear depth
1149
+ *
1150
+ * @param scope - Current shader scope
1151
+ * @param depth - The linear depth
1152
+ * @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
1153
+ * @returns The calculated non-linear depth
1119
1154
  */ static linearDepthToNonLinear(scope, depth, nearFar) {
1120
1155
  const pb = scope.$builder;
1121
1156
  nearFar = nearFar ?? this.getCameraParams(scope);
1122
- return pb.add(pb.mul(pb.div(pb.sub(pb.add(nearFar.x, nearFar.y), pb.div(pb.mul(nearFar.x, nearFar.y, 2), depth)), pb.sub(nearFar.y, nearFar.x)), 0.5), 0.5);
1123
- }
1124
- /**
1125
- * Calculates the linear depth from non-linear depth
1126
- *
1127
- * @param scope - Current shader scope
1128
- * @param depth - The non-linear depth
1129
- * @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
1130
- * @returns The calculated linear depth
1157
+ return pb.div(pb.sub(nearFar.y, pb.div(pb.mul(nearFar.x, nearFar.y), depth)), pb.sub(nearFar.y, nearFar.x));
1158
+ }
1159
+ /**
1160
+ * Calculates the linear depth from non-linear depth
1161
+ *
1162
+ * @param scope - Current shader scope
1163
+ * @param depth - The non-linear depth
1164
+ * @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
1165
+ * @returns The calculated linear depth
1131
1166
  */ static nonLinearDepthToLinear(scope, depth, nearFar) {
1132
1167
  const pb = scope.$builder;
1133
1168
  nearFar = nearFar ?? this.getCameraParams(scope);
1134
- return pb.div(pb.mul(nearFar.x, nearFar.y, 2), pb.add(nearFar.x, nearFar.y, pb.mul(pb.sub(nearFar.x, nearFar.y), pb.sub(pb.mul(depth, 2), 1))));
1135
- //return pb.div(pb.mul(nearFar.x, nearFar.y), pb.mix(nearFar.y, nearFar.x, depth));
1136
- }
1137
- /**
1138
- * Calculates the normalized linear depth from non-linear depth
1139
- *
1140
- * @param scope - Current shader scope
1141
- * @param depth - The non-linear depth
1142
- * @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
1143
- * @returns The calculated normalized linear depth
1169
+ return pb.div(pb.mul(nearFar.x, nearFar.y), pb.mix(nearFar.y, nearFar.x, depth));
1170
+ }
1171
+ /**
1172
+ * Calculates the normalized linear depth from non-linear depth
1173
+ *
1174
+ * @param scope - Current shader scope
1175
+ * @param depth - The non-linear depth
1176
+ * @param nearFar - A vector that contains the near clip plane in x component and the far clip plane in y component
1177
+ * @returns The calculated normalized linear depth
1144
1178
  */ static nonLinearDepthToLinearNormalized(scope, depth, nearFar) {
1145
1179
  const pb = scope.$builder;
1146
1180
  nearFar = nearFar ?? this.getCameraParams(scope);
1147
- //return pb.div(nearFar.x, pb.mix(nearFar.y, nearFar.x, depth));
1148
- return pb.div(pb.sub(this.nonLinearDepthToLinear(scope, depth, nearFar), nearFar.x), pb.sub(nearFar.y, nearFar.x));
1149
- }
1150
- /**
1151
- * Sample linear depth from linear depth texture
1152
- * @param scope - Current shader scope
1153
- * @param tex - The linear depth texture
1154
- * @param uv - The uv coordinates
1155
- * @param level - The mipmap level to sample
1156
- * @returns Linear depth value
1181
+ return pb.div(nearFar.x, pb.mix(nearFar.y, nearFar.x, depth));
1182
+ }
1183
+ /**
1184
+ * Sample linear depth from linear depth texture
1185
+ * @param scope - Current shader scope
1186
+ * @param tex - The linear depth texture
1187
+ * @param uv - The uv coordinates
1188
+ * @param level - The mipmap level to sample
1189
+ * @returns Linear depth value
1157
1190
  */ static sampleLinearDepth(scope, tex, uv, level) {
1158
1191
  const pb = scope.$builder;
1159
1192
  const depth = pb.textureSampleLevel(tex, uv, level);
@@ -1175,23 +1208,23 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
1175
1208
  });
1176
1209
  return scope.zSamplePositionFromDepth(uv, cameraNearFar, mat);
1177
1210
  }
1178
- /**
1179
- * Sample linear depth from linear depth texture with backface
1180
- * @param scope - Current shader scope
1181
- * @param tex - The linear depth texture
1182
- * @param uv - The uv coordinates
1183
- * @param level - The mipmap level to sample
1184
- * @returns Linear depth value
1211
+ /**
1212
+ * Sample linear depth from linear depth texture with backface
1213
+ * @param scope - Current shader scope
1214
+ * @param tex - The linear depth texture
1215
+ * @param uv - The uv coordinates
1216
+ * @param level - The mipmap level to sample
1217
+ * @returns Linear depth value
1185
1218
  */ static sampleLinearDepthWithBackface(scope, tex, uv, level) {
1186
1219
  const pb = scope.$builder;
1187
1220
  return pb.textureSampleLevel(tex, uv, level).rg;
1188
1221
  }
1189
- /**
1190
- * Transform color to sRGB color space if nessesary
1191
- *
1192
- * @param scope - Current shader scope
1193
- * @param outputColor - The color to be transformed
1194
- * @returns The transformed color
1222
+ /**
1223
+ * Transform color to sRGB color space if nessesary
1224
+ *
1225
+ * @param scope - Current shader scope
1226
+ * @param outputColor - The color to be transformed
1227
+ * @returns The transformed color
1195
1228
  */ static encodeColorOutput(scope, outputColor) {
1196
1229
  const pb = scope.$builder;
1197
1230
  const that = this;
@@ -1208,9 +1241,6 @@ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
1208
1241
  });
1209
1242
  return pb.getGlobalScope()[funcName](outputColor);
1210
1243
  }
1211
- static getMaxClusteredLightCount() {
1212
- return getDevice().type === 'webgl' ? 127 : 255;
1213
- }
1214
1244
  }
1215
1245
 
1216
1246
  export { ShaderHelper };