@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,14 +1,17 @@
1
1
  import { AbstractPostEffect, PostEffectLayer } from './posteffect.js';
2
2
  import { linearToGamma } from '../shaders/misc.js';
3
3
  import { SSR_calcJitter, screenSpaceRayTracing_HiZ, screenSpaceRayTracing_Linear2D } from '../shaders/ssr.js';
4
- import { Vector2, Vector4, Matrix4x4 } from '@zephyr3d/base';
4
+ import { temporalResolve } from '../shaders/temporal.js';
5
+ import { Vector2, Matrix4x4, Vector4 } from '@zephyr3d/base';
5
6
  import { fetchSampler, copyTexture } from '../utility/misc.js';
7
+ import { getGGXLUT } from '../utility/textures/ggxlut.js';
6
8
  import { BilateralBlurBlitter } from '../blitter/bilateralblur.js';
7
9
  import { ShaderHelper } from '../material/shader/helper.js';
8
10
  import '../material/lambert.js';
9
11
  import '../material/blinn.js';
10
12
  import '../material/unlit.js';
11
13
  import '../material/particle.js';
14
+ import '../material/subsurfaceprofile.js';
12
15
  import '@zephyr3d/device';
13
16
  import '../values.js';
14
17
  import '../material/meshmaterial.js';
@@ -16,36 +19,40 @@ import '../material/grassmaterial.js';
16
19
  import '../material/terrain-cm.js';
17
20
  import '../material/pbrmr.js';
18
21
  import '../material/pbrsg.js';
22
+ import '../material/mtoon.js';
19
23
  import '../material/pbrblueprint.js';
20
24
  import '../material/sprite.js';
21
25
  import '../material/sprite_std.js';
22
- import '../material/msdf_text.js';
23
26
  import '../utility/blueprint/material/texture.js';
27
+ import { RGHistoryResources } from '../render/rendergraph/history_resources.js';
24
28
 
25
- /**
26
- * SSR post effect
27
- *
28
- * @remarks
29
- * Internal used in light pass
30
- *
31
- * @internal
29
+ /**
30
+ * SSR post effect
31
+ *
32
+ * @remarks
33
+ * Internal used in light pass
34
+ *
35
+ * @internal
32
36
  */ class SSR extends AbstractPostEffect {
33
37
  static _programs = {};
34
38
  static _resolveProgram = {};
35
39
  static _combineProgram;
40
+ static _temporalProgram;
36
41
  static _blurBlitterH = null;
37
42
  static _blurBlitterV = null;
38
43
  _bindgroups;
39
44
  _resolveBindGroup;
40
45
  _combineBindGroup;
41
- /**
42
- * Creates an instance of SSR post effect
46
+ _temporalBindGroup;
47
+ /**
48
+ * Creates an instance of SSR post effect
43
49
  */ constructor(){
44
50
  super();
45
51
  this._layer = PostEffectLayer.opaque;
46
52
  this._bindgroups = {};
47
53
  this._resolveBindGroup = {};
48
54
  this._combineBindGroup = null;
55
+ this._temporalBindGroup = null;
49
56
  }
50
57
  /** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */ requireLinearDepthTexture() {
51
58
  return true;
@@ -75,15 +82,26 @@ import '../utility/blueprint/material/texture.js';
75
82
  program = this._createCombineProgrm(ctx);
76
83
  SSR._combineProgram = program;
77
84
  }
85
+ const roughnessTexture = ctx.SSRRoughnessTexture;
78
86
  if (!this._combineBindGroup) {
79
87
  this._combineBindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
80
88
  }
81
89
  const linearSampler = fetchSampler('clamp_linear');
90
+ const nearestSampler = fetchSampler('clamp_nearest');
82
91
  this._combineBindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
83
92
  this._combineBindGroup.setTexture('reflectanceTex', reflectanceTex, linearSampler);
84
- this._combineBindGroup.setTexture('roughnessTex', ctx.SSRRoughnessTexture, linearSampler);
93
+ this._combineBindGroup.setTexture('roughnessTex', roughnessTexture, linearSampler);
94
+ this._combineBindGroup.setTexture('albedoTex', inputColorTexture, linearSampler);
95
+ this._combineBindGroup.setTexture('extraTex', inputColorTexture, nearestSampler);
96
+ this._combineBindGroup.setTexture('normalTex', ctx.SSRNormalTexture, nearestSampler);
97
+ this._combineBindGroup.setTexture('depthTex', ctx.linearDepthTexture, nearestSampler);
98
+ this._combineBindGroup.setTexture('zGGXLut', getGGXLUT(1024), fetchSampler('clamp_nearest_nomip'));
85
99
  this._combineBindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
86
- this._combineBindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), device.getDrawingBufferWidth(), device.getDrawingBufferHeight()));
100
+ this._combineBindGroup.setValue('ssrStrengthMode', 0);
101
+ this._combineBindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
102
+ this._combineBindGroup.setValue('viewMatrix', ctx.camera.viewMatrix);
103
+ this._combineBindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
104
+ this._combineBindGroup.setValue('targetSize', new Vector4(inputColorTexture.width, inputColorTexture.height, inputColorTexture.width, inputColorTexture.height));
87
105
  this._combineBindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
88
106
  this._combineBindGroup.setValue('srgbOut', srgbOut ? 1 : 0);
89
107
  device.setProgram(program);
@@ -92,7 +110,8 @@ import '../utility/blueprint/material/texture.js';
92
110
  }
93
111
  /** @internal */ resolve(ctx, inputColorTexture, sceneDepthTexture, intersectTexture) {
94
112
  const device = ctx.device;
95
- const hash = ctx.env.light.envLight ? ctx.env.light.getHash() : '';
113
+ const hasEnvRadiance = !!ctx.env.light.envLight?.hasRadiance();
114
+ const hash = hasEnvRadiance ? ctx.env.light.getHash() : '';
96
115
  let program = SSR._resolveProgram[hash];
97
116
  if (program === undefined) {
98
117
  program = this._createResolveProgram(ctx);
@@ -105,19 +124,26 @@ import '../utility/blueprint/material/texture.js';
105
124
  }
106
125
  const nearestSampler = fetchSampler('clamp_nearest');
107
126
  const linearSampler = fetchSampler('clamp_linear');
127
+ const roughnessTexture = ctx.SSRRoughnessTexture;
128
+ const normalTexture = ctx.SSRNormalTexture;
108
129
  bindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
109
130
  bindGroup.setTexture('intersectTex', intersectTexture, nearestSampler);
110
- bindGroup.setTexture('roughnessTex', ctx.SSRRoughnessTexture, nearestSampler);
111
- bindGroup.setTexture('normalTex', ctx.SSRNormalTexture, nearestSampler);
131
+ bindGroup.setTexture('roughnessTex', roughnessTexture, nearestSampler);
132
+ bindGroup.setTexture('normalTex', normalTexture, nearestSampler);
133
+ bindGroup.setTexture('albedoTex', inputColorTexture, linearSampler);
134
+ bindGroup.setTexture('extraTex', inputColorTexture, nearestSampler);
112
135
  bindGroup.setTexture('depthTex', sceneDepthTexture, nearestSampler);
136
+ bindGroup.setTexture('zGGXLut', getGGXLUT(1024), fetchSampler('clamp_nearest_nomip'));
113
137
  bindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
138
+ bindGroup.setValue('ssrStrengthMode', 0);
114
139
  bindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
115
- bindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), sceneDepthTexture.width, sceneDepthTexture.height));
140
+ bindGroup.setValue('targetSize', new Vector4(inputColorTexture.width, inputColorTexture.height, sceneDepthTexture.width, sceneDepthTexture.height));
116
141
  bindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
117
142
  bindGroup.setValue('viewMatrix', ctx.camera.viewMatrix);
118
143
  bindGroup.setValue('invViewMatrix', ctx.camera.worldMatrix);
119
- if (ctx.env.light.envLight) {
144
+ if (hasEnvRadiance) {
120
145
  bindGroup.setValue('envLightStrength', ctx.env.light.strength);
146
+ bindGroup.setValue('envLightSpecularStrength', ctx.env.light.specularStrength ?? 1);
121
147
  ctx.env.light.envLight.updateBindGroup(bindGroup);
122
148
  }
123
149
  bindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
@@ -127,10 +153,15 @@ import '../utility/blueprint/material/texture.js';
127
153
  }
128
154
  /** @internal */ intersect(ctx, inputColorTexture, sceneDepthTexture, blur, srgbOut) {
129
155
  const device = ctx.device;
130
- const hash = `${Number(blur)}:${ctx.env.light.envLight ? ctx.env.light.getHash() : ''}:${!!ctx.HiZTexture}:${!!ctx.camera.ssrCalcThickness}`;
156
+ const hasEnvRadiance = !!ctx.env.light.envLight?.hasRadiance();
157
+ const hash = `${Number(blur)}:${hasEnvRadiance ? ctx.env.light.getHash() : ''}:${!!ctx.HiZTexture}:${!!ctx.camera.ssrCalcThickness}`;
131
158
  let program = SSR._programs[hash];
132
159
  if (program === undefined) {
133
- program = this._createIntersectProgram(ctx, blur);
160
+ const created = this._createIntersectProgram(ctx, blur);
161
+ if (!created) {
162
+ return;
163
+ }
164
+ program = created;
134
165
  SSR._programs[hash] = program;
135
166
  }
136
167
  let bindGroup = this._bindgroups[hash];
@@ -140,16 +171,22 @@ import '../utility/blueprint/material/texture.js';
140
171
  }
141
172
  const nearestSampler = fetchSampler('clamp_nearest');
142
173
  const linearSampler = fetchSampler('clamp_linear');
174
+ const roughnessTexture = ctx.SSRRoughnessTexture;
175
+ const normalTexture = ctx.SSRNormalTexture;
143
176
  if (!blur) {
144
177
  bindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
145
- if (ctx.env.light.envLight) {
178
+ if (hasEnvRadiance) {
146
179
  bindGroup.setValue('envLightStrength', ctx.env.light.strength);
180
+ bindGroup.setValue('envLightSpecularStrength', ctx.env.light.specularStrength ?? 1);
147
181
  ctx.env.light.envLight.updateBindGroup(bindGroup);
148
182
  }
149
183
  }
150
- bindGroup.setTexture('roughnessTex', ctx.SSRRoughnessTexture, nearestSampler);
151
- bindGroup.setTexture('normalTex', ctx.SSRNormalTexture, nearestSampler);
184
+ bindGroup.setTexture('albedoTex', inputColorTexture, linearSampler);
185
+ bindGroup.setTexture('roughnessTex', roughnessTexture, nearestSampler);
186
+ bindGroup.setTexture('normalTex', normalTexture, nearestSampler);
187
+ bindGroup.setTexture('extraTex', inputColorTexture, nearestSampler);
152
188
  bindGroup.setTexture('depthTex', sceneDepthTexture, nearestSampler);
189
+ bindGroup.setTexture('zGGXLut', getGGXLUT(1024), fetchSampler('clamp_nearest_nomip'));
153
190
  bindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
154
191
  bindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
155
192
  bindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
@@ -158,13 +195,14 @@ import '../utility/blueprint/material/texture.js';
158
195
  bindGroup.setValue('invViewMatrix', ctx.camera.worldMatrix);
159
196
  bindGroup.setValue('ssrParams', ctx.camera.ssrParams);
160
197
  bindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
198
+ bindGroup.setValue('ssrStrengthMode', 0);
161
199
  if (ctx.HiZTexture) {
162
200
  bindGroup.setTexture('hizTex', ctx.HiZTexture, nearestSampler);
163
201
  bindGroup.setValue('depthMipLevels', ctx.HiZTexture.mipLevelCount);
164
- bindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), ctx.HiZTexture.width, ctx.HiZTexture.height));
202
+ bindGroup.setValue('targetSize', new Vector4(sceneDepthTexture.width, sceneDepthTexture.height, ctx.HiZTexture.width, ctx.HiZTexture.height));
165
203
  } else {
166
204
  bindGroup.setValue('ssrStride', ctx.camera.ssrStride);
167
- bindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), sceneDepthTexture.width, sceneDepthTexture.height));
205
+ bindGroup.setValue('targetSize', new Vector4(sceneDepthTexture.width, sceneDepthTexture.height, sceneDepthTexture.width, sceneDepthTexture.height));
168
206
  }
169
207
  bindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
170
208
  bindGroup.setValue('srgbOut', srgbOut ? 1 : 0);
@@ -172,6 +210,29 @@ import '../utility/blueprint/material/texture.js';
172
210
  device.setBindGroup(0, bindGroup);
173
211
  this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
174
212
  }
213
+ /** @internal */ temporal(ctx, currentReflectTex, sceneDepthTexture, prevReflectTex, prevMotionVectorTex, outFramebuffer) {
214
+ const device = ctx.device;
215
+ let program = SSR._temporalProgram;
216
+ if (!program) {
217
+ program = this._createTemporalProgram(ctx);
218
+ SSR._temporalProgram = program;
219
+ }
220
+ if (!this._temporalBindGroup) {
221
+ this._temporalBindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
222
+ }
223
+ this._temporalBindGroup.setTexture('historyColorTex', prevReflectTex, fetchSampler('clamp_linear_nomip'));
224
+ this._temporalBindGroup.setTexture('currentColorTex', currentReflectTex, fetchSampler('clamp_nearest_nomip'));
225
+ this._temporalBindGroup.setTexture('currentDepthTex', sceneDepthTexture, fetchSampler('clamp_nearest_nomip'));
226
+ this._temporalBindGroup.setTexture('motionVector', ctx.motionVectorTexture, fetchSampler('clamp_nearest_nomip'));
227
+ this._temporalBindGroup.setTexture('prevMotionVector', prevMotionVectorTex, fetchSampler('clamp_nearest_nomip'));
228
+ this._temporalBindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
229
+ this._temporalBindGroup.setValue('texSize', new Vector2(sceneDepthTexture.width, sceneDepthTexture.height));
230
+ this._temporalBindGroup.setValue('temporalWeight', ctx.camera.ssrTemporalWeight);
231
+ device.setFramebuffer(outFramebuffer);
232
+ device.setProgram(program);
233
+ device.setBindGroup(0, this._temporalBindGroup);
234
+ this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
235
+ }
175
236
  /** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
176
237
  const device = ctx.device;
177
238
  device.pushDeviceStates();
@@ -185,7 +246,8 @@ import '../utility/blueprint/material/texture.js';
185
246
  this.intersect(ctx, inputColorTexture, sceneDepthTexture, true, false);
186
247
  const intersectTex = intersectFramebuffer.getColorAttachments()[0];
187
248
  device.setFramebuffer(pingpongFramebuffer[0]);
188
- this.resolve(ctx, inputColorTexture, sceneDepthTexture, intersectTex);
249
+ const ssrSceneColorTexture = ctx.sceneColorTexture ?? inputColorTexture;
250
+ this.resolve(ctx, ssrSceneColorTexture, sceneDepthTexture, intersectTex);
189
251
  if (ctx.camera.ssrBlurScale > 0 && ctx.camera.ssrBlurKernelSize > 0) {
190
252
  const blurSizeScale = 255 * ctx.camera.ssrBlurScale;
191
253
  const kernelRadius = Math.max(1, ctx.camera.ssrBlurKernelSize >> 0) - 1 >> 1;
@@ -198,8 +260,65 @@ import '../utility/blueprint/material/texture.js';
198
260
  blitterV.renderStates = AbstractPostEffect.getDefaultRenderState(ctx, 'gt');
199
261
  this.blurPass(ctx, blitterV, intersectTex, 2, blurSizeScale, kernelRadius, stdDev, depthCutoff, pingpongFramebuffer[1], pingpongFramebuffer[0]);
200
262
  }
263
+ const historyManager = ctx.camera.getHistoryResourceManager();
264
+ const useGraphHistory = !!historyManager?.frameActive;
265
+ const history = useGraphHistory ? null : ctx.camera.getHistoryData();
266
+ let reflectanceTex = pingpongFramebuffer[0].getColorAttachments()[0];
267
+ const prevSSRReflectTex = useGraphHistory ? historyManager.tryGetPrevious(RGHistoryResources.SSR_REFLECT) : history.prevSSRReflectTex;
268
+ const prevSSRMotionVectorTex = useGraphHistory ? historyManager.tryGetPrevious(RGHistoryResources.SSR_MOTION_VECTOR) : history.prevSSRMotionVectorTex;
269
+ const canTemporal = ctx.camera.ssrTemporal && !!ctx.motionVectorTexture && !!prevSSRReflectTex && !!prevSSRMotionVectorTex && prevSSRReflectTex.width === reflectanceTex.width && prevSSRReflectTex.height === reflectanceTex.height;
270
+ if (canTemporal) {
271
+ this.temporal(ctx, reflectanceTex, sceneDepthTexture, prevSSRReflectTex, prevSSRMotionVectorTex, pingpongFramebuffer[1]);
272
+ reflectanceTex = pingpongFramebuffer[1].getColorAttachments()[0];
273
+ }
201
274
  device.popDeviceStates();
202
- this.combine(ctx, inputColorTexture, pingpongFramebuffer[0].getColorAttachments()[0], srgbOutput);
275
+ this.combine(ctx, inputColorTexture, reflectanceTex, srgbOutput);
276
+ if (useGraphHistory) {
277
+ if (ctx.camera.ssrTemporal) {
278
+ const reflectanceSize = {
279
+ width: reflectanceTex.width,
280
+ height: reflectanceTex.height
281
+ };
282
+ historyManager.queueRetainedCommit(RGHistoryResources.SSR_REFLECT, {
283
+ format: reflectanceTex.format,
284
+ sizeMode: 'absolute',
285
+ width: reflectanceTex.width,
286
+ height: reflectanceTex.height
287
+ }, reflectanceSize, reflectanceTex);
288
+ }
289
+ if (ctx.camera.ssrTemporal && ctx.motionVectorTexture) {
290
+ const motionVectorSize = {
291
+ width: ctx.motionVectorTexture.width,
292
+ height: ctx.motionVectorTexture.height
293
+ };
294
+ historyManager.queueRetainedCommit(RGHistoryResources.SSR_MOTION_VECTOR, {
295
+ format: ctx.motionVectorTexture.format,
296
+ sizeMode: 'absolute',
297
+ width: ctx.motionVectorTexture.width,
298
+ height: ctx.motionVectorTexture.height
299
+ }, motionVectorSize, ctx.motionVectorTexture);
300
+ }
301
+ } else {
302
+ if (history.prevSSRReflectTex) {
303
+ device.pool.releaseTexture(history.prevSSRReflectTex);
304
+ history.prevSSRReflectTex = null;
305
+ }
306
+ if (history.prevSSRMotionVectorTex) {
307
+ device.pool.releaseTexture(history.prevSSRMotionVectorTex);
308
+ history.prevSSRMotionVectorTex = null;
309
+ }
310
+ if (ctx.camera.ssrTemporal) {
311
+ device.pool.retainTexture(reflectanceTex);
312
+ history.prevSSRReflectTex = reflectanceTex;
313
+ }
314
+ if (ctx.camera.ssrTemporal && ctx.motionVectorTexture) {
315
+ if (history.prevSSRMotionVectorTex) {
316
+ device.pool.releaseTexture(history.prevSSRMotionVectorTex);
317
+ }
318
+ device.pool.retainTexture(ctx.motionVectorTexture);
319
+ history.prevSSRMotionVectorTex = ctx.motionVectorTexture;
320
+ }
321
+ }
203
322
  device.pool.releaseFrameBuffer(intersectFramebuffer);
204
323
  device.pool.releaseFrameBuffer(pingpongFramebuffer[0]);
205
324
  device.pool.releaseFrameBuffer(pingpongFramebuffer[1]);
@@ -222,17 +341,82 @@ import '../utility/blueprint/material/texture.js';
222
341
  this.colorTex = pb.tex2D().uniform(0);
223
342
  this.reflectanceTex = pb.tex2D().uniform(0);
224
343
  this.roughnessTex = pb.tex2D().uniform(0);
344
+ this.albedoTex = pb.tex2D().uniform(0);
345
+ this.extraTex = pb.tex2D().uniform(0);
346
+ this.normalTex = pb.tex2D().uniform(0);
347
+ this.depthTex = pb.tex2D().uniform(0);
348
+ this.zGGXLut = pb.tex2D().uniform(0);
225
349
  this.targetSize = pb.vec4().uniform(0);
350
+ this.cameraNearFar = pb.vec2().uniform(0);
351
+ this.viewMatrix = pb.mat4().uniform(0);
352
+ this.invProjMatrix = pb.mat4().uniform(0);
226
353
  this.ssrMaxRoughness = pb.float().uniform(0);
354
+ this.ssrStrengthMode = pb.int().uniform(0);
227
355
  this.srgbOut = pb.int().uniform(0);
228
356
  this.$outputs.outColor = pb.vec4();
357
+ pb.func('getPosition', [
358
+ pb.vec2('uv')
359
+ ], function() {
360
+ this.$l.linearDepth = ShaderHelper.sampleLinearDepth(this, this.depthTex, this.uv, 0);
361
+ this.$l.nonLinearDepth = pb.div(pb.sub(pb.div(this.cameraNearFar.x, this.linearDepth), this.cameraNearFar.y), pb.sub(this.cameraNearFar.x, this.cameraNearFar.y));
362
+ this.$l.clipSpacePos = pb.vec4(pb.sub(pb.mul(this.uv, 2), pb.vec2(1)), pb.sub(pb.mul(pb.clamp(this.nonLinearDepth, 0, 1), 2), 1), 1);
363
+ this.$l.viewPos4 = pb.mul(this.invProjMatrix, this.clipSpacePos);
364
+ this.$return(pb.vec4(pb.div(this.viewPos4.xyz, this.viewPos4.w), this.linearDepth));
365
+ });
366
+ pb.func('resolveDeferredStrength', [
367
+ pb.vec2('uv'),
368
+ pb.vec4('roughnessValue')
369
+ ], function() {
370
+ this.$l.roughness = pb.clamp(this.roughnessValue.a, 0.045, 1);
371
+ this.$l.base = pb.textureSampleLevel(this.albedoTex, this.uv, 0);
372
+ // Hybrid may merge forward-only SSR surface data into the roughness MRT while the
373
+ // deferred GBuffer remains empty at those pixels. Fall back to forward SSR semantics
374
+ // there instead of decoding the mixed texture as deferred metallic/occlusion/F0 data.
375
+ this.$if(pb.lessThanEqual(this.base.a, 1e-5), function() {
376
+ this.$return(pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1)));
377
+ });
378
+ this.$l.pos = this.getPosition(this.uv);
379
+ this.$if(pb.greaterThanEqual(this.pos.w, 1), function() {
380
+ this.$return(pb.vec3(0));
381
+ });
382
+ this.$l.viewPos = this.pos.xyz;
383
+ this.$l.viewVec = pb.neg(pb.normalize(this.viewPos));
384
+ this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
385
+ this.$l.viewNormal = pb.normalize(pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz);
386
+ this.$l.NoV = pb.clamp(pb.dot(this.viewNormal, this.viewVec), 0.0001, 1);
387
+ this.$l.baseColor = this.base.rgb;
388
+ this.$l.extra = pb.textureSampleLevel(this.extraTex, this.uv, 0);
389
+ this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
390
+ this.$l.occlusion = pb.clamp(this.roughnessValue.g, 0, 1);
391
+ this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
392
+ this.$l.specularWeight = pb.clamp(this.extra.a, 0, 1);
393
+ this.$l.f0 = pb.mix(pb.mul(pb.vec3(0.04), this.specStrength), this.baseColor, this.metallic);
394
+ this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.roughness)), this.f0), this.f0);
395
+ this.$l.kS = pb.add(this.f0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
396
+ this.$l.fab = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.roughness), pb.vec2(0), pb.vec2(1)), 0).rg, pb.vec2(0), pb.vec2(1));
397
+ this.$l.FssEss = pb.add(pb.mul(this.kS, this.fab.x), pb.vec3(this.fab.y));
398
+ this.$return(pb.clamp(pb.mul(this.FssEss, this.occlusion, this.specularWeight), pb.vec3(0), pb.vec3(1)));
399
+ });
229
400
  pb.func('resolveSample', [
401
+ pb.vec2('uv'),
230
402
  pb.vec3('sceneColor'),
231
403
  pb.vec3('reflectance'),
232
404
  pb.vec4('roughnessValue')
233
405
  ], function() {
234
406
  this.$l.r = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
235
- this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
407
+ this.$l.strength = pb.vec3();
408
+ this.$if(pb.equal(this.ssrStrengthMode, 0), function() {
409
+ this.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
410
+ }).$elseif(pb.equal(this.ssrStrengthMode, 1), function() {
411
+ this.$l.roughAtten = pb.clamp(pb.sub(1, pb.div(this.roughnessValue.a, pb.max(this.ssrMaxRoughness, 1e-4))), 0, 1);
412
+ this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
413
+ this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
414
+ this.$l.f0 = pb.mix(pb.mul(0.04, this.specStrength), 1, this.metallic);
415
+ this.$l.s = pb.mul(this.roughAtten, this.roughAtten, this.f0);
416
+ this.strength = pb.vec3(this.s);
417
+ }).$else(function() {
418
+ this.strength = this.resolveDeferredStrength(this.uv, this.roughnessValue);
419
+ });
236
420
  this.color = pb.add(pb.mul(this.r, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
237
421
  this.$return(this.color);
238
422
  });
@@ -245,7 +429,7 @@ import '../utility/blueprint/material/texture.js';
245
429
  this.combined = this.sceneColor;
246
430
  }).$else(function() {
247
431
  this.$l.reflectance = pb.textureSampleLevel(this.reflectanceTex, this.screenUV, 0).rgb;
248
- this.combined = this.resolveSample(this.sceneColor, this.reflectance, this.roughnessInfo);
432
+ this.combined = this.resolveSample(this.screenUV, this.sceneColor, this.reflectance, this.roughnessInfo);
249
433
  });
250
434
  this.$if(pb.equal(this.srgbOut, 0), function() {
251
435
  this.$outputs.outColor = pb.vec4(this.combined, 1);
@@ -264,7 +448,7 @@ import '../utility/blueprint/material/texture.js';
264
448
  this.flip = pb.int().uniform(0);
265
449
  this.$inputs.pos = pb.vec2().attrib('position');
266
450
  this.$outputs.uv = pb.vec2();
267
- if (ctx.env.light.envLight) {
451
+ if (ctx.env.light.envLight?.hasRadiance()) {
268
452
  ctx.env.light.envLight.initShaderBindings(pb);
269
453
  }
270
454
  pb.main(function() {
@@ -280,15 +464,20 @@ import '../utility/blueprint/material/texture.js';
280
464
  this.intersectTex = pb.tex2D().uniform(0);
281
465
  this.roughnessTex = pb.tex2D().uniform(0);
282
466
  this.normalTex = pb.tex2D().uniform(0);
467
+ this.albedoTex = pb.tex2D().uniform(0);
468
+ this.extraTex = pb.tex2D().uniform(0);
283
469
  this.depthTex = pb.tex2D().uniform(0);
470
+ this.zGGXLut = pb.tex2D().uniform(0);
284
471
  this.cameraNearFar = pb.vec2().uniform(0);
285
472
  this.targetSize = pb.vec4().uniform(0);
286
473
  this.viewMatrix = pb.mat4().uniform(0);
287
474
  this.invViewMatrix = pb.mat4().uniform(0);
288
475
  this.invProjMatrix = pb.mat4().uniform(0);
289
476
  this.ssrMaxRoughness = pb.float().uniform(0);
290
- if (ctx.env.light.envLight) {
477
+ this.ssrStrengthMode = pb.int().uniform(0);
478
+ if (ctx.env.light.envLight?.hasRadiance()) {
291
479
  this.envLightStrength = pb.float().uniform(0);
480
+ this.envLightSpecularStrength = pb.float().uniform(0);
292
481
  ctx.env.light.envLight.initShaderBindings(pb);
293
482
  }
294
483
  this.$outputs.outColor = pb.vec4();
@@ -302,13 +491,57 @@ import '../utility/blueprint/material/texture.js';
302
491
  this.$l.wPos = pb.mul(this.mat, this.clipSpacePos);
303
492
  this.$return(pb.vec4(pb.div(this.wPos.xyz, this.wPos.w), this.linearDepth));
304
493
  });
494
+ pb.func('resolveDeferredStrength', [
495
+ pb.vec2('uv'),
496
+ pb.vec4('roughnessValue')
497
+ ], function() {
498
+ this.$l.roughness = pb.clamp(this.roughnessValue.a, 0.045, 1);
499
+ this.$l.base = pb.textureSampleLevel(this.albedoTex, this.uv, 0);
500
+ this.$if(pb.lessThanEqual(this.base.a, 1e-5), function() {
501
+ this.$return(pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1)));
502
+ });
503
+ this.$l.pos = this.getPosition(this.uv, this.invProjMatrix);
504
+ this.$if(pb.greaterThanEqual(this.pos.w, 1), function() {
505
+ this.$return(pb.vec3(0));
506
+ });
507
+ this.$l.viewPos = this.pos.xyz;
508
+ this.$l.viewVec = pb.neg(pb.normalize(this.viewPos));
509
+ this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
510
+ this.$l.viewNormal = pb.normalize(pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz);
511
+ this.$l.NoV = pb.clamp(pb.dot(this.viewNormal, this.viewVec), 0.0001, 1);
512
+ this.$l.baseColor = this.base.rgb;
513
+ this.$l.extra = pb.textureSampleLevel(this.extraTex, this.uv, 0);
514
+ this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
515
+ this.$l.occlusion = pb.clamp(this.roughnessValue.g, 0, 1);
516
+ this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
517
+ this.$l.specularWeight = pb.clamp(this.extra.a, 0, 1);
518
+ this.$l.f0 = pb.mix(pb.mul(pb.vec3(0.04), this.specStrength), this.baseColor, this.metallic);
519
+ this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.roughness)), this.f0), this.f0);
520
+ this.$l.kS = pb.add(this.f0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
521
+ this.$l.fab = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.roughness), pb.vec2(0), pb.vec2(1)), 0).rg, pb.vec2(0), pb.vec2(1));
522
+ this.$l.FssEss = pb.add(pb.mul(this.kS, this.fab.x), pb.vec3(this.fab.y));
523
+ this.$return(pb.clamp(pb.mul(this.FssEss, this.occlusion, this.specularWeight), pb.vec3(0), pb.vec3(1)));
524
+ });
305
525
  pb.func('resolveSample', [
526
+ pb.vec2('uv'),
306
527
  pb.vec3('sceneColor'),
307
528
  pb.vec3('reflectance'),
308
529
  pb.vec4('roughnessValue')
309
530
  ], function() {
310
531
  this.$l.r = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
311
- this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
532
+ this.$l.strength = pb.vec3();
533
+ this.$if(pb.equal(this.ssrStrengthMode, 0), function() {
534
+ this.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
535
+ }).$elseif(pb.equal(this.ssrStrengthMode, 1), function() {
536
+ this.$l.roughAtten = pb.clamp(pb.sub(1, pb.div(this.roughnessValue.a, pb.max(this.ssrMaxRoughness, 1e-4))), 0, 1);
537
+ this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
538
+ this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
539
+ this.$l.f0 = pb.mix(pb.mul(0.04, this.specStrength), 1, this.metallic);
540
+ this.$l.s = pb.mul(this.roughAtten, this.roughAtten, this.f0);
541
+ this.strength = pb.vec3(this.s);
542
+ }).$else(function() {
543
+ this.strength = this.resolveDeferredStrength(this.uv, this.roughnessValue);
544
+ });
312
545
  this.color = pb.add(pb.mul(this.r, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
313
546
  this.$return(this.color);
314
547
  });
@@ -316,7 +549,7 @@ import '../utility/blueprint/material/texture.js';
316
549
  pb.vec2('uv'),
317
550
  pb.vec4('roughnessInfo')
318
551
  ], function() {
319
- if (!ctx.env.light.envLight) {
552
+ if (!ctx.env.light.envLight?.hasRadiance()) {
320
553
  this.$return(pb.vec3(0));
321
554
  return;
322
555
  }
@@ -331,8 +564,8 @@ import '../utility/blueprint/material/texture.js';
331
564
  this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
332
565
  this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
333
566
  this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
334
- this.$l.roughness2 = pb.float(0);
335
- this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness2), this.envLightStrength);
567
+ this.$l.roughness2 = pb.clamp(this.roughness, 0, 1);
568
+ this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness2), this.envLightStrength, this.envLightSpecularStrength);
336
569
  this.$return(pb.min(this.env, pb.vec3(1)));
337
570
  });
338
571
  pb.func('resolveReflectance', [
@@ -342,32 +575,36 @@ import '../utility/blueprint/material/texture.js';
342
575
  pb.float('alpha')
343
576
  ], function() {
344
577
  this.$l.env = this.resolveEnvRadiance(this.uv, this.roughnessInfo);
345
- this.$l.reflectance = pb.mix(this.env, this.reflectSceneColor, this.alpha);
578
+ this.$l.reflectance = pb.mix(this.env, this.reflectSceneColor, pb.clamp(this.alpha, 0, 1));
346
579
  this.$return(this.reflectance);
347
580
  });
348
581
  pb.main(function() {
349
582
  this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
350
583
  this.$l.roughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
351
- this.$if(pb.greaterThanEqual(this.roughnessInfo.a, this.ssrMaxRoughness), function() {
352
- pb.discard();
353
- });
354
- this.$l.intersectSample = pb.textureSampleLevel(this.intersectTex, this.screenUV, 0);
355
- this.$l.reflectance = pb.vec3();
356
- this.$if(pb.greaterThan(this.intersectSample.w, 0), function() {
357
- this.$l.indirectIntersectSample = pb.textureSampleLevel(this.intersectTex, this.intersectSample.xy, 0);
358
- this.$l.indirectRoughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.intersectSample.xy, 0);
359
- this.$l.indirectReflectance = pb.vec3();
360
- this.$if(pb.greaterThan(this.indirectIntersectSample.w, 0), function() {
361
- this.$l.indirectReflectSceneColor = pb.textureSampleLevel(this.colorTex, this.indirectIntersectSample.xy, 0).rgb;
362
- this.indirectReflectance = this.resolveReflectance(this.intersectSample.xy, this.indirectReflectSceneColor, this.indirectRoughnessInfo, this.indirectIntersectSample.w);
584
+ this.$l.intersectSample = pb.vec4(0);
585
+ this.$l.reflectance = pb.vec3(0);
586
+ this.$if(pb.lessThan(this.roughnessInfo.a, this.ssrMaxRoughness), function() {
587
+ this.intersectSample = pb.textureSampleLevel(this.intersectTex, this.screenUV, 0);
588
+ this.$l.hitAlpha = pb.clamp(this.intersectSample.w, 0, 1);
589
+ this.$l.hitUV = pb.clamp(this.intersectSample.xy, pb.vec2(0), pb.vec2(1));
590
+ this.$if(pb.greaterThan(this.hitAlpha, 0), function() {
591
+ this.$l.indirectIntersectSample = pb.textureSampleLevel(this.intersectTex, this.hitUV, 0);
592
+ this.$l.indirectAlpha = pb.clamp(this.indirectIntersectSample.w, 0, 1);
593
+ this.$l.indirectUV = pb.clamp(this.indirectIntersectSample.xy, pb.vec2(0), pb.vec2(1));
594
+ this.$l.indirectRoughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.hitUV, 0);
595
+ this.$l.indirectReflectance = pb.vec3();
596
+ this.$if(pb.greaterThan(this.indirectAlpha, 0), function() {
597
+ this.$l.indirectReflectSceneColor = pb.textureSampleLevel(this.colorTex, this.indirectUV, 0).rgb;
598
+ this.indirectReflectance = this.resolveReflectance(this.hitUV, this.indirectReflectSceneColor, this.indirectRoughnessInfo, this.indirectAlpha);
599
+ }).$else(function() {
600
+ this.indirectReflectance = this.resolveEnvRadiance(this.hitUV, this.indirectRoughnessInfo);
601
+ });
602
+ this.$l.reflectSceneColor = pb.textureSampleLevel(this.colorTex, this.hitUV, 0).rgb;
603
+ this.$l.reflectSceneColor = this.resolveSample(this.hitUV, this.reflectSceneColor, this.indirectReflectance, this.indirectRoughnessInfo);
604
+ this.reflectance = this.resolveReflectance(this.screenUV, this.reflectSceneColor, this.roughnessInfo, this.hitAlpha);
363
605
  }).$else(function() {
364
- this.indirectReflectance = this.resolveEnvRadiance(this.intersectSample.xy, this.indirectRoughnessInfo);
606
+ this.reflectance = this.resolveEnvRadiance(this.screenUV, this.roughnessInfo);
365
607
  });
366
- this.$l.reflectSceneColor = pb.textureSampleLevel(this.colorTex, this.intersectSample.xy, 0).rgb;
367
- this.$l.reflectSceneColor = this.resolveSample(this.reflectSceneColor, this.indirectReflectance, this.indirectRoughnessInfo);
368
- this.reflectance = this.resolveReflectance(this.screenUV, this.reflectSceneColor, this.roughnessInfo, this.intersectSample.w);
369
- }).$else(function() {
370
- this.reflectance = this.resolveEnvRadiance(this.screenUV, this.roughnessInfo);
371
608
  });
372
609
  this.$outputs.outColor = pb.vec4(this.reflectance, this.intersectSample.z);
373
610
  });
@@ -376,13 +613,48 @@ import '../utility/blueprint/material/texture.js';
376
613
  program.name = '@SSR_Resolve';
377
614
  return program;
378
615
  }
616
+ /** @internal */ _createTemporalProgram(ctx) {
617
+ const program = ctx.device.buildRenderProgram({
618
+ vertex (pb) {
619
+ this.flip = pb.int().uniform(0);
620
+ this.$inputs.pos = pb.vec2().attrib('position');
621
+ this.$outputs.uv = pb.vec2();
622
+ pb.main(function() {
623
+ this.$builtins.position = pb.vec4(this.$inputs.pos, 1, 1);
624
+ this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
625
+ this.$if(pb.notEqual(this.flip, 0), function() {
626
+ this.$builtins.position.y = pb.neg(this.$builtins.position.y);
627
+ });
628
+ });
629
+ },
630
+ fragment (pb) {
631
+ this.historyColorTex = pb.tex2D().uniform(0);
632
+ this.currentColorTex = pb.tex2D().uniform(0);
633
+ this.currentDepthTex = pb.tex2D().uniform(0);
634
+ this.motionVector = pb.tex2D().uniform(0);
635
+ this.prevMotionVector = pb.tex2D().uniform(0);
636
+ this.texSize = pb.vec2().uniform(0);
637
+ this.temporalWeight = pb.float().uniform(0);
638
+ this.$outputs.outColor = pb.vec4();
639
+ pb.main(function() {
640
+ this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.texSize);
641
+ this.$l.currentColor = pb.textureSampleLevel(this.currentColorTex, this.screenUV, 0).rgb;
642
+ this.$l.resolvedColor = temporalResolve(this, this.currentColorTex, this.historyColorTex, this.currentDepthTex, this.motionVector, this.prevMotionVector, this.screenUV, this.texSize, 0);
643
+ this.$l.w = pb.clamp(this.temporalWeight, 0, 1);
644
+ this.$outputs.outColor = pb.vec4(pb.mix(this.currentColor, this.resolvedColor, this.w), 1);
645
+ });
646
+ }
647
+ });
648
+ program.name = '@SSR_Temporal';
649
+ return program;
650
+ }
379
651
  /** @internal */ _createIntersectProgram(ctx, blur) {
380
652
  const program = ctx.device.buildRenderProgram({
381
653
  vertex (pb) {
382
654
  this.flip = pb.int().uniform(0);
383
655
  this.$inputs.pos = pb.vec2().attrib('position');
384
656
  this.$outputs.uv = pb.vec2();
385
- if (!blur && ctx.env.light.envLight) {
657
+ if (!blur && ctx.env.light.envLight?.hasRadiance()) {
386
658
  ctx.env.light.envLight.initShaderBindings(pb);
387
659
  }
388
660
  pb.main(function() {
@@ -396,14 +668,18 @@ import '../utility/blueprint/material/texture.js';
396
668
  fragment (pb) {
397
669
  if (!blur) {
398
670
  this.colorTex = pb.tex2D().uniform(0);
399
- if (ctx.env.light.envLight) {
671
+ if (ctx.env.light.envLight?.hasRadiance()) {
400
672
  this.envLightStrength = pb.float().uniform(0);
673
+ this.envLightSpecularStrength = pb.float().uniform(0);
401
674
  ctx.env.light.envLight.initShaderBindings(pb);
402
675
  }
403
676
  }
677
+ this.albedoTex = pb.tex2D().uniform(0);
404
678
  this.roughnessTex = pb.tex2D().uniform(0);
405
679
  this.normalTex = pb.tex2D().uniform(0);
680
+ this.extraTex = pb.tex2D().uniform(0);
406
681
  this.depthTex = pb.tex2D().uniform(0);
682
+ this.zGGXLut = pb.tex2D().uniform(0);
407
683
  this.cameraNearFar = pb.vec2().uniform(0);
408
684
  this.cameraPos = pb.vec3().uniform(0);
409
685
  this.invProjMatrix = pb.mat4().uniform(0);
@@ -412,6 +688,7 @@ import '../utility/blueprint/material/texture.js';
412
688
  this.invViewMatrix = pb.mat4().uniform(0);
413
689
  this.ssrParams = pb.vec4().uniform(0);
414
690
  this.ssrMaxRoughness = pb.float().uniform(0);
691
+ this.ssrStrengthMode = pb.int().uniform(0);
415
692
  this.targetSize = pb.vec4().uniform(0);
416
693
  if (ctx.HiZTexture) {
417
694
  this.hizTex = pb.tex2D().uniform(0);
@@ -431,56 +708,102 @@ import '../utility/blueprint/material/texture.js';
431
708
  this.$l.wPos = pb.mul(this.mat, this.clipSpacePos);
432
709
  this.$return(pb.vec4(pb.div(this.wPos.xyz, this.wPos.w), this.linearDepth));
433
710
  });
711
+ pb.func('resolveDeferredStrength', [
712
+ pb.vec2('uv'),
713
+ pb.vec4('roughnessValue'),
714
+ pb.vec4('viewPosInfo')
715
+ ], function() {
716
+ this.$l.roughness = pb.clamp(this.roughnessValue.a, 0.045, 1);
717
+ this.$l.base = pb.textureSampleLevel(this.albedoTex, this.uv, 0);
718
+ this.$if(pb.lessThanEqual(this.base.a, 1e-5), function() {
719
+ this.$return(pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1)));
720
+ });
721
+ this.$l.viewPos = this.viewPosInfo.xyz;
722
+ this.$l.viewVec = pb.neg(pb.normalize(this.viewPos));
723
+ this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
724
+ this.$l.viewNormal = pb.normalize(pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz);
725
+ this.$l.NoV = pb.clamp(pb.dot(this.viewNormal, this.viewVec), 0.0001, 1);
726
+ this.$l.baseColor = this.base.rgb;
727
+ this.$l.extra = pb.textureSampleLevel(this.extraTex, this.uv, 0);
728
+ this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
729
+ this.$l.occlusion = pb.clamp(this.roughnessValue.g, 0, 1);
730
+ this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
731
+ this.$l.specularWeight = pb.clamp(this.extra.a, 0, 1);
732
+ this.$l.f0 = pb.mix(pb.mul(pb.vec3(0.04), this.specStrength), this.baseColor, this.metallic);
733
+ this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.roughness)), this.f0), this.f0);
734
+ this.$l.kS = pb.add(this.f0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
735
+ this.$l.fab = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.roughness), pb.vec2(0), pb.vec2(1)), 0).rg, pb.vec2(0), pb.vec2(1));
736
+ this.$l.FssEss = pb.add(pb.mul(this.kS, this.fab.x), pb.vec3(this.fab.y));
737
+ this.$return(pb.clamp(pb.mul(this.FssEss, this.occlusion, this.specularWeight), pb.vec3(0), pb.vec3(1)));
738
+ });
434
739
  pb.main(function() {
435
740
  this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
436
741
  this.$l.roughnessValue = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
437
742
  this.$l.roughness = this.roughnessValue.a;
438
- this.$if(pb.greaterThanEqual(this.roughness, this.ssrMaxRoughness), function() {
439
- pb.discard();
440
- });
441
743
  if (!blur) {
442
744
  this.$l.sceneColor = pb.textureSampleLevel(this.colorTex, this.screenUV, 0).rgb;
443
745
  }
444
- this.$l.pos = this.getPosition(this.screenUV, this.invProjMatrix);
445
- this.$l.linearDepth = this.pos.w;
446
746
  this.$l.color = pb.vec3(0);
447
- this.$l.a = pb.float();
448
- this.$if(pb.greaterThanEqual(this.linearDepth, 1), function() {
449
- if (!blur) {
450
- this.color = this.sceneColor;
451
- this.a = 1;
452
- }
453
- }).$else(function() {
454
- this.$l.viewPos = this.pos.xyz;
455
- this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.screenUV, 0).rgb, 2), pb.vec3(1));
456
- this.$l.viewVec = pb.normalize(this.viewPos);
457
- this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
458
- this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
459
- this.$l.hitInfo = ctx.HiZTexture ? screenSpaceRayTracing_HiZ(this, this.viewPos, this.reflectVec, this.viewMatrix, this.projMatrix, this.invProjMatrix, this.cameraNearFar, this.depthMipLevels, this.ssrParams.y, this.ssrParams.z, this.targetSize, this.hizTex, this.normalTex) : screenSpaceRayTracing_Linear2D(this, this.viewPos, this.reflectVec, this.viewMatrix, this.projMatrix, this.invProjMatrix, this.cameraNearFar, this.ssrParams.x, this.ssrParams.y, this.ssrParams.z, this.ssrStride, this.targetSize, this.depthTex, this.normalTex, !!ctx.camera.ssrCalcThickness);
460
- if (blur) {
461
- this.blurRadius = pb.float(0);
462
- this.$if(pb.greaterThan(this.roughness, 0.001), function() {
463
- this.$l.coneAngle = pb.mul(pb.min(this.roughness, 0.999), Math.PI * 0.5);
464
- this.$l.coneLen = this.$choice(pb.greaterThan(this.hitInfo.w, 0), this.hitInfo.z, pb.min(this.targetSize.z, this.targetSize.w));
465
- this.$l.opLen = pb.mul(pb.tan(this.coneAngle), this.coneLen, 2);
466
- this.$l.a2 = pb.mul(this.opLen, this.opLen);
467
- this.$l.fh2 = pb.mul(this.coneLen, this.coneLen, 4);
468
- this.blurRadius = pb.div(pb.mul(this.opLen, pb.sub(pb.sqrt(pb.add(this.a2, this.fh2)), this.opLen)), pb.mul(this.coneLen, 4));
469
- });
470
- this.a = this.hitInfo.w;
471
- this.color = pb.vec3(this.hitInfo.xy, pb.clamp(pb.div(this.blurRadius, 255), 0, 1));
472
- } else {
473
- if (ctx.env.light.envLight) {
474
- this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
475
- this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness), this.envLightStrength);
747
+ this.$l.a = pb.float(0);
748
+ this.$if(pb.lessThan(this.roughness, this.ssrMaxRoughness), function() {
749
+ this.$l.pos = this.getPosition(this.screenUV, this.invProjMatrix);
750
+ this.$l.linearDepth = this.pos.w;
751
+ this.$if(pb.greaterThanEqual(this.linearDepth, 1), function() {
752
+ if (!blur) {
753
+ this.color = this.sceneColor;
754
+ this.a = 1;
755
+ }
756
+ }).$else(function() {
757
+ this.$l.viewPos = this.pos.xyz;
758
+ this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.screenUV, 0).rgb, 2), pb.vec3(1));
759
+ this.$l.viewVec = pb.normalize(this.viewPos);
760
+ this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
761
+ this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
762
+ this.$l.hitInfo = pb.vec4(0);
763
+ if (ctx.HiZTexture) {
764
+ this.hitInfo = screenSpaceRayTracing_HiZ(this, this.viewPos, this.reflectVec, this.viewMatrix, this.projMatrix, this.invProjMatrix, this.cameraNearFar, this.depthMipLevels, this.ssrParams.y, this.ssrParams.z, this.targetSize, this.hizTex, this.normalTex);
765
+ } else {
766
+ this.hitInfo = screenSpaceRayTracing_Linear2D(this, this.viewPos, this.reflectVec, this.viewMatrix, this.projMatrix, this.invProjMatrix, this.cameraNearFar, this.ssrParams.x, this.ssrParams.y, this.ssrParams.z, this.ssrStride, this.targetSize, this.depthTex, this.normalTex, !!ctx.camera.ssrCalcThickness);
767
+ }
768
+ this.$l.hitAlpha = pb.clamp(this.hitInfo.w, 0, 1);
769
+ this.$l.hitUV = pb.clamp(this.hitInfo.xy, pb.vec2(0), pb.vec2(1));
770
+ if (blur) {
771
+ this.blurRadius = pb.float(0);
772
+ this.$if(pb.greaterThan(this.roughness, 0.001), function() {
773
+ this.$l.coneAngle = pb.mul(pb.min(this.roughness, 0.999), Math.PI * 0.5);
774
+ this.$l.coneLen = this.$choice(pb.greaterThan(this.hitAlpha, 0), this.hitInfo.z, pb.min(this.targetSize.z, this.targetSize.w));
775
+ this.$l.opLen = pb.mul(pb.tan(this.coneAngle), this.coneLen, 2);
776
+ this.$l.a2 = pb.mul(this.opLen, this.opLen);
777
+ this.$l.fh2 = pb.mul(this.coneLen, this.coneLen, 4);
778
+ this.blurRadius = pb.div(pb.mul(this.opLen, pb.sub(pb.sqrt(pb.add(this.a2, this.fh2)), this.opLen)), pb.mul(this.coneLen, 4));
779
+ });
780
+ this.a = this.hitAlpha;
781
+ this.color = pb.vec3(this.hitUV, pb.clamp(pb.div(this.blurRadius, 255), 0, 1));
476
782
  } else {
477
- this.$l.env = pb.vec3(0);
783
+ if (ctx.env.light.envLight?.hasRadiance()) {
784
+ this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
785
+ this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness), this.envLightStrength, this.envLightSpecularStrength);
786
+ } else {
787
+ this.$l.env = pb.vec3(0);
788
+ }
789
+ this.$l.reflectance = pb.mix(this.env, pb.textureSampleLevel(this.colorTex, this.hitUV, 0).rgb, this.hitAlpha);
790
+ this.$l.reflectance = pb.div(this.$l.reflectance, pb.add(this.$l.reflectance, pb.vec3(1)));
791
+ this.$l.strength = pb.vec3();
792
+ this.$if(pb.equal(this.ssrStrengthMode, 0), function() {
793
+ this.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
794
+ }).$elseif(pb.equal(this.ssrStrengthMode, 1), function() {
795
+ this.$l.roughAtten = pb.clamp(pb.sub(1, pb.div(this.roughness, pb.max(this.ssrMaxRoughness, 1e-4))), 0, 1);
796
+ this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
797
+ this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
798
+ this.$l.f0 = pb.mix(pb.mul(0.04, this.specStrength), 1, this.metallic);
799
+ this.$l.s = pb.mul(this.roughAtten, this.roughAtten, this.f0);
800
+ this.strength = pb.vec3(this.s);
801
+ }).$else(function() {
802
+ this.strength = this.resolveDeferredStrength(this.screenUV, this.roughnessValue, this.pos);
803
+ });
804
+ this.color = pb.add(pb.mul(this.reflectance, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
478
805
  }
479
- this.$l.reflectance = pb.mix(this.env, pb.textureSampleLevel(this.colorTex, this.hitInfo.xy, 0).rgb, this.hitInfo.w);
480
- this.reflectance = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
481
- this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
482
- this.color = pb.add(pb.mul(this.reflectance, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
483
- }
806
+ });
484
807
  });
485
808
  this.$if(pb.equal(this.srgbOut, 0), function() {
486
809
  this.$outputs.outColor = pb.vec4(this.color, this.a);
@@ -490,6 +813,9 @@ import '../utility/blueprint/material/texture.js';
490
813
  });
491
814
  }
492
815
  });
816
+ if (!program) {
817
+ return null;
818
+ }
493
819
  program.name = blur ? '@SSR_Intersect_Blur' : '@SSR_Intersect';
494
820
  return program;
495
821
  }