@zephyr3d/scene 0.9.27 → 0.10.0

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 (502) hide show
  1. package/README.md +60 -27
  2. package/dist/animation/animation_bank.js +634 -0
  3. package/dist/animation/animation_bank.js.map +1 -0
  4. package/dist/animation/animation_bank_gpu.js +256 -0
  5. package/dist/animation/animation_bank_gpu.js.map +1 -0
  6. package/dist/animation/animationset.js +54 -0
  7. package/dist/animation/animationset.js.map +1 -1
  8. package/dist/animation/cloth/gpu_cloth_component.js +406 -0
  9. package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
  10. package/dist/animation/cloth/gpu_cloth_system.js +332 -202
  11. package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
  12. package/dist/animation/gpu_animation_driver.js +289 -0
  13. package/dist/animation/gpu_animation_driver.js.map +1 -0
  14. package/dist/animation/joint_dynamics/collision.js +112 -1
  15. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  16. package/dist/animation/joint_dynamics/controller.js +6 -0
  17. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  18. package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
  19. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  20. package/dist/animation/joint_dynamics/solver.js +50 -12
  21. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  22. package/dist/animation/joint_dynamics/types.js.map +1 -1
  23. package/dist/animation/skeleton.js +279 -55
  24. package/dist/animation/skeleton.js.map +1 -1
  25. package/dist/animation/skin_palette_atlas.js +252 -0
  26. package/dist/animation/skin_palette_atlas.js.map +1 -0
  27. package/dist/animation/spring/multi_chain_spring_system.js +298 -38
  28. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
  29. package/dist/animation/spring/spring_chain.js +2 -0
  30. package/dist/animation/spring/spring_chain.js.map +1 -1
  31. package/dist/animation/spring/spring_collider.js +159 -21
  32. package/dist/animation/spring/spring_collider.js.map +1 -1
  33. package/dist/animation/spring/spring_particle.js +1 -0
  34. package/dist/animation/spring/spring_particle.js.map +1 -1
  35. package/dist/animation/spring/spring_solver.js +173 -0
  36. package/dist/animation/spring/spring_solver.js.map +1 -0
  37. package/dist/animation/spring/spring_system.js +249 -24
  38. package/dist/animation/spring/spring_system.js.map +1 -1
  39. package/dist/animation/spring_modifier.js +32 -1
  40. package/dist/animation/spring_modifier.js.map +1 -1
  41. package/dist/app/app.js +26 -0
  42. package/dist/app/app.js.map +1 -1
  43. package/dist/app/engine.js +86 -15
  44. package/dist/app/engine.js.map +1 -1
  45. package/dist/app/gamepad.js +191 -0
  46. package/dist/app/gamepad.js.map +1 -0
  47. package/dist/app/inputactions.js +271 -0
  48. package/dist/app/inputactions.js.map +1 -0
  49. package/dist/app/inputmgr.js +331 -22
  50. package/dist/app/inputmgr.js.map +1 -1
  51. package/dist/app/loading.js +138 -0
  52. package/dist/app/loading.js.map +1 -0
  53. package/dist/app/pipelinecache.js +209 -0
  54. package/dist/app/pipelinecache.js.map +1 -0
  55. package/dist/app/runtimescript.js +25 -0
  56. package/dist/app/runtimescript.js.map +1 -1
  57. package/dist/app/scriptingsystem.js +54 -0
  58. package/dist/app/scriptingsystem.js.map +1 -1
  59. package/dist/app/scriptregistry.js +7 -2
  60. package/dist/app/scriptregistry.js.map +1 -1
  61. package/dist/asset/asset_manifest.js +59 -0
  62. package/dist/asset/asset_manifest.js.map +1 -0
  63. package/dist/asset/asset_preload.js +258 -0
  64. package/dist/asset/asset_preload.js.map +1 -0
  65. package/dist/asset/assetmanager.js +117 -65
  66. package/dist/asset/assetmanager.js.map +1 -1
  67. package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
  68. package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
  69. package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
  70. package/dist/asset/loaders/ktx2/basis_location.js +17 -0
  71. package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
  72. package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
  73. package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
  74. package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
  75. package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
  76. package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
  77. package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
  78. package/dist/asset/mesh_lod_builder.js +104 -0
  79. package/dist/asset/mesh_lod_builder.js.map +1 -0
  80. package/dist/asset/mesh_settings.js +111 -0
  81. package/dist/asset/mesh_settings.js.map +1 -0
  82. package/dist/asset/meshopt_decoder.js +18 -0
  83. package/dist/asset/meshopt_decoder.js.map +1 -0
  84. package/dist/asset/meshopt_simplifier.js +26 -0
  85. package/dist/asset/meshopt_simplifier.js.map +1 -0
  86. package/dist/asset/model.js +171 -1
  87. package/dist/asset/model.js.map +1 -1
  88. package/dist/asset/texture_settings.js +231 -0
  89. package/dist/asset/texture_settings.js.map +1 -0
  90. package/dist/asset/zmsh_binary.js +131 -0
  91. package/dist/asset/zmsh_binary.js.map +1 -0
  92. package/dist/asset/zsdf_binary.js +111 -0
  93. package/dist/asset/zsdf_binary.js.map +1 -0
  94. package/dist/blitter/bilateralblur.js +1 -2
  95. package/dist/blitter/bilateralblur.js.map +1 -1
  96. package/dist/blitter/gaussianblur.js +1 -6
  97. package/dist/blitter/gaussianblur.js.map +1 -1
  98. package/dist/camera/base.js +31 -10
  99. package/dist/camera/base.js.map +1 -1
  100. package/dist/camera/camera.js +104 -178
  101. package/dist/camera/camera.js.map +1 -1
  102. package/dist/camera/follow.js +342 -0
  103. package/dist/camera/follow.js.map +1 -0
  104. package/dist/camera/fps.js +9 -7
  105. package/dist/camera/fps.js.map +1 -1
  106. package/dist/camera/orbit.js +46 -19
  107. package/dist/camera/orbit.js.map +1 -1
  108. package/dist/index.d.ts +25436 -15990
  109. package/dist/index.js +65 -11
  110. package/dist/index.js.map +1 -1
  111. package/dist/material/blinn.js +3 -0
  112. package/dist/material/blinn.js.map +1 -1
  113. package/dist/material/eye.js +1 -1
  114. package/dist/material/eye.js.map +1 -1
  115. package/dist/material/hair.js +2 -3
  116. package/dist/material/hair.js.map +1 -1
  117. package/dist/material/lambert.js +4 -1
  118. package/dist/material/lambert.js.map +1 -1
  119. package/dist/material/material.js +66 -4
  120. package/dist/material/material.js.map +1 -1
  121. package/dist/material/meshmaterial.js +118 -45
  122. package/dist/material/meshmaterial.js.map +1 -1
  123. package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
  124. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  125. package/dist/material/mixins/lightmodel/lambert.js +1 -1
  126. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  127. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
  128. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  129. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
  130. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  131. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
  132. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  133. package/dist/material/mixins/lit.js +191 -83
  134. package/dist/material/mixins/lit.js.map +1 -1
  135. package/dist/material/mixins/pbr/common.js +31 -206
  136. package/dist/material/mixins/pbr/common.js.map +1 -1
  137. package/dist/material/mtoon.js +1 -1
  138. package/dist/material/mtoon.js.map +1 -1
  139. package/dist/material/pbrmr.js +3 -0
  140. package/dist/material/pbrmr.js.map +1 -1
  141. package/dist/material/pbrsg.js +3 -0
  142. package/dist/material/pbrsg.js.map +1 -1
  143. package/dist/material/sdf_debug.js +78 -0
  144. package/dist/material/sdf_debug.js.map +1 -0
  145. package/dist/material/shader/helper.js +333 -191
  146. package/dist/material/shader/helper.js.map +1 -1
  147. package/dist/material/shader/terrain_blend.js +204 -43
  148. package/dist/material/shader/terrain_blend.js.map +1 -1
  149. package/dist/material/skin.js +331 -297
  150. package/dist/material/skin.js.map +1 -1
  151. package/dist/material/skinprofile.js +1058 -0
  152. package/dist/material/skinprofile.js.map +1 -0
  153. package/dist/material/sss.js +353 -0
  154. package/dist/material/sss.js.map +1 -0
  155. package/dist/material/sss_kernel.js +265 -0
  156. package/dist/material/sss_kernel.js.map +1 -0
  157. package/dist/material/sssprofile.js +879 -0
  158. package/dist/material/sssprofile.js.map +1 -0
  159. package/dist/material/subsurfaceprofile.js +4 -8
  160. package/dist/material/subsurfaceprofile.js.map +1 -1
  161. package/dist/material/terrain-cm.js +464 -188
  162. package/dist/material/terrain-cm.js.map +1 -1
  163. package/dist/material/unlit.js +3 -0
  164. package/dist/material/unlit.js.map +1 -1
  165. package/dist/material/water.js +1261 -1438
  166. package/dist/material/water.js.map +1 -1
  167. package/dist/node_modules/meshoptimizer/LICENSE +21 -0
  168. package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
  169. package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
  170. package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
  171. package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
  172. package/dist/physics/character.js +226 -0
  173. package/dist/physics/character.js.map +1 -0
  174. package/dist/physics/collider.js +209 -0
  175. package/dist/physics/collider.js.map +1 -0
  176. package/dist/physics/events.js +79 -0
  177. package/dist/physics/events.js.map +1 -0
  178. package/dist/physics/joint.js +272 -0
  179. package/dist/physics/joint.js.map +1 -0
  180. package/dist/physics/node_physics.js +234 -0
  181. package/dist/physics/node_physics.js.map +1 -0
  182. package/dist/physics/part.js +91 -0
  183. package/dist/physics/part.js.map +1 -0
  184. package/dist/physics/rigid_body.js +379 -0
  185. package/dist/physics/rigid_body.js.map +1 -0
  186. package/dist/physics/vehicle.js +335 -0
  187. package/dist/physics/vehicle.js.map +1 -0
  188. package/dist/physics/world.js +25 -0
  189. package/dist/physics/world.js.map +1 -0
  190. package/dist/posteffect/bloom.js +49 -14
  191. package/dist/posteffect/bloom.js.map +1 -1
  192. package/dist/posteffect/motionblur.js +106 -106
  193. package/dist/posteffect/motionblur.js.map +1 -1
  194. package/dist/posteffect/postsss.js +572 -0
  195. package/dist/posteffect/postsss.js.map +1 -0
  196. package/dist/posteffect/sao.js +2 -6
  197. package/dist/posteffect/sao.js.map +1 -1
  198. package/dist/posteffect/skinsss.js +605 -355
  199. package/dist/posteffect/skinsss.js.map +1 -1
  200. package/dist/posteffect/ssgi.js +91 -162
  201. package/dist/posteffect/ssgi.js.map +1 -1
  202. package/dist/posteffect/ssr.js +3 -11
  203. package/dist/posteffect/ssr.js.map +1 -1
  204. package/dist/posteffect/sss.js +4 -13
  205. package/dist/posteffect/sss.js.map +1 -1
  206. package/dist/posteffect/taa.js +1 -0
  207. package/dist/posteffect/taa.js.map +1 -1
  208. package/dist/render/abuffer_oit.js +3 -2
  209. package/dist/render/abuffer_oit.js.map +1 -1
  210. package/dist/render/clipmap.js +179 -64
  211. package/dist/render/clipmap.js.map +1 -1
  212. package/dist/render/cluster_light.js +958 -224
  213. package/dist/render/cluster_light.js.map +1 -1
  214. package/dist/render/cull_visitor.js +25 -5
  215. package/dist/render/cull_visitor.js.map +1 -1
  216. package/dist/render/debug_views.js +37 -0
  217. package/dist/render/debug_views.js.map +1 -0
  218. package/dist/render/depthpass.js +5 -1
  219. package/dist/render/depthpass.js.map +1 -1
  220. package/dist/render/drawable_mixin.js +53 -6
  221. package/dist/render/drawable_mixin.js.map +1 -1
  222. package/dist/render/dualdepthpeeling_oit.js +5 -5
  223. package/dist/render/dualdepthpeeling_oit.js.map +1 -1
  224. package/dist/render/envlight.js +196 -113
  225. package/dist/render/envlight.js.map +1 -1
  226. package/dist/render/fbm_wavegenerator.js +5 -10
  227. package/dist/render/fbm_wavegenerator.js.map +1 -1
  228. package/dist/render/fft_wavegenerator.js +247 -157
  229. package/dist/render/fft_wavegenerator.js.map +1 -1
  230. package/dist/render/gerstner_wavegenerator.js +16 -38
  231. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  232. package/dist/render/gi/probe_volume.js +1334 -0
  233. package/dist/render/gi/probe_volume.js.map +1 -0
  234. package/dist/render/gi/scene_gi.js +282 -0
  235. package/dist/render/gi/scene_gi.js.map +1 -0
  236. package/dist/render/gi/voxel_atlas.js +198 -0
  237. package/dist/render/gi/voxel_atlas.js.map +1 -0
  238. package/dist/render/gi/voxel_lighting.js +652 -0
  239. package/dist/render/gi/voxel_lighting.js.map +1 -0
  240. package/dist/render/gi/voxel_scene.js +642 -0
  241. package/dist/render/gi/voxel_scene.js.map +1 -0
  242. package/dist/render/gi/voxelize_pass.js +223 -0
  243. package/dist/render/gi/voxelize_pass.js.map +1 -0
  244. package/dist/render/globalbindgroup_allocator.js +3 -2
  245. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  246. package/dist/render/gpu_picking.js +9 -36
  247. package/dist/render/gpu_picking.js.map +1 -1
  248. package/dist/render/instance_culling.js +499 -0
  249. package/dist/render/instance_culling.js.map +1 -0
  250. package/dist/render/lightpass.js +19 -8
  251. package/dist/render/lightpass.js.map +1 -1
  252. package/dist/render/lod.js +46 -0
  253. package/dist/render/lod.js.map +1 -0
  254. package/dist/render/primitive.js +301 -9
  255. package/dist/render/primitive.js.map +1 -1
  256. package/dist/render/primitive_readback.js +209 -0
  257. package/dist/render/primitive_readback.js.map +1 -0
  258. package/dist/render/render_queue.js +162 -11
  259. package/dist/render/render_queue.js.map +1 -1
  260. package/dist/render/renderer.js +10 -7
  261. package/dist/render/renderer.js.map +1 -1
  262. package/dist/render/rendergraph/blackboard.js +14 -1
  263. package/dist/render/rendergraph/blackboard.js.map +1 -1
  264. package/dist/render/rendergraph/executor.js +136 -0
  265. package/dist/render/rendergraph/executor.js.map +1 -1
  266. package/dist/render/rendergraph/forward_plus_builder.js +272 -55
  267. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  268. package/dist/render/rendergraph/frame_graph_context.js +41 -0
  269. package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
  270. package/dist/render/rendergraph/scene_render_context.js +31 -2
  271. package/dist/render/rendergraph/scene_render_context.js.map +1 -1
  272. package/dist/render/rendergraph/types.js.map +1 -1
  273. package/dist/render/renderpass.js +28 -5
  274. package/dist/render/renderpass.js.map +1 -1
  275. package/dist/render/sdf/box_allocator.js +98 -0
  276. package/dist/render/sdf/box_allocator.js.map +1 -0
  277. package/dist/render/sdf/global_sdf.js +865 -0
  278. package/dist/render/sdf/global_sdf.js.map +1 -0
  279. package/dist/render/sdf/scene_sdf.js +562 -0
  280. package/dist/render/sdf/scene_sdf.js.map +1 -0
  281. package/dist/render/sdf/sdf_atlas.js +227 -0
  282. package/dist/render/sdf/sdf_atlas.js.map +1 -0
  283. package/dist/render/sdf/sdf_programs.js +42 -0
  284. package/dist/render/sdf/sdf_programs.js.map +1 -0
  285. package/dist/render/sdf/sdf_view.js +199 -0
  286. package/dist/render/sdf/sdf_view.js.map +1 -0
  287. package/dist/render/sdf/waterline.js +610 -0
  288. package/dist/render/sdf/waterline.js.map +1 -0
  289. package/dist/render/shadow_mask_pass.js +142 -25
  290. package/dist/render/shadow_mask_pass.js.map +1 -1
  291. package/dist/render/shore_wave_generator.js +1193 -0
  292. package/dist/render/shore_wave_generator.js.map +1 -0
  293. package/dist/render/sky.js +516 -86
  294. package/dist/render/sky.js.map +1 -1
  295. package/dist/render/transmission_thickness_pass.js +477 -0
  296. package/dist/render/transmission_thickness_pass.js.map +1 -0
  297. package/dist/render/underwater.js +58 -158
  298. package/dist/render/underwater.js.map +1 -1
  299. package/dist/render/virtualtexture/virtual_texture.js +1214 -0
  300. package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
  301. package/dist/render/volumetric_cloud/cloud_common.js +472 -0
  302. package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
  303. package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
  304. package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
  305. package/dist/render/volumetric_cloud/debug_view.js +131 -0
  306. package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
  307. package/dist/render/volumetric_cloud/resources.js +380 -0
  308. package/dist/render/volumetric_cloud/resources.js.map +1 -0
  309. package/dist/render/volumetric_cloud/sky_cache.js +380 -0
  310. package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
  311. package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
  312. package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
  313. package/dist/render/water_caustics.js +134 -319
  314. package/dist/render/water_caustics.js.map +1 -1
  315. package/dist/render/water_foam.js +627 -0
  316. package/dist/render/water_foam.js.map +1 -0
  317. package/dist/render/water_interaction.js +1795 -0
  318. package/dist/render/water_interaction.js.map +1 -0
  319. package/dist/render/weightedblended_oit.js +3 -3
  320. package/dist/render/weightedblended_oit.js.map +1 -1
  321. package/dist/scene/basesprite.js +9 -4
  322. package/dist/scene/basesprite.js.map +1 -1
  323. package/dist/scene/batchgroup.js +108 -12
  324. package/dist/scene/batchgroup.js.map +1 -1
  325. package/dist/scene/environment.js +28 -7
  326. package/dist/scene/environment.js.map +1 -1
  327. package/dist/scene/foliage.js +1020 -0
  328. package/dist/scene/foliage.js.map +1 -0
  329. package/dist/scene/foliage_buckets.js +147 -0
  330. package/dist/scene/foliage_buckets.js.map +1 -0
  331. package/dist/scene/foliage_mask.js +358 -0
  332. package/dist/scene/foliage_mask.js.map +1 -0
  333. package/dist/scene/hair.js +15 -4
  334. package/dist/scene/hair.js.map +1 -1
  335. package/dist/scene/light.js +179 -13
  336. package/dist/scene/light.js.map +1 -1
  337. package/dist/scene/mesh.js +327 -45
  338. package/dist/scene/mesh.js.map +1 -1
  339. package/dist/scene/meshdrawable.js +6 -0
  340. package/dist/scene/meshdrawable.js.map +1 -1
  341. package/dist/scene/msdftext.js +9 -3
  342. package/dist/scene/msdftext.js.map +1 -1
  343. package/dist/scene/msdftextsprite.js +9 -3
  344. package/dist/scene/msdftextsprite.js.map +1 -1
  345. package/dist/scene/particlesys.js +8 -2
  346. package/dist/scene/particlesys.js.map +1 -1
  347. package/dist/scene/physics_settings.js +157 -0
  348. package/dist/scene/physics_settings.js.map +1 -0
  349. package/dist/scene/scene.js +190 -44
  350. package/dist/scene/scene.js.map +1 -1
  351. package/dist/scene/scene_node.js +147 -6
  352. package/dist/scene/scene_node.js.map +1 -1
  353. package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
  354. package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
  355. package/dist/scene/terrain-cm/grass.js +881 -42
  356. package/dist/scene/terrain-cm/grass.js.map +1 -1
  357. package/dist/scene/terrain-cm/grass_gpu.js +929 -0
  358. package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
  359. package/dist/scene/terrain-cm/grassmaterial.js +180 -9
  360. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  361. package/dist/scene/terrain-cm/terrain-cm.js +465 -36
  362. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  363. package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
  364. package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
  365. package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
  366. package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
  367. package/dist/scene/update_queue.js +54 -0
  368. package/dist/scene/update_queue.js.map +1 -0
  369. package/dist/scene/water.js +633 -268
  370. package/dist/scene/water.js.map +1 -1
  371. package/dist/scene/water_surface_sampler.js +324 -0
  372. package/dist/scene/water_surface_sampler.js.map +1 -0
  373. package/dist/scene/wind.js +317 -0
  374. package/dist/scene/wind.js.map +1 -0
  375. package/dist/shaders/atmosphere.js +388 -166
  376. package/dist/shaders/atmosphere.js.map +1 -1
  377. package/dist/shaders/fog.js +100 -32
  378. package/dist/shaders/fog.js.map +1 -1
  379. package/dist/shaders/gi.js +365 -0
  380. package/dist/shaders/gi.js.map +1 -0
  381. package/dist/shaders/ltc_rect.js +202 -0
  382. package/dist/shaders/ltc_rect.js.map +1 -0
  383. package/dist/shaders/misc.js +1 -10
  384. package/dist/shaders/misc.js.map +1 -1
  385. package/dist/shaders/noise.js +5 -1
  386. package/dist/shaders/noise.js.map +1 -1
  387. package/dist/shaders/probes.js +309 -0
  388. package/dist/shaders/probes.js.map +1 -0
  389. package/dist/shaders/sdf.js +537 -0
  390. package/dist/shaders/sdf.js.map +1 -0
  391. package/dist/shaders/shadow.js +104 -70
  392. package/dist/shaders/shadow.js.map +1 -1
  393. package/dist/shaders/skin_brdf.js +243 -0
  394. package/dist/shaders/skin_brdf.js.map +1 -0
  395. package/dist/shaders/ssgi.js +63 -0
  396. package/dist/shaders/ssgi.js.map +1 -0
  397. package/dist/shaders/ssgi_reprojection.js +118 -0
  398. package/dist/shaders/ssgi_reprojection.js.map +1 -0
  399. package/dist/shaders/ssr.js +6 -159
  400. package/dist/shaders/ssr.js.map +1 -1
  401. package/dist/shaders/temporal.js +38 -27
  402. package/dist/shaders/temporal.js.map +1 -1
  403. package/dist/shaders/water.js +32 -82
  404. package/dist/shaders/water.js.map +1 -1
  405. package/dist/shaders/water_medium.js +7 -21
  406. package/dist/shaders/water_medium.js.map +1 -1
  407. package/dist/shadow/dom.js +110 -19
  408. package/dist/shadow/dom.js.map +1 -1
  409. package/dist/shadow/esm.js +3 -3
  410. package/dist/shadow/esm.js.map +1 -1
  411. package/dist/shadow/pcf_opt.js +15 -48
  412. package/dist/shadow/pcf_opt.js.map +1 -1
  413. package/dist/shadow/pcf_pd.js +15 -53
  414. package/dist/shadow/pcf_pd.js.map +1 -1
  415. package/dist/shadow/pcss.js +34 -9
  416. package/dist/shadow/pcss.js.map +1 -1
  417. package/dist/shadow/shadow_impl.js +3 -8
  418. package/dist/shadow/shadow_impl.js.map +1 -1
  419. package/dist/shadow/shadow_region.js +40 -2
  420. package/dist/shadow/shadow_region.js.map +1 -1
  421. package/dist/shadow/shadowmapper.js +93 -53
  422. package/dist/shadow/shadowmapper.js.map +1 -1
  423. package/dist/shadow/ssm.js +18 -72
  424. package/dist/shadow/ssm.js.map +1 -1
  425. package/dist/shadow/vsm.js +3 -3
  426. package/dist/shadow/vsm.js.map +1 -1
  427. package/dist/shapes/shape.js +44 -1
  428. package/dist/shapes/shape.js.map +1 -1
  429. package/dist/utility/buoyancy.js +287 -0
  430. package/dist/utility/buoyancy.js.map +1 -0
  431. package/dist/utility/physical.js +10 -1
  432. package/dist/utility/physical.js.map +1 -1
  433. package/dist/utility/pmrem.js +17 -43
  434. package/dist/utility/pmrem.js.map +1 -1
  435. package/dist/utility/sdf/bake.js +435 -0
  436. package/dist/utility/sdf/bake.js.map +1 -0
  437. package/dist/utility/sdf/bvh.js +576 -0
  438. package/dist/utility/sdf/bvh.js.map +1 -0
  439. package/dist/utility/serialization/manager.js +34 -6
  440. package/dist/utility/serialization/manager.js.map +1 -1
  441. package/dist/utility/serialization/scene/animation.js +46 -5
  442. package/dist/utility/serialization/scene/animation.js.map +1 -1
  443. package/dist/utility/serialization/scene/batch.js +11 -4
  444. package/dist/utility/serialization/scene/batch.js.map +1 -1
  445. package/dist/utility/serialization/scene/camera.js +87 -254
  446. package/dist/utility/serialization/scene/camera.js.map +1 -1
  447. package/dist/utility/serialization/scene/cloth.js +25 -0
  448. package/dist/utility/serialization/scene/cloth.js.map +1 -0
  449. package/dist/utility/serialization/scene/common.js +14 -6
  450. package/dist/utility/serialization/scene/common.js.map +1 -1
  451. package/dist/utility/serialization/scene/foliage.js +821 -0
  452. package/dist/utility/serialization/scene/foliage.js.map +1 -0
  453. package/dist/utility/serialization/scene/hair.js +11 -4
  454. package/dist/utility/serialization/scene/hair.js.map +1 -1
  455. package/dist/utility/serialization/scene/light.js +115 -7
  456. package/dist/utility/serialization/scene/light.js.map +1 -1
  457. package/dist/utility/serialization/scene/material.js +388 -220
  458. package/dist/utility/serialization/scene/material.js.map +1 -1
  459. package/dist/utility/serialization/scene/mesh.js +69 -4
  460. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  461. package/dist/utility/serialization/scene/node.js +140 -5
  462. package/dist/utility/serialization/scene/node.js.map +1 -1
  463. package/dist/utility/serialization/scene/node_physics.js +1318 -0
  464. package/dist/utility/serialization/scene/node_physics.js.map +1 -0
  465. package/dist/utility/serialization/scene/particle.js +11 -4
  466. package/dist/utility/serialization/scene/particle.js.map +1 -1
  467. package/dist/utility/serialization/scene/physics.js +120 -0
  468. package/dist/utility/serialization/scene/physics.js.map +1 -0
  469. package/dist/utility/serialization/scene/primitive.js +124 -10
  470. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  471. package/dist/utility/serialization/scene/scene.js +1687 -51
  472. package/dist/utility/serialization/scene/scene.js.map +1 -1
  473. package/dist/utility/serialization/scene/sprite.js +11 -4
  474. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  475. package/dist/utility/serialization/scene/terrain.js +163 -33
  476. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  477. package/dist/utility/serialization/scene/text.js +11 -4
  478. package/dist/utility/serialization/scene/text.js.map +1 -1
  479. package/dist/utility/serialization/scene/water.js +1543 -264
  480. package/dist/utility/serialization/scene/water.js.map +1 -1
  481. package/dist/utility/serialization/types.js.map +1 -1
  482. package/dist/utility/shprojector.js +10 -22
  483. package/dist/utility/shprojector.js.map +1 -1
  484. package/dist/utility/textures/foam.js +170 -0
  485. package/dist/utility/textures/foam.js.map +1 -0
  486. package/dist/utility/textures/ggxlut.js +17 -43
  487. package/dist/utility/textures/ggxlut.js.map +1 -1
  488. package/dist/utility/textures/ltcdata.js +4 -4
  489. package/dist/utility/textures/ltcdata.js.map +1 -1
  490. package/dist/utility/textures/ltclut.js +16 -6
  491. package/dist/utility/textures/ltclut.js.map +1 -1
  492. package/dist/utility/unsupported.js +24 -0
  493. package/dist/utility/unsupported.js.map +1 -0
  494. package/dist/values.js +13 -1
  495. package/dist/values.js.map +1 -1
  496. package/package.json +25 -12
  497. package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
  498. package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
  499. package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
  500. package/src/asset/meshoptimizer/LICENSE +21 -0
  501. package/dist/animation/joint_dynamics/convex_collider.js +0 -320
  502. package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"water.js","sources":["../../src/material/water.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BindGroup,\r\n PBFunctionScope,\r\n PBInsideFunctionScope,\r\n PBShaderExp,\r\n Texture2D\r\n} from '@zephyr3d/device';\r\nimport { applyMaterialMixins, MeshMaterial } from './meshmaterial';\r\nimport type { DrawContext, WaveGenerator } from '../render';\r\nimport { LIGHT_TYPE_DIRECTIONAL, MaterialVaryingFlags } from '../values';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { DRef, DWeakRef, Interpolator, Vector3, Vector4 } from '@zephyr3d/base';\r\nimport { screenSpaceRayTracing_HiZ, screenSpaceRayTracing_Linear2D } from '../shaders/ssr';\r\nimport { fetchSampler } from '../utility/misc';\r\nimport { mixinLight } from './mixins/lit';\r\nimport { distributionGGX, fresnelSchlick, visGGX } from '../shaders/pbr';\r\nimport { interleavedGradientNoise, valueNoise } from '../shaders/noise';\r\nimport { waterScatterPhase } from '../shaders/water_medium';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * How the water medium converts a path length into transmittance and in-scattering.\r\n *\r\n * - `physical`: Beer-Lambert with authored absorption/scattering coefficients in 1/m.\r\n * - `ramp`: artist-authored ramp textures indexed by `depth * depthMulti`. Caustics\r\n * still use the physical coefficients, so the two can disagree in this mode.\r\n *\r\n * @public\r\n */\r\nexport type WaterMediumMode = 'physical' | 'ramp';\r\n\r\n/**\r\n * How the refracted view sample is located.\r\n *\r\n * - `march`: walk the refracted ray against the scene depth buffer and sample at\r\n * the first crossing, at the cost of {@link REFRACT_MARCH_STEPS} depth fetches\r\n * per water pixel.\r\n * - `offset`: displace the screen UV by the refraction of the wave normal alone,\r\n * with no search. Much cheaper, but the sample does not land where the ray\r\n * actually goes and the medium tint uses the straight-line distance.\r\n *\r\n * The two agree on calm water viewed from above and diverge with wave steepness\r\n * and view angle.\r\n *\r\n * @public\r\n */\r\nexport type WaterRefractionMode = 'march' | 'offset';\r\n\r\n/**\r\n * Debug view of the water shading, replacing the final colour with one of its\r\n * intermediate terms.\r\n *\r\n * - `none`: normal shading.\r\n * - `normal`: wave normal, remapped to [0,1].\r\n * - `diffuseNormal`: the normal the diffuse terms use, remapped to [0,1].\r\n * - `viewFacing`: dot(wave normal, towards the eye), as grey.\r\n * - `frontFacing`: white where the rasterised triangle faces the eye, black on\r\n * the underside of a folded crest.\r\n * - `foam`: foam coverage after the amount/falloff ramp, as grey. Both sources.\r\n * - `shoreFoam`: the shoreline contribution on its own, as grey.\r\n * - `waterDepth`: distance from the surface to the nearest solid around it, in\r\n * metres / 10, as grey.\r\n * - `fresnel`: reflection weight after foam suppression, as grey.\r\n * - `reflection`: what the surface reflects (SSR blended over the sky).\r\n * - `refraction`: the scene sample behind the water, before the medium tint.\r\n * - `absorption`: medium transmittance over the refracted path.\r\n * - `scattering`: ambient in-scattering from the water body.\r\n * - `sunScattering`: directional in-scattering from the lights.\r\n * - `sunPhase`: the scattering phase function of it, as grey.\r\n * - `sunIntegral`: the depth integral of it, as grey (1 is optically thick).\r\n * - `sunNoL`: the diffuse incidence the sun's terms are weighted by, as grey.\r\n * - `shadow`: the shadow factor the directional lights are attenuated by.\r\n * - `subsurface`: the backlit-crest translucency term.\r\n * - `specular`: the specular lobe from the lights.\r\n * - `depth`: refracted path length through the medium, metres / 10.\r\n * - `refractUV`: the refracted sample's offset from the pixel, remapped so\r\n * no offset is mid grey.\r\n * - `nan`: red where the final colour or the normal is NaN/inf, black elsewhere.\r\n *\r\n * Each value is a separate shader variant; the `none` variant carries no trace\r\n * of the others.\r\n *\r\n * @public\r\n */\r\nexport type WaterDebugOutput =\r\n | 'none'\r\n | 'normal'\r\n | 'diffuseNormal'\r\n | 'viewFacing'\r\n | 'frontFacing'\r\n | 'foam'\r\n | 'shoreFoam'\r\n | 'waterDepth'\r\n | 'fresnel'\r\n | 'reflection'\r\n | 'refraction'\r\n | 'absorption'\r\n | 'scattering'\r\n | 'sunScattering'\r\n | 'sunPhase'\r\n | 'sunIntegral'\r\n | 'sunNoL'\r\n | 'shadow'\r\n | 'subsurface'\r\n | 'specular'\r\n | 'depth'\r\n | 'refractUV'\r\n | 'nan';\r\n\r\n/** Label/value pairs for {@link WaterDebugOutput}, for editor enumerations. */\r\nexport const WATER_DEBUG_OUTPUTS = [\r\n { label: 'None', value: 'none' },\r\n { label: 'Normal', value: 'normal' },\r\n { label: 'Diffuse normal', value: 'diffuseNormal' },\r\n { label: 'View facing', value: 'viewFacing' },\r\n { label: 'Front facing', value: 'frontFacing' },\r\n { label: 'Foam', value: 'foam' },\r\n { label: 'Shore foam', value: 'shoreFoam' },\r\n { label: 'Water depth', value: 'waterDepth' },\r\n { label: 'Fresnel', value: 'fresnel' },\r\n { label: 'Reflection', value: 'reflection' },\r\n { label: 'Refraction', value: 'refraction' },\r\n { label: 'Absorption', value: 'absorption' },\r\n { label: 'Scattering', value: 'scattering' },\r\n { label: 'Sun scattering', value: 'sunScattering' },\r\n { label: 'Sun phase', value: 'sunPhase' },\r\n { label: 'Sun integral', value: 'sunIntegral' },\r\n { label: 'Sun NoL', value: 'sunNoL' },\r\n { label: 'Shadow', value: 'shadow' },\r\n { label: 'Subsurface', value: 'subsurface' },\r\n { label: 'Specular', value: 'specular' },\r\n { label: 'Depth', value: 'depth' },\r\n { label: 'Refract UV', value: 'refractUV' },\r\n { label: 'NaN', value: 'nan' }\r\n] as const;\r\n\r\n/** Fresnel reflectance of water at normal incidence, for n = 1.333. */\r\nconst WATER_F0 = 0.02;\r\n/** Specular roughness of water close enough that the waves are resolved. */\r\nconst WATER_BASE_ROUGHNESS = 0.04;\r\n/**\r\n * Specular roughness once the distance fade has flattened the waves away.\r\n * Widened by the same amount the slope was cut, so the remaining mirror does\r\n * not alias.\r\n */\r\nconst WATER_DISTANT_ROUGHNESS = 0.35;\r\n/** Index of refraction of water. Matches the caustics pass. */\r\nconst WATER_IOR = 1.333;\r\n/** Ratio for a ray entering the water from air, as `refract` wants it. */\r\nconst AIR_TO_WATER_ETA = 1 / WATER_IOR;\r\n/** Ratio for a ray leaving the water into air. */\r\nconst WATER_TO_AIR_ETA = WATER_IOR;\r\n/**\r\n * Cap on the refracted path length, as a multiple of the straight-line distance\r\n * to what is behind the water. A guard against nearly tangent rays; Snell bounds\r\n * the true ratio near 1.5 above water, so this leaves headroom.\r\n */\r\nconst REFRACT_MAX_PATH_RATIO = 4;\r\n/**\r\n * Number of steps the refracted-ray march takes over {@link REFRACT_MAX_PATH_RATIO}.\r\n *\r\n * Sets how finely a scene discontinuity is caught. Fixed count keeps the shader\r\n * uniform across backends; 24 steps resolve a crest-to-bed exchange to well\r\n * under a water pixel at typical camera distances.\r\n */\r\nconst REFRACT_MARCH_STEPS = 24;\r\n/** Depth tolerance, in meters, for the march to treat a step as a hit. */\r\nconst REFRACT_MARCH_THICKNESS = 0.05;\r\n/**\r\n * Fraction of the far plane an infinite water surface is pulled in to.\r\n *\r\n * Short of 1 so the result is never the vertex the hardware clips, and never\r\n * lands on the cleared depth value that `ShaderHelper.isFarthestDepth` tests for\r\n * by equality.\r\n */\r\nconst INFINITE_DEPTH_PULLIN = 0.99;\r\n/**\r\n * Minimum reflection-direction y a water surface samples the sky bake with.\r\n *\r\n * The bake's lower hemisphere is near-black, so grazing reflections would read\r\n * the dark terminator. Re-normalised after the floor, so only the few pixels\r\n * near the horizon change.\r\n */\r\nconst HORIZON_REFLECT_BIAS = 0.08;\r\n/**\r\n * Width in UV of the band the refraction offset fades out over at the screen\r\n * border. Off-screen there is no scene colour to refract, and a clamped sample\r\n * smears the border pixel across the water.\r\n */\r\nconst REFRACT_EDGE_FADE = 0.06;\r\n/**\r\n * Normalized linear depth at or above which what is behind the water is taken to\r\n * be the sky, and the refraction can skip its march.\r\n */\r\nconst SCENE_SKY_DEPTH01 = 0.999;\r\n/**\r\n * How far the surface normal bends the transmitted direction in the subsurface\r\n * term. This is what lets the wave itself modulate the glow.\r\n */\r\nconst SSS_DISTORTION = 0.25;\r\n/** Falloff of the subsurface lobe. Higher keeps the glow closer to the sun. */\r\nconst SSS_POWER = 4;\r\n/**\r\n * Mean cosine of one scattering event in the water body.\r\n *\r\n * Real sea water measures near 0.9, but at that value almost nothing comes back\r\n * towards a camera looking down at the water. The default gives up some of that\r\n * peak for a term that reads from above; the multiple-scattering blend in\r\n * {@link WaterMaterial.waterSunScattering} restores the isotropy.\r\n */\r\nexport const DEFAULT_SCATTER_ANISOTROPY = 0.7;\r\n/**\r\n * Floor on how fast the refracted sun ray descends, used by the in-scattering\r\n * integral, so a sun on the horizon cannot make the term diverge. Snell refracts\r\n * even a grazing sun to about 41 degrees below the surface, so it is unreachable\r\n * for any sun actually above the horizon.\r\n */\r\nconst MIN_SUN_SLOPE = 0.05;\r\n/**\r\n * Blur per meter of path that even a non-scattering medium produces, in mip\r\n * widths. The wave normal varies across a texel's footprint, so the background\r\n * is slightly defocused by the geometry alone.\r\n */\r\nconst REFRACT_BLUR_GEOMETRIC = 0.02;\r\n/**\r\n * How strongly the scattering coefficient drives the refraction blur, mapping\r\n * 1/m onto mip widths per meter. Sized so sigma_s near 0.4 reaches the top of\r\n * the mip chain over a few meters while clear water stays sharp.\r\n */\r\nconst REFRACT_BLUR_DENSITY = 1.5;\r\n/**\r\n * Cap on the refraction blur LOD.\r\n *\r\n * Past this the sample stops being \"what is behind the water\" and becomes the\r\n * average of the frame. Six levels is a 64x footprint, already far wider than\r\n * any real forward-scattering kernel.\r\n */\r\nexport const REFRACT_BLUR_MAX_LOD = 6;\r\n/**\r\n * Share of the shoreline ramp the foam pattern is allowed to eat into.\r\n *\r\n * The pattern raises the threshold the ramp has to clear, which breaks its outer\r\n * edge into clumps. Below 1 so the foam at the contact line survives it.\r\n */\r\nconst SHORE_FOAM_NOISE_BITE = 0.6;\r\n/** World-space drift of the foam pattern, m/s. Off-axis so it has no grain. */\r\nconst SHORE_FOAM_DRIFT_X = 0.11;\r\n/** @see SHORE_FOAM_DRIFT_X */\r\nconst SHORE_FOAM_DRIFT_Z = -0.07;\r\n/** Frequency ratio between octaves. Not 2, which would align the lattices. */\r\nconst SHORE_FOAM_OCTAVE_RATIO = 2.17;\r\n/**\r\n * Weight of each foam pattern octave, coarsest first. Three octaves span about\r\n * five times in feature size, so one authored clump size serves both a wide\r\n * shoreline and a narrow collar.\r\n */\r\nconst SHORE_FOAM_OCTAVE_WEIGHTS = [0.5, 0.3, 0.2];\r\n/**\r\n * Width of the band's gradient, as a fraction of the distance it reaches,\r\n * running inward from the reach. 1 fades across the whole band, 0 makes it a\r\n * hard-edged slab. The pattern can only break up what is still in the gradient.\r\n */\r\nconst SHORE_FOAM_EDGE_SOFTNESS = 0.85;\r\n/**\r\n * Hi-Z cells the proximity query's window spreads over its radius, which sets\r\n * the pyramid level. Higher locates surfaces more precisely but stops covering\r\n * the whole footprint, and geometry in the uncovered corners is missed.\r\n */\r\nconst SHORE_QUERY_TAP_SPREAD = 1.5;\r\n/**\r\n * Softness of the proximity query's minimum, as a fraction of its radius. A hard\r\n * minimum leaves the band in cell-shaped squares; the trade is that the band\r\n * sits a little tighter than the authored reach.\r\n */\r\nconst SHORE_QUERY_SOFTMIN = 0.25;\r\n/**\r\n * Distance, in radii, that an empty neighbourhood resolves to. Distances are\r\n * clamped to it before the exponential, so nothing can underflow every term and\r\n * leave the logarithm with nothing to take.\r\n */\r\nconst SHORE_QUERY_MISS_REACH = 2;\r\n/** Advance of the dither's hash input per frame, for TAA to average over. */\r\nconst SHORE_QUERY_DITHER_STRIDE = 5.588238;\r\n/**\r\n * How thick a cell's frustum block may be, in multiples of its own width. A cell\r\n * spanning an object's edge would otherwise stretch down the view ray and grow\r\n * foam on water far behind the object.\r\n */\r\nconst SHORE_QUERY_CELL_DEPTH_SPAN = 2;\r\n\r\nexport class WaterMaterial extends applyMaterialMixins(MeshMaterial, mixinLight) {\r\n private static readonly FEATURE_MEDIUM_MODE = this.defineFeature();\r\n private static readonly FEATURE_REFRACTION_MODE = this.defineFeature();\r\n private static readonly FEATURE_INFINITE = this.defineFeature();\r\n private static readonly FEATURE_SHORE_FOAM = this.defineFeature();\r\n private static readonly FEATURE_DEBUG_OUTPUT = this.defineFeature();\r\n private static readonly _absorptionGrad = new Interpolator(\r\n 'linear',\r\n 'vec3',\r\n new Float32Array([0, 0.082, 0.318, 0.665, 1]),\r\n new Float32Array([1, 1, 1, 0.22, 0.87, 0.87, 0, 0.47, 0.49, 0, 0.275, 0.44, 0, 0, 0])\r\n );\r\n private static readonly _scatterGrad = new Interpolator(\r\n 'linear',\r\n 'vec3',\r\n new Float32Array([0, 0.15, 0.42, 1]),\r\n new Float32Array([0, 0, 0, 0.08, 0.41, 0.34, 0.13, 0.4, 0.45, 0.21, 0.5, 0.6])\r\n );\r\n private static readonly _defaultScatterRampTexture: DWeakRef<Texture2D> = new DWeakRef();\r\n private static readonly _defaultAbsorptionRampTexture: DWeakRef<Texture2D> = new DWeakRef();\r\n private static readonly _waveUpdateState: WeakMap<WaveGenerator, number> = new WeakMap();\r\n private readonly _region: Vector4;\r\n private _refractionScale: number;\r\n private _depthMulti: number;\r\n private _reflectionStrength: number;\r\n private readonly _scatterRampTexture: DRef<Texture2D>;\r\n private readonly _absorptionRampTexture: DRef<Texture2D>;\r\n private readonly _waveGenerator: DRef<WaveGenerator>;\r\n /**\r\n * Per-bind-group wave uniform sync, keyed by the bind group object.\r\n *\r\n * The material owns one bind group per pass/render-variant hash, so a water\r\n * surface drawn for two different cameras touches two distinct bind groups\r\n * and each must upload once per wave generator version.\r\n */\r\n private _waveVersionByBindGroup: WeakMap<BindGroup, number>;\r\n private readonly _clipmapInfo: Vector4;\r\n private readonly _clipmapGridInfo: Vector4;\r\n private _skirtDistance: number;\r\n private readonly _ssrParams: Vector4;\r\n /** Absorption coefficient sigma_a, per meter, per RGB channel. */\r\n private readonly _absorption: Vector3;\r\n /** Scattering coefficient sigma_s, per meter, per RGB channel. */\r\n private readonly _scattering: Vector3;\r\n /** sigma_a + sigma_s, recomputed whenever either coefficient changes. */\r\n private readonly _extinction: Vector3;\r\n /** sigma_s / sigma_t, the single-scattering albedo. */\r\n private readonly _scatterAlbedo: Vector3;\r\n /** Scale for the absorption coefficient. */\r\n private _absorptionScale: number;\r\n /** Scale for the scattering coefficient. */\r\n private _scatteringScale: number;\r\n private _causticsEnabled: boolean;\r\n private _causticsIntensity: number;\r\n private _causticsDepth: number;\r\n private _causticsRange: number;\r\n private _causticsFadeDistance: number;\r\n private _causticsWarp: number;\r\n private _causticsSceneDepth: boolean;\r\n private _causticsDefocus: number;\r\n private _causticsResolution: number;\r\n private _causticsPhotonResolution: number;\r\n private _causticsBlurPasses: number;\r\n private _causticsTemporalStrength: number;\r\n private _underwaterEnabled: boolean;\r\n private _underwaterAmbientIntensity: number;\r\n private _underwaterGodRays: boolean;\r\n private _underwaterGodRayIntensity: number;\r\n private _underwaterGodRaySteps: number;\r\n private _underwaterGodRayShadow: boolean;\r\n private _underwaterHysteresis: number;\r\n private _subsurfaceIntensity: number;\r\n private _subsurfaceSteepness: number;\r\n private readonly _subsurfaceParams: Vector4;\r\n private _sunScatteringIntensity: number;\r\n private _scatterAnisotropy: number;\r\n private readonly _sunScatterParams: Vector4;\r\n private _refractionBlur: number;\r\n private _cheapRefractionDepth: number;\r\n private _foamAmount: number;\r\n private _foamFalloff: number;\r\n private readonly _foamColor: Vector3;\r\n private readonly _foamParams: Vector4;\r\n private _shoreFoamAmount: number;\r\n private _shoreFoamDepth: number;\r\n private _shoreFoamFalloff: number;\r\n private _shoreFoamScale: number;\r\n private _shoreFoamWashAmount: number;\r\n private _shoreFoamWashSpeed: number;\r\n private _shoreFoamWashScale: number;\r\n private readonly _shoreFoamParams: Vector4;\r\n private readonly _shoreFoamWashParams: Vector4;\r\n constructor() {\r\n super();\r\n this._region = new Vector4(-99999, -99999, 99999, 99999);\r\n // Fitted to the legacy absorption ramp at depthMulti = 0.1, so switching the\r\n // medium to physical does not change the out-of-box look much.\r\n this._absorption = new Vector3(1.0, 0.25, 0.15);\r\n this._scattering = new Vector3(0.05, 0.12, 0.18);\r\n this._extinction = new Vector3();\r\n this._scatterAlbedo = new Vector3();\r\n this._absorptionScale = 1;\r\n this._scatteringScale = 1;\r\n this._updateMediumCoefficients();\r\n this._clipmapInfo = new Vector4();\r\n this._clipmapGridInfo = new Vector4();\r\n this._skirtDistance = 0;\r\n this._waveGenerator = new DRef();\r\n this._waveVersionByBindGroup = new WeakMap();\r\n this._ssrParams = new Vector4(1000, 160, 0.5, 2);\r\n this._scatterRampTexture = new DRef();\r\n this._absorptionRampTexture = new DRef();\r\n this._refractionScale = 1;\r\n this._depthMulti = 0.1;\r\n this._reflectionStrength = 1;\r\n this._causticsEnabled = true;\r\n this._causticsIntensity = 1;\r\n this._causticsDepth = 4;\r\n this._causticsRange = 60;\r\n this._causticsFadeDistance = 0;\r\n this._causticsWarp = 1.5;\r\n this._causticsSceneDepth = true;\r\n this._causticsDefocus = 0.12;\r\n this._causticsResolution = 1024;\r\n this._causticsPhotonResolution = 0;\r\n this._causticsBlurPasses = 2;\r\n this._causticsTemporalStrength = 0.85;\r\n this._underwaterEnabled = true;\r\n this._underwaterAmbientIntensity = 1;\r\n this._underwaterGodRays = true;\r\n this._underwaterGodRayIntensity = 1;\r\n this._underwaterGodRaySteps = 24;\r\n // Off by default: it is a shadow map lookup per march step on top of the\r\n // caustic lookup already there, which roughly doubles the cost of the\r\n // shafts. Worth turning on for a scene with something large standing in the\r\n // water, where a shaft running through it unbroken is the obvious artefact.\r\n this._underwaterGodRayShadow = false;\r\n // A few centimetres. Wide enough that floating-point noise on the camera\r\n // height cannot flip the state, narrow enough that the transition still\r\n // happens where the eye expects it.\r\n this._underwaterHysteresis = 0.05;\r\n // Sized so a fully lit crest contributes about as much as the ambient\r\n // scattering term already does.\r\n this._subsurfaceIntensity = 1.5;\r\n // At 4 the wave flanks carry the glow and the troughs stay dark; 20 turns\r\n // the whole sea into a lamp.\r\n this._subsurfaceSteepness = 4;\r\n this._subsurfaceParams = new Vector4();\r\n // The integral is derived, not fitted, so 1 is what the medium coefficients\r\n // already imply.\r\n this._sunScatteringIntensity = 1;\r\n this._scatterAnisotropy = DEFAULT_SCATTER_ANISOTROPY;\r\n this._sunScatterParams = new Vector4();\r\n this._refractionBlur = 1;\r\n // A shallow-pool depth: the offset stays plausible on thin water and cannot\r\n // reach across a large object's silhouette.\r\n this._cheapRefractionDepth = 1;\r\n // Coverage from the generator is a folded-surface measure, not an area\r\n // fraction; these map it onto one. The falloff above 1 keeps light folding\r\n // from reading as foam.\r\n this._foamAmount = 1;\r\n this._foamFalloff = 1.5;\r\n // Slightly off-white and slightly blue: sea foam is water and air, and a\r\n // pure white one reads as snow.\r\n this._foamColor = new Vector3(0.92, 0.95, 0.97);\r\n this._foamParams = new Vector4();\r\n // Off by default. The shoreline estimate is a property of whatever happens\r\n // to be behind the surface, so it would grow a white rim around every\r\n // submerged object in a scene authored without it.\r\n this._shoreFoamAmount = 0;\r\n // A waterline band of a foot or two: a wave over a gently shelving bed moves\r\n // it visibly, but it stays a band and not a white lagoon.\r\n this._shoreFoamDepth = 0.5;\r\n // Above 1, so coverage falls off towards the outer edge rather than filling\r\n // the whole band.\r\n this._shoreFoamFalloff = 1.5;\r\n // A couple of clumps across the band's width, whatever that width is.\r\n this._shoreFoamScale = 2.5;\r\n // Half the band's depth, so the waterline visibly advances and retreats\r\n // without the band ever closing completely.\r\n this._shoreFoamWashAmount = 0.5;\r\n // One wash every eight seconds or so - the band is what a set of waves does,\r\n // not what one wave does.\r\n this._shoreFoamWashSpeed = 0.12;\r\n // Wash phase decorrelates over ~30 m, so a long shoreline breaks in sections\r\n // instead of pulsing as one.\r\n this._shoreFoamWashScale = 0.03;\r\n this._shoreFoamParams = new Vector4();\r\n this._shoreFoamWashParams = new Vector4();\r\n this.cullMode = 'none';\r\n this.useFeature(WaterMaterial.FEATURE_MEDIUM_MODE, 'physical' as WaterMediumMode);\r\n this.useFeature(WaterMaterial.FEATURE_REFRACTION_MODE, 'march' as WaterRefractionMode);\r\n this.useFeature(WaterMaterial.FEATURE_INFINITE, false);\r\n this.useFeature(WaterMaterial.FEATURE_SHORE_FOAM, false);\r\n this.useFeature(WaterMaterial.FEATURE_DEBUG_OUTPUT, 'none' as WaterDebugOutput);\r\n //this.TAADisabled = true;\r\n }\r\n /** {@inheritDoc Material.onDispose} */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._waveGenerator.dispose();\r\n this._scatterRampTexture.dispose();\r\n this._absorptionRampTexture.dispose();\r\n }\r\n /** @internal */\r\n get region() {\r\n return this._region;\r\n }\r\n /** @internal */\r\n set region(val: Vector4) {\r\n if (!val.equalsTo(this._region)) {\r\n this._region.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n get waveGenerator() {\r\n return this._waveGenerator.get();\r\n }\r\n set waveGenerator(waveGenerator: Nullable<WaveGenerator>) {\r\n if (this._waveGenerator.get() !== waveGenerator) {\r\n this._waveGenerator.set(waveGenerator);\r\n // Bind groups are pooled and reused across frames, so an old entry must\r\n // not suppress the upload for a new generator.\r\n this._waveVersionByBindGroup = new WeakMap();\r\n this.optionChanged(true);\r\n }\r\n }\r\n get scatterRampTexture() {\r\n const tex = this._getScatterRampTexture(getDevice());\r\n return tex === WaterMaterial._defaultScatterRampTexture.get() ? null : tex;\r\n }\r\n set scatterRampTexture(tex) {\r\n if (tex !== this.scatterRampTexture) {\r\n this._scatterRampTexture.set(tex);\r\n this.uniformChanged();\r\n }\r\n }\r\n get absorptionRampTexture() {\r\n const tex = this._getAbsorptionRampTexture(getDevice());\r\n return tex === WaterMaterial._defaultAbsorptionRampTexture.get() ? null : tex;\r\n }\r\n set absorptionRampTexture(tex) {\r\n if (tex !== this.absorptionRampTexture) {\r\n this._absorptionRampTexture.set(tex);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * How the medium turns a path length into transmittance and in-scattering.\r\n *\r\n * Defaults to `physical`. `ramp` restores the legacy ramp-texture lookup for\r\n * scenes that were tuned against it.\r\n */\r\n get mediumMode(): WaterMediumMode {\r\n return this.featureUsed<WaterMediumMode>(WaterMaterial.FEATURE_MEDIUM_MODE) ?? 'physical';\r\n }\r\n set mediumMode(val: WaterMediumMode) {\r\n if (val !== this.mediumMode) {\r\n this.useFeature(WaterMaterial.FEATURE_MEDIUM_MODE, val);\r\n }\r\n }\r\n /**\r\n * How the refracted view sample is located. Defaults to `march`.\r\n *\r\n * Set `offset` on hardware that cannot afford the depth-buffer search - the\r\n * water still refracts, it just refracts to the wrong place. A compile-time\r\n * feature, so the cheap variant carries no trace of the march.\r\n */\r\n get refractionMode(): WaterRefractionMode {\r\n return this.featureUsed<WaterRefractionMode>(WaterMaterial.FEATURE_REFRACTION_MODE) ?? 'march';\r\n }\r\n set refractionMode(val: WaterRefractionMode) {\r\n if (val !== this.refractionMode) {\r\n this.useFeature(WaterMaterial.FEATURE_REFRACTION_MODE, val);\r\n }\r\n }\r\n /**\r\n * Which intermediate shading term to display instead of the final colour.\r\n * Defaults to `none`. See {@link WaterDebugOutput}.\r\n */\r\n get debugOutput(): WaterDebugOutput {\r\n return this.featureUsed<WaterDebugOutput>(WaterMaterial.FEATURE_DEBUG_OUTPUT) ?? 'none';\r\n }\r\n set debugOutput(val: WaterDebugOutput) {\r\n if (val !== this.debugOutput) {\r\n this.useFeature(WaterMaterial.FEATURE_DEBUG_OUTPUT, val);\r\n }\r\n }\r\n /**\r\n * Whether the surface reads as unbounded, reaching the horizon rather than\r\n * ending at {@link region}. Off by default.\r\n *\r\n * The region test is not emitted at all, so the surface has no edge, and the\r\n * clipmap's outermost ring becomes a horizon skirt that survives clipping past\r\n * the camera's far plane. Use it for an ocean, not for a pond or a pool.\r\n */\r\n get infinite(): boolean {\r\n return this.featureUsed<boolean>(WaterMaterial.FEATURE_INFINITE) ?? false;\r\n }\r\n set infinite(val: boolean) {\r\n if (!!val !== this.infinite) {\r\n this.useFeature(WaterMaterial.FEATURE_INFINITE, !!val);\r\n }\r\n }\r\n /** Absorption coefficient sigma_a in 1/m, per RGB channel. */\r\n get absorption() {\r\n return this._absorption;\r\n }\r\n set absorption(val: Vector3) {\r\n if (!val.equalsTo(this._absorption)) {\r\n this._absorption.set(val);\r\n this._updateMediumCoefficients();\r\n this.uniformChanged();\r\n }\r\n }\r\n /** Scale for the absorption coefficient. */\r\n get absorptionScale() {\r\n return this._absorptionScale;\r\n }\r\n set absorptionScale(val: number) {\r\n if (val !== this._absorptionScale) {\r\n this._absorptionScale = val;\r\n this._updateMediumCoefficients();\r\n this.uniformChanged();\r\n }\r\n }\r\n /** Scattering coefficient sigma_s in 1/m, per RGB channel. */\r\n get scattering() {\r\n return this._scattering;\r\n }\r\n set scattering(val: Vector3) {\r\n if (!val.equalsTo(this._scattering)) {\r\n this._scattering.set(val);\r\n this._updateMediumCoefficients();\r\n this.uniformChanged();\r\n }\r\n }\r\n /** Scale for the scattering coefficient. */\r\n get scatteringScale() {\r\n return this._scatteringScale;\r\n }\r\n set scatteringScale(val: number) {\r\n if (val !== this._scatteringScale) {\r\n this._scatteringScale = val;\r\n this._updateMediumCoefficients();\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Extinction coefficient sigma_t = sigma_a + sigma_s in 1/m.\r\n *\r\n * Read by the caustics pass so the light attenuated along the refracted path\r\n * uses the same medium as the surface shading. Do not mutate the result.\r\n */\r\n get extinction() {\r\n return this._extinction;\r\n }\r\n /** Single-scattering albedo sigma_s / sigma_t. Do not mutate the result. */\r\n get scatterAlbedo() {\r\n return this._scatterAlbedo;\r\n }\r\n /**\r\n * Whether a camera inside this body of water sees the water from the inside:\r\n * the medium applied to the whole scene, the sky replaced by water, and the\r\n * surface read from below.\r\n *\r\n * The medium coefficients are the ones the surface already uses\r\n * ({@link WaterMaterial.absorption}, {@link WaterMaterial.scattering} and\r\n * their scales), so the volume and the surface never disagree.\r\n */\r\n get underwaterEnabled() {\r\n return this._underwaterEnabled;\r\n }\r\n set underwaterEnabled(val: boolean) {\r\n this._underwaterEnabled = !!val;\r\n }\r\n /**\r\n * Scale on the downwelling sky radiance that lights the water column from\r\n * inside, 1 for the value the sky implies.\r\n *\r\n * This is what the water fades to in the distance, so it is also what decides\r\n * how bright the underwater \"fog\" reads.\r\n */\r\n get underwaterAmbientIntensity() {\r\n return this._underwaterAmbientIntensity;\r\n }\r\n set underwaterAmbientIntensity(val: number) {\r\n this._underwaterAmbientIntensity = Math.max(0, val);\r\n }\r\n /**\r\n * Whether shafts of sunlight are marched through the water column.\r\n *\r\n * Reads the caustic map as the surface's transmittance, so the shafts carry\r\n * the same focusing pattern that lands on the sea bed. Switches itself off\r\n * wherever the caustic map is unavailable - WebGL1, no shadow-casting\r\n * directional light, or a sun too close to the horizon.\r\n */\r\n get underwaterGodRays() {\r\n return this._underwaterGodRays;\r\n }\r\n set underwaterGodRays(val: boolean) {\r\n this._underwaterGodRays = !!val;\r\n }\r\n /** Strength of the light shafts, 1 for the value the medium implies. */\r\n get underwaterGodRayIntensity() {\r\n return this._underwaterGodRayIntensity;\r\n }\r\n set underwaterGodRayIntensity(val: number) {\r\n this._underwaterGodRayIntensity = Math.max(0, val);\r\n }\r\n /**\r\n * Samples taken along each view ray for the light shafts.\r\n *\r\n * The march is dithered, so a low count reads as noise rather than as banding;\r\n * below about 8 the noise stops resolving into shafts at all.\r\n */\r\n get underwaterGodRaySteps() {\r\n return this._underwaterGodRaySteps;\r\n }\r\n set underwaterGodRaySteps(val: number) {\r\n this._underwaterGodRaySteps = Math.max(1, Math.floor(val));\r\n }\r\n /**\r\n * Whether geometry standing in the water breaks the light shafts.\r\n *\r\n * Off by default. The shafts are built from the caustic map, which knows what\r\n * the *surface* did to the sunlight and nothing about what is under it, so\r\n * without this a shaft runs straight through a piling or a hull. Turning it on\r\n * samples the sun's shadow map once per march step, which roughly doubles what\r\n * the shafts cost; the sea bed's own shadows are unaffected either way, since\r\n * those come from the ordinary lighting path.\r\n *\r\n * Needs the caustic light to be casting shadows, which it already must be for\r\n * the caustics themselves to exist.\r\n */\r\n get underwaterGodRayShadow() {\r\n return this._underwaterGodRayShadow;\r\n }\r\n set underwaterGodRayShadow(val: boolean) {\r\n this._underwaterGodRayShadow = !!val;\r\n }\r\n /**\r\n * Half-width in meters of the dead band around the surface the submerged test\r\n * uses, so a camera sitting exactly at water level does not flip state every\r\n * frame. The test is against the rest plane, not the displaced surface.\r\n */\r\n get underwaterHysteresis() {\r\n return this._underwaterHysteresis;\r\n }\r\n set underwaterHysteresis(val: number) {\r\n this._underwaterHysteresis = Math.max(0, val);\r\n }\r\n /**\r\n * Whether this water projects caustics onto the geometry below it.\r\n *\r\n * Requires a shadow-casting directional light and a non-WebGL1 device; the\r\n * caustics pass disables itself when either is missing.\r\n */\r\n get causticsEnabled() {\r\n return this._causticsEnabled;\r\n }\r\n set causticsEnabled(val: boolean) {\r\n this._causticsEnabled = !!val;\r\n }\r\n /** Strength of the caustic contrast. 0 leaves the light unmodulated. */\r\n get causticsIntensity() {\r\n return this._causticsIntensity;\r\n }\r\n set causticsIntensity(val: number) {\r\n this._causticsIntensity = val;\r\n }\r\n /**\r\n * Depth in meters below the surface where the caustics are in focus.\r\n *\r\n * Receivers away from this depth are progressively defocused rather than\r\n * displaced, so set it near the depth of the sea bed that should show the\r\n * sharpest pattern.\r\n */\r\n get causticsDepth() {\r\n return this._causticsDepth;\r\n }\r\n set causticsDepth(val: number) {\r\n this._causticsDepth = Math.max(0.01, val);\r\n }\r\n /**\r\n * Furthest distance in meters from the camera the caustic map reaches.\r\n *\r\n * A cap rather than a fixed extent: the map is fitted to the part of the water\r\n * within this distance. Raise it to light more of the scene, at the cost of\r\n * resolution wherever the water is large enough to fill it.\r\n */\r\n get causticsRange() {\r\n return this._causticsRange;\r\n }\r\n set causticsRange(val: number) {\r\n this._causticsRange = Math.max(1, val);\r\n }\r\n /**\r\n * Width in meters of the band the pattern fades out over at the edge of the\r\n * map, or 0 to derive it from {@link causticsRange}.\r\n *\r\n * Too narrow a band makes the map boundary read as a hard line across the sea\r\n * bed. Auto scales with the range but puts a floor under it in meters. Capped\r\n * at 90% of the range, so a core of the map always survives.\r\n */\r\n get causticsFadeDistance() {\r\n return this._causticsFadeDistance;\r\n }\r\n set causticsFadeDistance(val: number) {\r\n this._causticsFadeDistance = Math.max(0, val);\r\n }\r\n /**\r\n * Whether photons land on the scene instead of on a plane at\r\n * {@link causticsDepth}.\r\n *\r\n * On by default. The plane displaces the pattern sideways on any receiver not\r\n * at that depth, which is badly wrong under a low sun and on a sea bed with\r\n * relief. Resolving the real depth reuses the sun's shadow cascade, so it\r\n * costs no extra geometry pass, and falls back to the plane wherever that\r\n * cascade has nothing to say.\r\n *\r\n * {@link causticsDepth} still sets where the iteration starts and what the\r\n * defocus is measured against.\r\n */\r\n get causticsSceneDepth() {\r\n return this._causticsSceneDepth;\r\n }\r\n set causticsSceneDepth(val: boolean) {\r\n this._causticsSceneDepth = !!val;\r\n }\r\n /**\r\n * How strongly caustic map texels are concentrated near the camera, 0 to\r\n * spread them evenly.\r\n *\r\n * Texel density is `1 + causticsWarp` times uniform at the centre and\r\n * `1 / (1 + causticsWarp)` times it at the border. Raise it when a\r\n * {@link causticsRange} large enough to light the scene is too coarse to\r\n * resolve a caustic cell.\r\n *\r\n * Ignored while the map already fits the water within range, which is the case\r\n * a bounded pool inside {@link causticsRange} always lands in.\r\n */\r\n get causticsWarp() {\r\n return this._causticsWarp;\r\n }\r\n set causticsWarp(val: number) {\r\n this._causticsWarp = Math.max(0, Math.min(8, val));\r\n }\r\n /** How fast the caustic contrast falls off per meter away from {@link causticsDepth}. */\r\n get causticsDefocus() {\r\n return this._causticsDefocus;\r\n }\r\n set causticsDefocus(val: number) {\r\n this._causticsDefocus = Math.max(0, val);\r\n }\r\n /** Edge length of the square caustic map. */\r\n get causticsResolution() {\r\n return this._causticsResolution;\r\n }\r\n set causticsResolution(val: number) {\r\n this._causticsResolution = Math.max(16, Math.min(2048, val | 0));\r\n }\r\n /**\r\n * Edge length of the photon grid, or 0 to size it from the map.\r\n *\r\n * Auto solves for photons per map texel, which is the density that governs\r\n * quality; a fixed grid over-spends on a small pool and under-spends on open\r\n * water. Set a value to pin the grid explicitly; the cost is the square of it.\r\n */\r\n get causticsPhotonResolution() {\r\n return this._causticsPhotonResolution;\r\n }\r\n set causticsPhotonResolution(val: number) {\r\n const n = val | 0;\r\n this._causticsPhotonResolution = n <= 0 ? 0 : Math.max(16, Math.min(4096, n));\r\n }\r\n /**\r\n * Number of 2x2 blur iterations applied to the accumulated map. Rounded up to\r\n * an even count.\r\n */\r\n get causticsBlurPasses() {\r\n return this._causticsBlurPasses;\r\n }\r\n set causticsBlurPasses(val: number) {\r\n const clamped = Math.max(0, Math.min(4, val | 0));\r\n this._causticsBlurPasses = clamped + (clamped & 1);\r\n }\r\n /**\r\n * Weight the previous frame's caustic map keeps in the current one, 0 to\r\n * disable.\r\n *\r\n * Averages away the scintillation a moving photon lattice produces, in effect\r\n * multiplying the photon count for free. The resolve clamps the reprojected\r\n * value to its own 3x3 neighbourhood, so still regions accumulate while moving\r\n * ones fall back to the current frame. Raising this past the default buys\r\n * diminishing stability and starts to smear the animation.\r\n */\r\n get causticsTemporalStrength() {\r\n return this._causticsTemporalStrength;\r\n }\r\n set causticsTemporalStrength(val: number) {\r\n this._causticsTemporalStrength = Math.max(0, Math.min(0.95, val));\r\n }\r\n /**\r\n * Strength of the sunlight scattered forward through a wave crest, 0 to\r\n * disable.\r\n *\r\n * This is the term that makes a backlit crest glow. Authored rather than\r\n * derived; the medium's albedo supplies the colour, so raising this brightens\r\n * the glow without shifting its hue.\r\n */\r\n get subsurfaceIntensity() {\r\n return this._subsurfaceIntensity;\r\n }\r\n set subsurfaceIntensity(val: number) {\r\n if (val !== this._subsurfaceIntensity) {\r\n this._subsurfaceIntensity = Math.max(0, val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * How sharply surface tilt gates the subsurface glow.\r\n *\r\n * The glow is scaled by `(1 - normal.y) * subsurfaceSteepness`, clamped to 1,\r\n * so this is the reciprocal of the tilt at which it saturates. Unitless, and\r\n * larger than it looks like it should be: an ocean surface is nearly flat in\r\n * these terms.\r\n */\r\n get subsurfaceSteepness() {\r\n return this._subsurfaceSteepness;\r\n }\r\n set subsurfaceSteepness(val: number) {\r\n if (val !== this._subsurfaceSteepness) {\r\n this._subsurfaceSteepness = Math.max(0, val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Strength of the sunlight scattered out of the water column towards the eye,\r\n * 1 for the value the medium coefficients imply. 0 disables the term.\r\n *\r\n * This is what gives the water body a direction-dependent colour: a shadow\r\n * falling on the water darkens the water itself, and a low sun tints the\r\n * column. Unlike {@link subsurfaceIntensity} this is not an authored\r\n * magnitude - 1 is the physical answer and anything else is a deliberate\r\n * exaggeration.\r\n */\r\n get sunScatteringIntensity() {\r\n return this._sunScatteringIntensity;\r\n }\r\n set sunScatteringIntensity(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._sunScatteringIntensity) {\r\n this._sunScatteringIntensity = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Depth in meters the cheap refraction mode assumes the water is, in\r\n * {@link refractionMode} `offset`. Ignored by `march`.\r\n *\r\n * Sets how strong the distortion looks: raise it for water that should read as\r\n * deep, lower it for a shallow film. A constant rather than the measured scene\r\n * distance, which would double every submerged object across its silhouette;\r\n * the price is that shallow and deep water distort equally.\r\n */\r\n get cheapRefractionDepth() {\r\n return this._cheapRefractionDepth;\r\n }\r\n set cheapRefractionDepth(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._cheapRefractionDepth) {\r\n this._cheapRefractionDepth = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Scale on how much the medium blurs what is seen through it. 0 keeps the\r\n * background perfectly sharp at any depth, 1 is what the medium implies.\r\n *\r\n * The width is derived from the scattering coefficient and the path length, so\r\n * this is a stylisation knob rather than the magnitude itself. Costs nothing -\r\n * it selects a mip of a chain that is generated regardless.\r\n */\r\n get refractionBlur() {\r\n return this._refractionBlur;\r\n }\r\n set refractionBlur(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._refractionBlur) {\r\n this._refractionBlur = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Mean cosine of a single scattering event, in `[0, 0.95]`.\r\n *\r\n * 0 scatters equally in all directions; higher values push light forward, so\r\n * the water brightens when looking towards the sun through it and darkens\r\n * when looking away. The term blends towards isotropic as the column gets\r\n * optically thick, so the visible anisotropy is always less than this number\r\n * alone suggests.\r\n */\r\n get scatterAnisotropy() {\r\n return this._scatterAnisotropy;\r\n }\r\n set scatterAnisotropy(val: number) {\r\n const clamped = Math.max(0, Math.min(0.95, val));\r\n if (clamped !== this._scatterAnisotropy) {\r\n this._scatterAnisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * How much of a folded texel reads as foam, 0 to disable. Scales the wave\r\n * generator's fold measure into a coverage fraction.\r\n */\r\n get foamAmount() {\r\n return this._foamAmount;\r\n }\r\n set foamAmount(val: number) {\r\n if (val !== this._foamAmount) {\r\n this._foamAmount = Math.max(0, val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Falloff applied to foam coverage before it is scaled. Above 1 only a crest\r\n * that has genuinely broken shows any foam, which keeps a windy sea from\r\n * turning uniformly white.\r\n */\r\n get foamFalloff() {\r\n return this._foamFalloff;\r\n }\r\n set foamFalloff(val: number) {\r\n if (val !== this._foamFalloff) {\r\n this._foamFalloff = Math.max(0.01, val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /** Diffuse albedo of the foam. */\r\n get foamColor() {\r\n return this._foamColor;\r\n }\r\n set foamColor(val: Vector3) {\r\n if (!val.equalsTo(this._foamColor)) {\r\n this._foamColor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Coverage of the foam that collects where the water meets a surface, 0 to disable.\r\n *\r\n * A second foam source independent of the crest foam, keyed on how far the\r\n * surface is from the nearest solid around it - the depth of water over a bed,\r\n * the horizontal distance to a hull or a piling. One band covers both the\r\n * shoreline and the contact line around anything standing in the water.\r\n *\r\n * Estimated in screen space, with the limits that implies: geometry that is\r\n * off screen, hidden behind something else, or thinner than a few pixels\r\n * produces no foam. Requires the Hi-Z pyramid, so it is unavailable on WebGL1.\r\n *\r\n * Drawn with {@link foamColor} and folded into the same coverage the crest foam\r\n * feeds, so it suppresses the specular lobe and the water body underneath it\r\n * exactly as that one does.\r\n */\r\n get shoreFoamAmount() {\r\n return this._shoreFoamAmount;\r\n }\r\n set shoreFoamAmount(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._shoreFoamAmount) {\r\n // A compile-time feature, so crossing zero rebuilds the shader while\r\n // changing the value either side of it does not. Forced off on WebGL1,\r\n // which has no Hi-Z pyramid for the query to read.\r\n const wasEnabled = this._shoreFoamAmount > 0;\r\n this._shoreFoamAmount = clamped;\r\n if (wasEnabled !== clamped > 0) {\r\n this.useFeature(WaterMaterial.FEATURE_SHORE_FOAM, clamped > 0 && getDevice().type !== 'webgl');\r\n } else {\r\n this.uniformChanged();\r\n }\r\n }\r\n }\r\n /**\r\n * How far, in meters, the foam band reaches from the surface behind it.\r\n *\r\n * Over a bed this is a depth of water; against anything vertical it is a\r\n * horizontal distance, and the same value serves both. Coverage is solid\r\n * against the contact itself and fades to nothing by this distance, so it is\r\n * the outer edge of the band rather than its midpoint. What it means on screen\r\n * depends on the geometry: on a steep drop-off the band is a thin line however\r\n * large this is, and on a flat shelf a small value already covers a wide\r\n * stretch.\r\n */\r\n get shoreFoamDepth() {\r\n return this._shoreFoamDepth;\r\n }\r\n set shoreFoamDepth(val: number) {\r\n const clamped = Math.max(0.001, val);\r\n if (clamped !== this._shoreFoamDepth) {\r\n this._shoreFoamDepth = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Falloff applied across the band before it is scaled. Above 1 the coverage is\r\n * pushed towards the near end, keeping the outer edge thin and broken instead\r\n * of washing evenly over the whole range.\r\n */\r\n get shoreFoamFalloff() {\r\n return this._shoreFoamFalloff;\r\n }\r\n set shoreFoamFalloff(val: number) {\r\n const clamped = Math.max(0.01, val);\r\n if (clamped !== this._shoreFoamFalloff) {\r\n this._shoreFoamFalloff = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Size of the clumps the band's edge breaks into, as cycles across the band.\r\n *\r\n * Relative to {@link shoreFoamDepth} rather than an absolute frequency, so one\r\n * setting serves both a shoreline metres across and a collar around a piling,\r\n * and widening the band widens its clumps with it.\r\n *\r\n * Evaluated in world space, so the pattern stays put as the camera moves.\r\n */\r\n get shoreFoamScale() {\r\n return this._shoreFoamScale;\r\n }\r\n set shoreFoamScale(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._shoreFoamScale) {\r\n this._shoreFoamScale = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * How far the band's edge runs back and forth, as a fraction of\r\n * {@link shoreFoamDepth}.\r\n *\r\n * This is what makes the band read as surf rather than as a painted rim. 0\r\n * leaves a static band. Above 1 the band closes completely at the bottom of\r\n * the cycle, which looks like the foam blinking out rather than retreating.\r\n */\r\n get shoreFoamWashAmount() {\r\n return this._shoreFoamWashAmount;\r\n }\r\n set shoreFoamWashAmount(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._shoreFoamWashAmount) {\r\n this._shoreFoamWashAmount = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /** Run-up cycles per second. Swell rather than wind waves, so well under 1. */\r\n get shoreFoamWashSpeed() {\r\n return this._shoreFoamWashSpeed;\r\n }\r\n set shoreFoamWashSpeed(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._shoreFoamWashSpeed) {\r\n this._shoreFoamWashSpeed = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Spatial frequency of the run-up phase, in cycles per meter.\r\n *\r\n * Decorrelates the wash along the shore: at 0 the entire waterline advances\r\n * and retreats in lockstep, which reads as the water level itself rising and\r\n * falling; a cycle every few tens of meters breaks a long shoreline into\r\n * sections that run up out of step with one another.\r\n */\r\n get shoreFoamWashScale() {\r\n return this._shoreFoamWashScale;\r\n }\r\n set shoreFoamWashScale(val: number) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._shoreFoamWashScale) {\r\n this._shoreFoamWashScale = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /** Whether the shoreline foam contributes at all. @internal */\r\n private get _shoreFoamEnabled() {\r\n return this.featureUsed<boolean>(WaterMaterial.FEATURE_SHORE_FOAM) ?? false;\r\n }\r\n /**\r\n * Whether this shader build can run the band: the feature is on *and* the\r\n * pyramid it queries is bound for this pass.\r\n *\r\n * A pass outside the main graph can shade water with no Hi-Z pass having run\r\n * for it, and compiling a fetch against an unbound texture is a build failure.\r\n * @internal\r\n */\r\n private _shoreFoamAvailable(scope: PBInsideFunctionScope | PBFunctionScope) {\r\n return this._shoreFoamEnabled && !!ShaderHelper.getHiZDepthTexture(scope as PBInsideFunctionScope);\r\n }\r\n /** @internal */\r\n private _updateMediumCoefficients() {\r\n this._extinction.setXYZ(\r\n this._absorption.x * this._absorptionScale + this._scattering.x * this._scatteringScale,\r\n this._absorption.y * this._absorptionScale + this._scattering.y * this._scatteringScale,\r\n this._absorption.z * this._absorptionScale + this._scattering.z * this._scatteringScale\r\n );\r\n // A channel with no interaction at all transmits fully and scatters nothing;\r\n // its albedo is arbitrary, so pick 0 rather than divide.\r\n this._scatterAlbedo.setXYZ(\r\n this._extinction.x > 0 ? (this._scattering.x * this._scatteringScale) / this._extinction.x : 0,\r\n this._extinction.y > 0 ? (this._scattering.y * this._scatteringScale) / this._extinction.y : 0,\r\n this._extinction.z > 0 ? (this._scattering.z * this._scatteringScale) / this._extinction.z : 0\r\n );\r\n }\r\n get depthMulti() {\r\n return this._depthMulti;\r\n }\r\n set depthMulti(val) {\r\n if (val !== this._depthMulti) {\r\n this._depthMulti = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Artistic scale on the refracted view offset. 1 is physical, 0 disables it.\r\n *\r\n * The offset is already derived from Snell's law and accounts for the\r\n * incidence angle, the receiver depth and the perspective foreshortening, so\r\n * this exists only to dial the result back for a stylised look. Values above 1\r\n * exaggerate; the surface stays continuous, but the sample can wander far\r\n * enough that the medium tint stops matching what is visible through it.\r\n */\r\n get refractionScale() {\r\n return this._refractionScale;\r\n }\r\n set refractionScale(val) {\r\n const clamped = Math.max(0, val);\r\n if (clamped !== this._refractionScale) {\r\n this._refractionScale = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Scale on the Fresnel reflectance, 1 for the physical value.\r\n *\r\n * Below 1 the surface reflects less than it should and shows more of what is\r\n * beneath it - useful when a physically correct grazing reflection buries a\r\n * sea bed the shot is about. The F0 floor is scaled with it, so 0 gives a\r\n * surface with no specular response at all.\r\n */\r\n get reflectionStrength() {\r\n return this._reflectionStrength;\r\n }\r\n set reflectionStrength(val) {\r\n const clamped = Math.max(0, Math.min(1, val));\r\n if (clamped !== this._reflectionStrength) {\r\n this._reflectionStrength = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n needSceneColor() {\r\n return true;\r\n }\r\n needSceneDepth() {\r\n return true;\r\n }\r\n /**\r\n * The shoreline foam reads the Hi-Z pyramid's nearest-depth channel. WebGL1\r\n * has no pyramid at all.\r\n */\r\n needHiZNearest() {\r\n return this._shoreFoamEnabled && getDevice().type !== 'webgl';\r\n }\r\n protected _createHash() {\r\n return `${super._createHash()}:${this.waveGenerator?.getHash() ?? ''}`;\r\n }\r\n setClipmapInfo(rotation: number, scale: number, offsetX: number, offsetY: number) {\r\n this._clipmapInfo.setXYZW(rotation, scale, offsetX, offsetY);\r\n this.uniformChanged();\r\n }\r\n setClipmapGridInfo(gridScale: number, gridOffsetX: number, gridOffsetY: number) {\r\n if (\r\n this._clipmapGridInfo.x !== gridScale ||\r\n this._clipmapGridInfo.y !== gridOffsetX ||\r\n this._clipmapGridInfo.z !== gridOffsetY\r\n ) {\r\n this._clipmapGridInfo.setXYZW(gridScale, gridOffsetX, gridOffsetY, 0);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * How far from the camera the horizon skirt's outer edge is placed, in world\r\n * units. Only read while {@link infinite} is on.\r\n */\r\n setSkirtDistance(distance: number) {\r\n if (this._skirtDistance !== distance) {\r\n this._skirtDistance = distance;\r\n this.uniformChanged();\r\n }\r\n }\r\n supportInstancing() {\r\n return false;\r\n }\r\n supportLighting() {\r\n return true;\r\n }\r\n /**\r\n * {@inheritDoc IMixinLight.receivesWaterCaustics}\r\n *\r\n * Always false. Caustics belong on whatever the water is above: the submersion\r\n * test compares a fragment's height against the surface height sampled on its\r\n * sun ray, so unless the sun is overhead every water fragment has some other\r\n * part of the same surface up-sun of it and reads as submerged wherever that\r\n * part rides a crest.\r\n */\r\n receivesWaterCaustics(): boolean {\r\n return false;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n this.waveGenerator?.setupUniforms(scope, 2);\r\n scope.$inputs.position = pb.vec3().attrib('position');\r\n scope.$inputs.clipmapInfo = pb.vec4().attrib('texCoord0');\r\n scope.clipmapGridInfo = pb.vec4().uniform(2);\r\n if (this.infinite) {\r\n scope.skirtDistance = pb.float().uniform(2);\r\n }\r\n\r\n scope.$l.s = pb.sin(scope.$inputs.clipmapInfo.x);\r\n scope.$l.c = pb.cos(scope.$inputs.clipmapInfo.x);\r\n scope.$l.scale2 = pb.mul(scope.$inputs.clipmapInfo.y, scope.clipmapGridInfo.x);\r\n scope.$l.clipmapMatrix = pb.mat4(\r\n pb.mul(scope.c, scope.scale2),\r\n pb.mul(scope.s, scope.scale2),\r\n 0,\r\n 0,\r\n pb.neg(pb.mul(scope.s, scope.scale2)),\r\n pb.mul(scope.c, scope.scale2),\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1,\r\n 0,\r\n pb.sub(pb.mul(scope.$inputs.clipmapInfo.z, scope.clipmapGridInfo.x), scope.clipmapGridInfo.y),\r\n pb.sub(pb.mul(scope.$inputs.clipmapInfo.w, scope.clipmapGridInfo.x), scope.clipmapGridInfo.z),\r\n 0,\r\n 1\r\n );\r\n\r\n scope.$l.clipmapPos = pb.mul(scope.clipmapMatrix, pb.vec4(scope.$inputs.position, 1)).xy;\r\n //scope.$l.level = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(0, 0, 0, 1)).y;\r\n scope.clipmapWorldPos = pb.mul(\r\n ShaderHelper.getWorldMatrix(scope),\r\n pb.vec4(scope.clipmapPos.x, 0, scope.clipmapPos.y, 1)\r\n ).xyz; // pb.vec3(scope.clipmapPos.x, scope.level, scope.clipmapPos.y);\r\n scope.worldNormal = pb.vec3(0, 1, 0);\r\n scope.worldPos = scope.clipmapWorldPos;\r\n if (this.infinite) {\r\n const that = this;\r\n // The clipmap meshes all leave position.z at 0; the skirt ring sets it to\r\n // 1 on its outer edge. Its inner edge is welded to the outermost tiles and\r\n // is displaced with them, so the join stays closed.\r\n scope.$l.skirt = pb.step(0.5, scope.$inputs.position.z);\r\n scope\r\n .$if(pb.greaterThan(scope.skirt, 0), function () {\r\n // Radially outwards from the camera rather than from the clipmap\r\n // origin: the ring has to read as a horizon from where it is being\r\n // looked at, and the clipmap is snapped to a grid the camera wanders\r\n // within.\r\n this.$l.camXZ = ShaderHelper.getCameraPosition(this).xz;\r\n this.$l.outDir = pb.normalize(pb.sub(this.clipmapWorldPos.xz, this.camXZ));\r\n this.$l.outXZ = pb.add(this.camXZ, pb.mul(this.outDir, this.skirtDistance));\r\n // Flat, at the still-water level. A displaced vertex out here would be\r\n // several kilometres from its neighbours, so any wave it sampled would\r\n // read as a jagged silhouette rather than a swell.\r\n this.worldPos = pb.vec3(this.outXZ.x, this.clipmapWorldPos.y, this.outXZ.y);\r\n })\r\n .$else(function () {\r\n that.waveGenerator?.calcVertexPositionAndNormal(\r\n this,\r\n this.clipmapWorldPos,\r\n this.worldPos,\r\n this.worldNormal\r\n );\r\n });\r\n scope.$outputs.skirt = scope.skirt;\r\n } else {\r\n this.waveGenerator?.calcVertexPositionAndNormal(\r\n scope,\r\n scope.clipmapWorldPos,\r\n scope.worldPos,\r\n scope.worldNormal\r\n );\r\n }\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.clipmapPos = scope.clipmapWorldPos;\r\n scope.$outputs.worldNormal = scope.worldNormal;\r\n if (this.infinite) {\r\n // Pulled in along the view ray rather than depth-clamped.\r\n //\r\n // The surface has to reach past the far plane, but the depth buffer cannot\r\n // encode anything past it. A perspective projection is invariant under\r\n // scaling about the eye, so moving a vertex along its own view ray leaves\r\n // its screen position untouched while bringing its depth back inside the\r\n // frustum - every vertex stays unclipped, so there is no seam to tear.\r\n //\r\n // Shading keeps the true world position, so only the written depth is\r\n // affected, and only past the far plane.\r\n scope.$l.camPos = ShaderHelper.getCameraPosition(scope).xyz;\r\n scope.$l.viewVec = pb.sub(scope.$outputs.worldPos, scope.camPos);\r\n scope.$l.viewDist = pb.max(pb.length(scope.viewVec), 1e-6);\r\n // Just inside the far plane, so the vertex is never the one the hardware\r\n // decides to clip and never lands on the cleared depth value.\r\n scope.$l.maxDist = pb.mul(ShaderHelper.getCameraParams(scope).y, INFINITE_DEPTH_PULLIN);\r\n scope.$l.pullIn = pb.min(pb.div(scope.maxDist, scope.viewDist), 1);\r\n scope.$l.projPos = pb.add(scope.camPos, pb.mul(scope.viewVec, scope.pullIn));\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.projPos, 1))\r\n );\r\n } else {\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1))\r\n );\r\n }\r\n ShaderHelper.resolveMotionVector(scope, scope.$outputs.worldPos, scope.$outputs.worldPos);\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n this.waveGenerator?.setupUniforms(scope, 2);\r\n if (!this.infinite) {\r\n scope.region = pb.vec4().uniform(2);\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.refractionScale = pb.float().uniform(2);\r\n if (this.refractionMode === 'offset') {\r\n // Only the cheap path has a fixed depth scale to step along; the march\r\n // derives its own from the scene.\r\n scope.cheapRefractionDepth = pb.float().uniform(2);\r\n }\r\n scope.reflectionStrength = pb.float().uniform(2);\r\n scope.ssrParams = pb.vec4().uniform(2);\r\n // (intensity, 1 / full-scatter crest height, 0, 0)\r\n scope.subsurfaceParams = pb.vec4().uniform(2);\r\n // (coverage scale, coverage falloff, 0, 0)\r\n scope.foamShadingParams = pb.vec4().uniform(2);\r\n scope.foamColor = pb.vec3().uniform(2);\r\n if (this._shoreFoamAvailable(scope)) {\r\n // (coverage scale, band depth in m, coverage falloff, pattern cycles/m)\r\n scope.shoreFoamParams = pb.vec4().uniform(2);\r\n // (run-up amount, run-up cycles/s, run-up cycles/m, query radius in m)\r\n scope.shoreFoamWashParams = pb.vec4().uniform(2);\r\n }\r\n // (intensity, anisotropy, 0, 0)\r\n scope.sunScatterParams = pb.vec4().uniform(2);\r\n // Mip widths per meter of path the medium's scattering contributes to the\r\n // refraction blur. Resolved on the CPU from the per-channel scattering\r\n // coefficient, since the blur is one LOD for all three.\r\n scope.refractBlurDensity = pb.float().uniform(2);\r\n // Declared in both medium modes: the ramp only replaces the depth-driven\r\n // absorption and scattering, while the subsurface and sun-scattering terms\r\n // need the medium's hue and thickness regardless.\r\n scope.mediumAlbedo = pb.vec3().uniform(2);\r\n scope.mediumExtinction = pb.vec3().uniform(2);\r\n if (this.mediumMode === 'ramp') {\r\n scope.depthMulti = pb.float().uniform(2);\r\n scope.scatterRampTex = pb.tex2D().uniform(2);\r\n scope.absorptionRampTex = pb.tex2D().uniform(2);\r\n }\r\n }\r\n // An unbounded surface has no edge to clip against.\r\n if (!this.infinite) {\r\n scope.$l.discardable = pb.or(\r\n pb.any(pb.lessThan(scope.$inputs.worldPos.xz, scope.region.xy)),\r\n pb.any(pb.greaterThan(scope.$inputs.worldPos.xz, scope.region.zw))\r\n );\r\n scope.$if(scope.discardable, function () {\r\n pb.discard();\r\n });\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.$l.normal = this.waveGenerator\r\n ? this.waveGenerator.calcFragmentNormalAndFoam(\r\n scope,\r\n scope.$inputs.clipmapPos.xz,\r\n scope.$inputs.worldNormal\r\n )\r\n : pb.vec4(scope.$inputs.worldNormal, 0);\r\n if (this.infinite) {\r\n // Flat and foamless across the horizon band. The skirt's world position\r\n // was never displaced, so evaluating waves from it would paint detail\r\n // the geometry does not have - and at kilometres per pixel that detail\r\n // is under-sampled into crawling speckle. The screen-space fog pass is\r\n // what should be visible here.\r\n scope.normal = pb.mix(scope.normal, pb.vec4(0, 1, 0, 0), scope.$inputs.skirt);\r\n }\r\n scope.$l.outColor = pb.vec4(\r\n this.waterShading(scope, scope.$inputs.worldPos, scope.normal.xyz, scope.normal.w),\r\n 1\r\n );\r\n if (\r\n this.drawContext.materialFlags &\r\n (MaterialVaryingFlags.SCENE_STORE_ROUGHNESS | MaterialVaryingFlags.SCENE_STORE_NORMAL)\r\n ) {\r\n // The real roughness, not a constant 1, so SSR on another surface does\r\n // not treat a near-mirror sea as fully diffuse.\r\n scope.$l.outRoughness = pb.vec4(pb.vec3(this.waterRoughness(scope, scope.$inputs.worldPos)), 0);\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.outColor,\r\n scope.outRoughness,\r\n scope.outColor\r\n );\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.outColor);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n /**\r\n * Specular roughness of the surface at a world position.\r\n *\r\n * Distance fades the wave normals flat, and this hands that lost slope to the\r\n * specular lobe instead of dropping it. Shared with the scene roughness buffer\r\n * so a surface reflecting the water sees the same value.\r\n */\r\n waterRoughness(scope: PBInsideFunctionScope, worldPos: PBShaderExp) {\r\n const pb = scope.$builder;\r\n pb.func('waterRoughness', [pb.vec3('worldPos')], function () {\r\n this.$l.dist = pb.length(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this)));\r\n this.$l.normalScale = pb.clamp(pb.div(100, this.dist), 0, 1);\r\n this.$return(pb.mix(WATER_DISTANT_ROUGHNESS, WATER_BASE_ROUGHNESS, this.normalScale));\r\n });\r\n return scope.waterRoughness(worldPos) as PBShaderExp;\r\n }\r\n /**\r\n * Where to sample the scene behind the water, and how far the light travelled\r\n * through the medium to get there.\r\n *\r\n * Refracts the view ray by Snell's law, then marches that ray against the scene\r\n * depth: at each step it projects the current point back to the screen, reads\r\n * the depth there, and stops at the first point where the ray has passed into\r\n * the geometry that pixel shows. The incidence angle, the depth of the receiver\r\n * and the perspective foreshortening all fall out of that.\r\n *\r\n * Independent of the engine's depth convention: the projection only ever reads\r\n * `clip.xy / clip.w`, every depth comparison happens in view space, and\r\n * decoding the depth texture lives behind {@link ShaderHelper.sampleLinearDepth}.\r\n *\r\n * @param scope - Current shader scope\r\n * @param worldPos - Surface point being shaded\r\n * @param normal - Wave normal at that point, pointing up out of the water\r\n * @param eyeVecNorm - Normalized direction from the camera to the surface\r\n * @param screenUV - Screen UV of the surface point\r\n * @param surfaceViewZ - View-space z of the surface point\r\n * @param straightDepth01 - Normalized linear depth of the scene behind it\r\n * @param straightWorldPos - Unrefracted scene world position behind the surface\r\n * @param straightDist - Straight-line distance from the surface to that scene\r\n * @returns `vec3(uv, pathLength)` - where to sample, and the medium path in meters\r\n */\r\n waterRefraction(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n eyeVecNorm: PBShaderExp,\r\n screenUV: PBShaderExp,\r\n surfaceViewZ: PBShaderExp,\r\n straightDepth01: PBShaderExp,\r\n straightWorldPos: PBShaderExp,\r\n straightDist: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const march = this.refractionMode === 'march';\r\n // Screen UV of a world position, through the same matrix the surface itself\r\n // was rasterised with.\r\n //\r\n // Only ever used as a difference of two such UVs, which is what makes the\r\n // offset independent of the conventions baked into that matrix: the TAA\r\n // jitter and the clip-space Y orientation cancel between the two ends. The\r\n // 0.5/0.5 mapping is the inverse of ShaderHelper.samplePositionFromDepth's.\r\n pb.func('waterRefractProjectUV', [pb.vec3('worldPos')], function () {\r\n this.$l.h = pb.mul(ShaderHelper.getViewProjectionMatrix(this), pb.vec4(this.worldPos, 1));\r\n this.$return(pb.add(pb.mul(pb.div(this.h.xy, pb.max(this.h.w, 1e-6)), 0.5), pb.vec2(0.5)));\r\n });\r\n // Where to sample the scene colour for a refracted ray that ended at\r\n // `hitPos`, faded back to the straight-through sample at the screen border.\r\n pb.func(\r\n 'waterRefractUV',\r\n [pb.vec2('screenUV'), pb.vec2('uvBase'), pb.vec3('hitPos'), pb.float('scale')],\r\n function () {\r\n this.$l.uv = pb.add(\r\n this.screenUV,\r\n pb.mul(pb.sub(this.waterRefractProjectUV(this.hitPos), this.uvBase), this.scale)\r\n );\r\n // Off screen there is no scene colour to refract, and a clamped sample\r\n // would smear one border pixel along the whole edge of the water.\r\n this.$l.edge = pb.min(\r\n pb.min(this.uv.x, pb.sub(1, this.uv.x)),\r\n pb.min(this.uv.y, pb.sub(1, this.uv.y))\r\n );\r\n this.$return(pb.mix(this.screenUV, this.uv, pb.clamp(pb.div(this.edge, REFRACT_EDGE_FADE), 0, 1)));\r\n }\r\n );\r\n // One step of the refracted-ray march.\r\n //\r\n // Projects the point `t` meters along the refracted ray to the screen, reads\r\n // the depth there, and reports the signed gap between the ray and that pixel\r\n // along the view axis: positive means the ray is still in front of the scene,\r\n // negative that it has passed through it. The hit test itself belongs to the\r\n // march.\r\n //\r\n // Declared only in `march` mode: a dead function still forces the depth\r\n // texture and the projection matrices into the bind group.\r\n if (march) {\r\n pb.func(\r\n 'waterRefractStep',\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('refractDir'),\r\n pb.vec2('screenUV'),\r\n pb.vec2('uvBase'),\r\n pb.float('rayViewZ'),\r\n pb.float('cameraFar'),\r\n pb.float('t')\r\n ],\r\n function () {\r\n this.$l.uv = this.waterRefractUV(\r\n this.screenUV,\r\n this.uvBase,\r\n pb.add(this.worldPos, pb.mul(this.refractDir, this.t)),\r\n this.refractionScale\r\n );\r\n this.$l.linearDepth = ShaderHelper.sampleLinearDepth(\r\n this,\r\n ShaderHelper.getLinearDepthTexture(this),\r\n this.uv,\r\n 0\r\n );\r\n // View-space z of whatever that pixel shows. The comparison below is in\r\n // view space, which the depth convention does not touch.\r\n this.$l.sceneViewZ = pb.mul(pb.neg(this.linearDepth), this.cameraFar);\r\n // Ray depth minus scene depth. Sky sits at the far plane, so over empty\r\n // water the gap stays large and positive and the march simply runs on.\r\n this.$return(pb.vec3(this.uv, pb.sub(this.rayViewZ, this.sceneViewZ)));\r\n }\r\n );\r\n // March the refracted ray and take the first crossing with the depth buffer.\r\n //\r\n // A hit is a step that lands inside a thickness band around the surface -\r\n // the ray is neither clearly in front of the scene nor already out the far\r\n // side. That two-sided test is what lets something poking out of the water\r\n // fall through: its depth is *nearest* the camera, so the gap is negative\r\n // from the first step and never enters the band. Stopping at the *first*\r\n // hit keeps a submerged object solid; a later one belongs to whatever is\r\n // behind it.\r\n pb.func(\r\n 'waterRefractMarch',\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('refractDir'),\r\n pb.vec2('screenUV'),\r\n pb.vec2('uvBase'),\r\n pb.float('surfaceViewZ'),\r\n pb.float('refractStepZ'),\r\n pb.float('cameraFar'),\r\n pb.float('maxPath'),\r\n pb.float('basePath')\r\n ],\r\n function () {\r\n this.$l.step = pb.div(pb.sub(this.maxPath, 0.05), pb.float(REFRACT_MARCH_STEPS));\r\n this.$l.tPrev = pb.float(0.05);\r\n this.$l.gapPrev = pb.float(1);\r\n this.$l.hitUV = this.screenUV;\r\n this.$l.hitPath = this.basePath;\r\n this.$for(pb.float('i'), 0, REFRACT_MARCH_STEPS, function () {\r\n this.$l.t = pb.add(this.tPrev, this.step);\r\n this.$l.rayViewZ = pb.add(this.surfaceViewZ, pb.mul(this.refractStepZ, this.t));\r\n this.$l.s = this.waterRefractStep(\r\n this.worldPos,\r\n this.refractDir,\r\n this.screenUV,\r\n this.uvBase,\r\n this.rayViewZ,\r\n this.cameraFar,\r\n this.t\r\n );\r\n this.$l.gap = this.s.z;\r\n this.$if(\r\n pb.or(\r\n pb.lessThan(pb.abs(this.gap), REFRACT_MARCH_THICKNESS),\r\n pb.lessThan(pb.mul(this.gapPrev, this.gap), 0)\r\n ),\r\n function () {\r\n // Within the band, or the gap flipped sign this step: the ray is at\r\n // the surface. Interpolate down to the exact crossing so the sample\r\n // sits on the object instead of a step behind it.\r\n this.$l.k = pb.div(this.gapPrev, pb.sub(this.gapPrev, this.gap));\r\n this.hitUV = this.s.xy;\r\n this.hitPath = pb.mix(this.tPrev, this.t, this.k);\r\n this.$break();\r\n }\r\n ).$else(function () {\r\n this.tPrev = this.t;\r\n this.gapPrev = this.gap;\r\n });\r\n });\r\n // No hit on any step leaves the straight-through sample at the\r\n // straight-line path, which is what a ray over empty water should show.\r\n this.$return(pb.vec3(this.hitUV, this.hitPath));\r\n }\r\n );\r\n }\r\n pb.func(\r\n 'waterRefraction',\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.vec3('eyeVecNorm'),\r\n pb.vec2('screenUV'),\r\n pb.float('surfaceViewZ'),\r\n pb.float('straightDepth01'),\r\n pb.vec3('straightWorldPos'),\r\n pb.float('straightDist')\r\n ],\r\n function () {\r\n // Both faces are handled: looking down at the water the ray enters the\r\n // medium, looking up from inside it the ray leaves. The surface is drawn\r\n // with cullMode 'none' and the wave normal always points up, so the\r\n // normal is faced back towards the eye and the ratio picked to match.\r\n // Taken from `frontFacing`, since a flipped wave normal cannot tell an\r\n // underside from an eye below the surface.\r\n this.$l.underwater = pb.not(this.$builtins.frontFacing);\r\n this.$l.faceNormal = this.$choice(this.underwater, pb.neg(this.normal), this.normal);\r\n this.$l.eta = this.$choice(this.underwater, pb.float(WATER_TO_AIR_ETA), pb.float(AIR_TO_WATER_ETA));\r\n // The unrefracted hit: the view line through the surface to whatever is\r\n // behind it, which is what keeps the sample tracking the object rather\r\n // than wandering across a silhouette.\r\n this.$l.uvBase = this.waterRefractProjectUV(this.worldPos);\r\n // Sky behind the water (depth at the far plane) has no surface to refract\r\n // towards, so the unrefracted sample is the correct one.\r\n this.$if(pb.greaterThanEqual(this.straightDepth01, SCENE_SKY_DEPTH01), function () {\r\n this.$return(pb.vec3(this.screenUV, this.straightDist));\r\n });\r\n this.$l.waterCrossDir = pb.normalize(pb.sub(this.straightWorldPos, this.worldPos));\r\n // Refract the view ray twice - once through the wave normal, once through\r\n // a flat surface of the same facing - and use only the difference, added\r\n // to the view line. The result is the view line plus a wave-normal\r\n // perturbation, so on calm water the sample stays put and only the wave\r\n // tilt moves it. The flat normal carries the same facing flip as the wave\r\n // one so the two cancel exactly on calm water from either side.\r\n this.$l.refractWave = pb.refract(this.eyeVecNorm, this.faceNormal, this.eta);\r\n this.$l.refractFlatNormal = pb.vec3(0, pb.sign(this.faceNormal.y), 0);\r\n this.$l.refractFlat = pb.refract(this.eyeVecNorm, this.refractFlatNormal, this.eta);\r\n // Total internal reflection - only reachable from under the surface -\r\n // leaves refract returning zero, so degenerate to the view line.\r\n this.$l.refractDir = pb.add(this.waterCrossDir, pb.sub(this.refractWave, this.refractFlat));\r\n this.$if(pb.lessThan(pb.length(pb.sub(this.refractWave, this.refractFlat)), 1e-4), function () {\r\n this.refractDir = this.waterCrossDir;\r\n });\r\n // A degenerate view line would push the direction below; clamp it to stay\r\n // on the line if the difference vanished.\r\n this.$if(pb.lessThan(pb.dot(this.refractDir, this.refractDir), 1e-6), function () {\r\n this.refractDir = this.waterCrossDir;\r\n });\r\n this.refractDir = pb.normalize(this.refractDir);\r\n this.$l.refractUV = this.screenUV;\r\n this.$l.refractPath = this.straightDist;\r\n if (!march) {\r\n // Cheap mode: step a fixed distance along the refracted direction and\r\n // sample where that projects, with no search. `refractDir` is the view\r\n // line plus a wave-normal perturbation, so with no waves this lands on\r\n // the point behind the surface.\r\n //\r\n // The step length is a *fixed* depth scale, deliberately not the\r\n // distance to what is behind the water: that distance jumps across an\r\n // object's silhouette, and the larger offset outside the outline lands\r\n // back on the object and paints a second copy of it. The price is that\r\n // shallow and deep water refract by the same amount.\r\n //\r\n // The edge fade inside waterRefractUV still applies, so the sample\r\n // cannot walk off screen.\r\n this.refractUV = this.waterRefractUV(\r\n this.screenUV,\r\n this.uvBase,\r\n pb.add(this.worldPos, pb.mul(this.refractDir, this.cheapRefractionDepth)),\r\n this.refractionScale\r\n );\r\n this.$return(pb.vec3(this.refractUV, this.refractPath));\r\n } else {\r\n this.$l.refractDirView = pb.mul(ShaderHelper.getViewMatrix(this), pb.vec4(this.refractDir, 0)).xyz;\r\n // Away from the camera the ray must travel, so a tangent one is clamped\r\n // rather than allowed to shoot off, and the straight-line distance bounds\r\n // the refracted path to a sane multiple of itself.\r\n this.$l.refractStepZ = pb.min(this.refractDirView.z, -1e-4);\r\n this.$l.maxPath = pb.mul(this.straightDist, REFRACT_MAX_PATH_RATIO);\r\n this.$l.marchResult = this.waterRefractMarch(\r\n this.worldPos,\r\n this.refractDir,\r\n this.screenUV,\r\n this.uvBase,\r\n this.surfaceViewZ,\r\n this.refractStepZ,\r\n ShaderHelper.getCameraParams(this).y,\r\n this.maxPath,\r\n this.straightDist\r\n );\r\n this.refractUV = this.marchResult.xy;\r\n this.refractPath = pb.clamp(this.marchResult.z, 0, this.maxPath);\r\n // Something sticking out of the water may occlude the refracted sample\r\n // even though the march kept going. Reconstruct the scene point at the\r\n // refracted UV and, if it sits above the surface, drop back to the\r\n // straight-through sample rather than refracting the object.\r\n this.$l.sceneHit = ShaderHelper.samplePositionFromDepth(\r\n this,\r\n ShaderHelper.getLinearDepthTexture(this),\r\n this.refractUV,\r\n ShaderHelper.getInvViewProjectionMatrix(this),\r\n ShaderHelper.getCameraParams(this).xy\r\n );\r\n // Only a *finite* scene point above the surface is an object poking\r\n // through - the sky's reconstructed point also sits high, but there is\r\n // nothing to reject then.\r\n this.$if(\r\n pb.and(pb.lessThan(this.sceneHit.w, 0.999), pb.greaterThan(this.sceneHit.y, this.worldPos.y)),\r\n function () {\r\n this.refractUV = this.screenUV;\r\n this.refractPath = this.straightDist;\r\n }\r\n );\r\n this.$return(pb.vec3(this.refractUV, this.refractPath));\r\n }\r\n }\r\n );\r\n return scope.waterRefraction(\r\n worldPos,\r\n normal,\r\n eyeVecNorm,\r\n screenUV,\r\n surfaceViewZ,\r\n straightDepth01,\r\n straightWorldPos,\r\n straightDist\r\n ) as PBShaderExp;\r\n }\r\n /**\r\n * Sunlight scattered out of the water column towards the eye.\r\n *\r\n * Closed-form single scattering, not a ray march. The medium is homogeneous\r\n * and the two paths through it are straight lines of fixed slope, so the\r\n * integral along the view ray has an elementary solution and costs one `exp`.\r\n *\r\n * Take `t` as distance along the refracted view ray from the surface, `d` as\r\n * its total length in the water, and `vy`/`sy` as how fast the view and sun\r\n * rays descend. A scattering event at `t` sits `t * vy` below the surface, so\r\n * the sun reached it over `t * vy / sy` and the scattered light returns over\r\n * `t`. Writing `r = vy / sy`:\r\n *\r\n * ```\r\n * S = integral(0..d) sigma_s * p * E * exp(-sigma_t * t * (1 + r)) dt\r\n * = albedo * p * E * (1 - exp(-sigma_t * (1 + r) * d)) / (1 + r)\r\n * ```\r\n *\r\n * `sigma_t` cancels out of everything but the exponent, which leaves the\r\n * result finite for an unbounded column: looking straight down at deep water\r\n * under an overhead sun gives `albedo * p * E / 2`, the textbook value.\r\n *\r\n * `E` is the sun's irradiance perpendicular to its own beam; there is no `NoL`\r\n * here, because the geometry the cosine would describe is already in `r`. Both\r\n * directions are refracted through a flat surface first.\r\n *\r\n * Only the entry Fresnel is applied here. The exit transmission is common to\r\n * every term leaving the medium and is applied once by the caller.\r\n *\r\n * Assumes the eye is above the surface; the caller gates on that.\r\n *\r\n * @param scope - Current shader scope.\r\n * @param lightEnergy - Sun irradiance perpendicular to the beam, after shadowing.\r\n * @param lightDir - Unit vector from the surface towards the light.\r\n * @param eyeVecNorm - Unit vector from the camera towards the surface.\r\n * @param NoL - Cosine of the sun's incidence on the wave normal.\r\n * @param depth - Refracted path length through the medium, in meters.\r\n * @returns Radiance scattered towards the eye, before the exit Fresnel.\r\n */\r\n waterSunScattering(\r\n scope: PBInsideFunctionScope,\r\n lightEnergy: PBShaderExp,\r\n lightDir: PBShaderExp,\r\n eyeVecNorm: PBShaderExp,\r\n NoL: PBShaderExp,\r\n depth: PBShaderExp,\r\n foam: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n pb.func(\r\n 'waterSunScattering',\r\n [\r\n pb.vec3('lightEnergy'),\r\n pb.vec3('lightDir'),\r\n pb.vec3('eyeVecNorm'),\r\n pb.float('NoL'),\r\n pb.float('depth'),\r\n pb.float('foam')\r\n ],\r\n function () {\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n // Both directions as they travel inside the water. The sun's incident\r\n // direction is where it travels to, the opposite of `lightDir`.\r\n this.$l.Lw = pb.refract(pb.neg(this.lightDir), this.up, AIR_TO_WATER_ETA);\r\n this.$l.Vw = pb.refract(this.eyeVecNorm, this.up, AIR_TO_WATER_ETA);\r\n // How fast each descends. The sun is floored rather than allowed to\r\n // reach zero: a sun on the horizon lights the column over an unbounded\r\n // path, which single scattering cannot represent.\r\n this.$l.sy = pb.max(pb.neg(this.Lw.y), MIN_SUN_SLOPE);\r\n this.$l.vy = pb.max(pb.neg(this.Vw.y), 1e-3);\r\n this.$l.r = pb.div(this.vy, this.sy);\r\n this.$l.rr = pb.add(1, this.r);\r\n // Angle between the sun's travel and the direction the light has to\r\n // leave in to reach the eye, which is back along the view ray.\r\n this.$l.cosTheta = pb.neg(pb.dot(this.Lw, this.Vw));\r\n this.$l.hg = waterScatterPhase(this, this.cosTheta, this.sunScatterParams.y);\r\n // Multiple scattering washes the lobe out: an optically thick column has\r\n // scattered the light enough times that the direction it entered by no\r\n // longer matters. Weighted on luminance and shared across channels,\r\n // because the phase does not depend on wavelength - only how far the\r\n // light got does.\r\n this.$l.lumWeights = pb.vec3(0.2126, 0.7152, 0.0722);\r\n this.$l.extLum = pb.dot(this.mediumExtinction, this.lumWeights);\r\n this.$l.albedoLum = pb.dot(this.mediumAlbedo, this.lumWeights);\r\n this.$l.thickness = pb.mul(\r\n this.albedoLum,\r\n pb.sub(1, pb.exp(pb.neg(pb.mul(this.extLum, this.depth))))\r\n );\r\n this.$l.phase = pb.mix(\r\n this.hg,\r\n 1 / (4 * Math.PI),\r\n pb.smoothStep(0, 0.5, pb.clamp(this.thickness, 0, 1))\r\n );\r\n // The integral itself. Per channel, since sigma_t is.\r\n this.$l.k = pb.mul(this.mediumExtinction, this.rr);\r\n this.$l.integral = pb.div(pb.sub(pb.vec3(1), pb.exp(pb.neg(pb.mul(this.k, this.depth)))), this.rr);\r\n // Entry Fresnel: what the surface let through on the way in. This is\r\n // also what keeps the term off a backlit crest - at NoL <= 0 no light\r\n // enters the top face at all, and the subsurface term owns that case.\r\n this.$l.entry = pb.sub(1, pb.add(WATER_F0, pb.mul(1 - WATER_F0, pb.pow(pb.sub(1, this.NoL), 5))));\r\n // The flat-interface Fresnel goes to zero at grazing incidence, which is\r\n // right for smooth water and wrong for a fold - a mass of bubbles, not a\r\n // mirror. Blended towards full transmission by the foam coverage, so a\r\n // breaking crest lights its own column. Weighted, not replaced: a thin\r\n // scattering layer still attenuates.\r\n this.$l.entry = pb.mix(this.entry, pb.float(1), this.foam);\r\n this.$return(\r\n pb.mul(\r\n this.mediumAlbedo,\r\n this.lightEnergy,\r\n this.integral,\r\n pb.mul(this.phase, this.entry, this.sunScatterParams.x)\r\n )\r\n );\r\n }\r\n );\r\n return scope.waterSunScattering(lightEnergy, lightDir, eyeVecNorm, NoL, depth, foam) as PBShaderExp;\r\n }\r\n waterShading(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n worldNormal: PBShaderExp,\r\n foamFactor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this;\r\n const ramp = this.mediumMode === 'ramp';\r\n const shoreFoam = this._shoreFoamAvailable(scope);\r\n const debugOutput = this.debugOutput;\r\n // Transmittance of the medium over `depth` meters of path.\r\n pb.func('getAbsorption', [pb.float('depth')], function () {\r\n if (ramp) {\r\n this.$l.c = pb.textureSampleLevel(\r\n this.absorptionRampTex,\r\n pb.vec2(pb.mul(this.depth, this.depthMulti), 0.5),\r\n 0\r\n ).rgb;\r\n this.$return(pb.mul(this.c, this.c));\r\n } else {\r\n this.$return(pb.exp(pb.neg(pb.mul(this.mediumExtinction, this.depth))));\r\n }\r\n });\r\n // Radiance scattered back out of the medium over `depth` meters of path,\r\n // as a fraction of the incident irradiance.\r\n pb.func('getScattering', [pb.float('depth')], function () {\r\n if (ramp) {\r\n this.$l.c = pb.textureSampleLevel(\r\n this.scatterRampTex,\r\n pb.vec2(pb.mul(this.depth, this.depthMulti), 0.5),\r\n 0\r\n ).rgb;\r\n this.$return(pb.mul(this.c, this.c));\r\n } else {\r\n // Single-scattering: the albedo weighs how much of the extinguished\r\n // energy comes back rather than being absorbed.\r\n this.$return(\r\n pb.mul(\r\n this.mediumAlbedo,\r\n pb.sub(pb.vec3(1), pb.exp(pb.neg(pb.mul(this.mediumExtinction, this.depth))))\r\n )\r\n );\r\n }\r\n });\r\n pb.func('fresnel', [pb.vec3('normal'), pb.vec3('eyeVec'), pb.bool('underwater')], function () {\r\n // The magnitude of the cosine: it changes sign when the view direction\r\n // crosses the normal, which a folded crest makes happen inside a single\r\n // wave. Clamping at zero instead drops the reflectance to F0 exactly where\r\n // the geometry is at its most grazing, giving a black band across the\r\n // crest.\r\n this.$l.NoV = pb.clamp(pb.abs(pb.dot(this.normal, this.eyeVec)), 0, 1);\r\n // Looking up at the underside, the interface behaves quite differently.\r\n // Past the critical angle - about 48.6 degrees off vertical for n = 1.333 -\r\n // Snell's law has no solution and nothing gets out at all: the surface is\r\n // a perfect mirror there, and the circle of sky inside that angle is the\r\n // Snell window.\r\n this.$if(this.underwater, function () {\r\n this.$l.sinT2 = pb.mul(WATER_TO_AIR_ETA * WATER_TO_AIR_ETA, pb.sub(1, pb.mul(this.NoV, this.NoV)));\r\n // Total internal reflection, and deliberately not scaled by\r\n // reflectionStrength. That knob exists to trade an above-water\r\n // reflection away for a view of the sea bed beneath it; from below there\r\n // is no transmitted ray to reveal, and dialling the mirror down there\r\n // just bleeds the straight-through sample - the world above the water -\r\n // across the whole surface outside the window, where physically nothing\r\n // is visible at all.\r\n this.$l.f = pb.float(1);\r\n this.$if(pb.lessThan(this.sinT2, 1), function () {\r\n // Schlick is written against the angle on the less dense side of the\r\n // interface, so the transmitted cosine is what goes in rather than the\r\n // incident one. F0 itself is unchanged: ((n1-n2)/(n1+n2))^2 is\r\n // symmetric in the two media.\r\n this.$l.cosT = pb.sqrt(pb.max(pb.sub(1, this.sinT2), 0));\r\n this.f = pb.clamp(\r\n pb.mul(\r\n pb.add(WATER_F0, pb.mul(1 - WATER_F0, pb.pow(pb.sub(1, this.cosT), 5))),\r\n this.reflectionStrength\r\n ),\r\n 0,\r\n 1\r\n );\r\n });\r\n this.$return(this.f);\r\n });\r\n this.$l.f = pb.add(WATER_F0, pb.mul(1 - WATER_F0, pb.pow(pb.sub(1, this.NoV), 5)));\r\n // Scaling keeps the term in [0,1] for any authored reflectionStrength.\r\n this.$return(pb.clamp(pb.mul(this.f, this.reflectionStrength), 0, 1));\r\n });\r\n pb.func(\r\n 'lightSpecular',\r\n [\r\n pb.vec3('lightDir'),\r\n pb.vec3('eyeVecNorm'),\r\n pb.vec3('normal'),\r\n pb.vec3('lightColor'),\r\n pb.float('roughness')\r\n ],\r\n function () {\r\n this.$l.f0 = pb.vec3(WATER_F0);\r\n this.$l.f90 = pb.vec3(1);\r\n this.$l.L = this.lightDir;\r\n this.$l.V = pb.neg(this.eyeVecNorm);\r\n this.$l.halfVec = pb.normalize(pb.add(this.L, this.V));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.halfVec), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.specular = pb.vec3(0);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.V, this.halfVec), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.V), 0, 1);\r\n this.$l.F = fresnelSchlick(this, this.VoH, this.f0, this.f90);\r\n this.$l.alphaRoughness = pb.mul(this.roughness, this.roughness);\r\n this.$l.D = distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.VIS = visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.specular = pb.mul(this.D, this.VIS, this.F, this.lightColor);\r\n });\r\n this.$return(this.specular);\r\n }\r\n );\r\n if (shoreFoam) {\r\n // Three octaves of value noise over the world XZ plane, drifting slowly.\r\n // World space rather than screen or surface space, so the pattern does not\r\n // slide over the band as the camera moves.\r\n pb.func('waterShoreFoamPattern', [pb.vec2('xz'), pb.float('time')], function () {\r\n // Drift applied in meters before the frequency, so changing the clump\r\n // size does not change how fast they travel.\r\n this.$l.p = pb.mul(\r\n pb.add(this.xz, pb.mul(pb.vec2(SHORE_FOAM_DRIFT_X, SHORE_FOAM_DRIFT_Z), this.time)),\r\n this.shoreFoamParams.w\r\n );\r\n this.$return(\r\n pb.add(\r\n pb.mul(valueNoise(this, this.p), SHORE_FOAM_OCTAVE_WEIGHTS[0]),\r\n // Offset as well as scaled: octaves sharing a lattice line their\r\n // features up at the cell corners.\r\n pb.mul(\r\n valueNoise(this, pb.add(pb.mul(this.p, SHORE_FOAM_OCTAVE_RATIO), pb.vec2(13.7, 7.3))),\r\n SHORE_FOAM_OCTAVE_WEIGHTS[1]\r\n ),\r\n pb.mul(\r\n valueNoise(\r\n this,\r\n pb.add(pb.mul(this.p, SHORE_FOAM_OCTAVE_RATIO * SHORE_FOAM_OCTAVE_RATIO), pb.vec2(5.1, 29.3))\r\n ),\r\n SHORE_FOAM_OCTAVE_WEIGHTS[2]\r\n )\r\n )\r\n );\r\n });\r\n // Distance from the water surface to the nearest opaque surface anywhere\r\n // around it, through the Hi-Z pyramid's nearest-depth channel.\r\n //\r\n // A *neighbourhood* query rather than a lookup along the view ray. Beside\r\n // a piling the ray hits its side just under the waterline, so a pixel far\r\n // from the piling reads as touching it while the closer pixels to its left\r\n // and right see past it entirely - the geometry those pixels need is not\r\n // on their ray at all.\r\n //\r\n // The pyramid is what makes the neighbourhood affordable: one cell at the\r\n // right level summarises the whole footprint, so the sample count does not\r\n // grow with the radius, and the nearest-depth reduction means a cell the\r\n // query covers cannot hide geometry from it.\r\n //\r\n // Reports a distance past the band's reach when the neighbourhood is\r\n // empty, so the caller's ramp reads it as \"outside the band\" without a\r\n // separate miss flag.\r\n pb.func(\r\n 'waterShoreProximity',\r\n [pb.vec3('viewPos'), pb.vec2('screenUV'), pb.float('radius')],\r\n function () {\r\n this.$l.renderSize = ShaderHelper.getRenderSize(this);\r\n this.$l.projMatrix = ShaderHelper.getProjectionMatrix(this);\r\n // Screen radius, in pixels, of a sphere of `radius` metres at this\r\n // depth. proj[0].x is the horizontal projection scale, and the NDC\r\n // half-extent maps onto half the render width.\r\n this.$l.viewDist = pb.max(pb.neg(this.viewPos.z), 1e-4);\r\n this.$l.pixelRadius = pb.mul(\r\n pb.div(pb.mul(this.radius, this.projMatrix[0].x), this.viewDist),\r\n 0.5,\r\n this.renderSize.x\r\n );\r\n // Level whose texel spans the query footprint divided by the tap\r\n // spread, so the 3x3 grid covers roughly the whole sphere. Floored to\r\n // an integer: the pyramid is sampled with a nearest mip filter, and a\r\n // fractional level would show up as a seam across the band.\r\n this.$l.level = pb.clamp(\r\n pb.floor(pb.log2(pb.max(pb.div(this.pixelRadius, SHORE_QUERY_TAP_SPREAD), 1))),\r\n 0,\r\n pb.sub(pb.float(ShaderHelper.getHiZDepthTextureMipLevelCount(this)), 1)\r\n );\r\n this.$l.mipSize = pb.max(pb.floor(pb.div(this.renderSize, pb.exp2(this.level))), pb.vec2(1));\r\n this.$l.texelStep = pb.div(pb.vec2(1), this.mipSize);\r\n // Every cell in a 4x4 window contributes, weighted by a tent reaching\r\n // zero at the window's edge, and each is read as a point dithered\r\n // somewhere inside it.\r\n //\r\n // The tent makes the window's own stepping invisible: the column of\r\n // cells leaving and the one arriving both have zero weight there. The\r\n // pyramid is bound with a nearest sampler - SSR's traversal needs exact\r\n // cell values - so this smoothing has to happen here.\r\n //\r\n // The dither keeps the contours round. A cell is a box, and the\r\n // distance to a box has square contours; at these levels a cell is most\r\n // of the radius across, so what is left is a grid of squares. Picking a\r\n // point inside the cell is what the cell's own statement licenses.\r\n //\r\n // Hashed from the pixel *and* the frame counter, and applied to the\r\n // interpretation of the samples rather than to which samples are\r\n // taken: the fetches stay identical frame to frame while the guess\r\n // moves, which is what lets TAA average the residual grain away.\r\n this.$l.dither = pb.mul(pb.float(ShaderHelper.getFramestamp(this)), SHORE_QUERY_DITHER_STRIDE);\r\n this.$l.gridCoord = pb.sub(pb.mul(this.screenUV, this.mipSize), pb.vec2(0.5));\r\n this.$l.gridBase = pb.floor(this.gridCoord);\r\n this.$l.gridFrac = pb.sub(this.gridCoord, this.gridBase);\r\n // Softness of the minimum below, and the distance a neighbourhood with\r\n // nothing in it resolves to. Both scale with the radius, so the query\r\n // behaves the same whatever the band is set to.\r\n this.$l.softK = pb.mul(this.radius, SHORE_QUERY_SOFTMIN);\r\n this.$l.dMax = pb.mul(this.radius, SHORE_QUERY_MISS_REACH);\r\n this.$l.esum = pb.float(0);\r\n this.$l.wsum = pb.float(0);\r\n for (let gy = 0; gy < 4; gy++) {\r\n for (let gx = 0; gx < 4; gx++) {\r\n this.$l[`uv${gx}${gy}`] = pb.mul(\r\n pb.add(this.gridBase, pb.vec2(gx - 1 + 0.5, gy - 1 + 0.5)),\r\n this.texelStep\r\n );\r\n this.$l[`hiz${gx}${gy}`] = pb.textureSampleLevel(\r\n ShaderHelper.getHiZDepthTexture(this),\r\n this[`uv${gx}${gy}`],\r\n this.level\r\n );\r\n this.$l[`z${gx}${gy}`] = ShaderHelper.nonLinearDepthToLinear(this, this[`hiz${gx}${gy}`].g);\r\n this.$l[`zFar${gx}${gy}`] = ShaderHelper.nonLinearDepthToLinear(this, this[`hiz${gx}${gy}`].r);\r\n // A cell says \"some surface lies inside this screen rectangle, at\r\n // a depth between near and far\" - a frustum block. Collapsing that\r\n // to the point on the centre ray at the near depth puts a cell\r\n // straddling a silhouette beside the object in empty space, nearer\r\n // to the water than the object itself.\r\n //\r\n // Laterally the point is dithered across the cell instead, which\r\n // invents nothing: any spot in the cell is somewhere the surface\r\n // could be. In depth it is clamped, because the reduction\r\n // guarantees a surface on the near face, and the span is clipped by\r\n // SHORE_QUERY_CELL_DEPTH_SPAN.\r\n this.$l[`cellW${gx}${gy}`] = pb.max(\r\n pb.div(pb.mul(this.texelStep.x, 2, this[`z${gx}${gy}`]), this.projMatrix[0].x),\r\n 1e-6\r\n );\r\n this.$l[`zBack${gx}${gy}`] = pb.min(\r\n this[`zFar${gx}${gy}`],\r\n pb.add(this[`z${gx}${gy}`], pb.mul(this[`cellW${gx}${gy}`], SHORE_QUERY_CELL_DEPTH_SPAN))\r\n );\r\n // How far outside the block's depth range the water pixel sits.\r\n // Zero while it is between the two faces.\r\n this.$l[`zClamp${gx}${gy}`] = pb.clamp(\r\n pb.neg(this.viewPos.z),\r\n this[`z${gx}${gy}`],\r\n this[`zBack${gx}${gy}`]\r\n );\r\n this.$l[`dz${gx}${gy}`] = pb.add(this.viewPos.z, this[`zClamp${gx}${gy}`]);\r\n // Seeded per cell as well as per pixel: one offset shared by all\r\n // sixteen would move the whole set together.\r\n this.$l[`jit${gx}${gy}`] = pb.sub(\r\n pb.vec2(\r\n interleavedGradientNoise(\r\n this,\r\n pb.add(\r\n this.$builtins.fragCoord.xy,\r\n pb.vec2(pb.add(this.dither, gx * 7.13 + 0.5), pb.add(this.dither, gy * 3.71 + 0.5))\r\n )\r\n ),\r\n interleavedGradientNoise(\r\n this,\r\n pb.add(\r\n this.$builtins.fragCoord.xy,\r\n pb.vec2(pb.add(this.dither, gy * 3.71 + 37), pb.add(this.dither, gx * 7.13 + 17))\r\n )\r\n )\r\n ),\r\n pb.vec2(0.5)\r\n );\r\n this.$l[`guessNDC${gx}${gy}`] = pb.sub(\r\n pb.mul(pb.add(this[`uv${gx}${gy}`], pb.mul(this[`jit${gx}${gy}`], this.texelStep)), 2),\r\n pb.vec2(1)\r\n );\r\n this.$l[`guess${gx}${gy}`] = pb.div(\r\n pb.mul(this[`guessNDC${gx}${gy}`], this[`zClamp${gx}${gy}`]),\r\n pb.vec2(this.projMatrix[0].x, this.projMatrix[1].y)\r\n );\r\n this.$l[`dxy${gx}${gy}`] = pb.sub(this.viewPos.xy, this[`guess${gx}${gy}`]);\r\n this.$l[`d${gx}${gy}`] = pb.length(pb.vec3(this[`dxy${gx}${gy}`], this[`dz${gx}${gy}`]));\r\n // Tent weight, from the cell's offset to the pixel in cell units.\r\n // Zero at two cells out, which is the edge of the 4x4 window, so a\r\n // cell entering or leaving the window does so from nothing.\r\n this.$l[`w${gx}${gy}`] = pb.mul(\r\n pb.max(pb.sub(1, pb.abs(pb.div(pb.sub(pb.float(gx - 1), this.gridFrac.x), 2))), 0),\r\n pb.max(pb.sub(1, pb.abs(pb.div(pb.sub(pb.float(gy - 1), this.gridFrac.y), 2))), 0)\r\n );\r\n this.wsum = pb.add(this.wsum, this[`w${gx}${gy}`]);\r\n this.esum = pb.add(\r\n this.esum,\r\n pb.mul(\r\n this[`w${gx}${gy}`],\r\n pb.exp(pb.neg(pb.div(pb.min(this[`d${gx}${gy}`], this.dMax), this.softK)))\r\n )\r\n );\r\n }\r\n }\r\n // Weighted soft minimum, not a hard one. A hard `min` lets one cell\r\n // decide the answer outright, so the band comes out in squares that\r\n // step on cell boundaries. Averaging lets a cell losing its claim cost\r\n // only its share and lets the dither average down. It still reads as a\r\n // distance: below a few times `softK` it tracks the true minimum\r\n // closely.\r\n this.$return(pb.mul(pb.neg(this.softK), pb.log(pb.div(this.esum, this.wsum))));\r\n }\r\n );\r\n // Coverage of the foam that collects where the water meets a surface, and\r\n // how far that surface is, as (coverage, distance).\r\n pb.func('waterShoreFoam', [pb.vec3('worldPos'), pb.vec3('viewPos'), pb.vec2('screenUV')], function () {\r\n this.$l.time = ShaderHelper.getElapsedTime(this);\r\n // Queried at the band's widest reach rather than its current one, so the\r\n // run-up below moves the edge without moving the mip level under it -\r\n // which would step the whole band's resolution once a cycle.\r\n this.$l.surfaceDist = this.waterShoreProximity(\r\n this.viewPos,\r\n this.screenUV,\r\n this.shoreFoamWashParams.w\r\n );\r\n // Where the band currently reaches out to, modulated over time by the\r\n // run-up. The phase offset comes from a noise field over the world plane\r\n // rather than from a direction: the query does not know where the shore\r\n // runs, and a guessed axis reads as a diagonal swell crossing the beach.\r\n this.$l.washOffset = valueNoise(this, pb.mul(this.worldPos.xz, this.shoreFoamWashParams.z));\r\n this.$l.wash = pb.sin(\r\n pb.mul(pb.add(pb.mul(this.time, this.shoreFoamWashParams.y), this.washOffset), 2 * Math.PI)\r\n );\r\n this.$l.edge = pb.max(\r\n pb.mul(this.shoreFoamParams.y, pb.add(1, pb.mul(this.shoreFoamWashParams.x, this.wash))),\r\n 0\r\n );\r\n this.$l.soft = pb.max(pb.mul(this.edge, SHORE_FOAM_EDGE_SOFTNESS), 1e-4);\r\n // The gradient runs *up to* the reach, not across it: `edge` is where the\r\n // band ends, so coverage must be zero there. Straddling `edge` would put\r\n // a total miss at the middle of the ramp, which is half coverage over the\r\n // entire open sea.\r\n this.$l.ramp = pb.sub(1, pb.smoothStep(pb.sub(this.edge, this.soft), this.edge, this.surfaceDist));\r\n // Open water, which is almost every water pixel in almost every frame,\r\n // is done here and does not pay for the pattern.\r\n this.$if(pb.lessThanEqual(this.ramp, 0), function () {\r\n this.$return(pb.vec2(0, this.surfaceDist));\r\n });\r\n this.$l.pattern = this.waterShoreFoamPattern(this.worldPos.xz, this.time);\r\n this.$l.coverage = pb.clamp(\r\n pb.div(pb.sub(this.ramp, pb.mul(this.pattern, SHORE_FOAM_NOISE_BITE)), 1 - SHORE_FOAM_NOISE_BITE),\r\n 0,\r\n 1\r\n );\r\n this.$return(\r\n pb.vec2(\r\n pb.clamp(pb.mul(pb.pow(this.coverage, this.shoreFoamParams.z), this.shoreFoamParams.x), 0, 1),\r\n this.surfaceDist\r\n )\r\n );\r\n });\r\n }\r\n pb.func(\r\n 'waterShading',\r\n [pb.vec3('worldPos'), pb.vec3('worldNormal'), pb.float('foamFactor')],\r\n function () {\r\n this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), ShaderHelper.getRenderSize(this));\r\n this.$l.dist = pb.length(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this)));\r\n this.$l.normalScale = pb.clamp(pb.div(100, this.dist), 0, 1);\r\n this.$l.normal = pb.normalize(\r\n pb.mul(this.worldNormal, pb.vec3(this.normalScale, 1, this.normalScale))\r\n );\r\n this.$l.roughness = that.waterRoughness(this, this.worldPos);\r\n this.$l.wPos = ShaderHelper.samplePositionFromDepth(\r\n this,\r\n ShaderHelper.getLinearDepthTexture(this),\r\n this.screenUV,\r\n ShaderHelper.getInvViewProjectionMatrix(this),\r\n ShaderHelper.getCameraParams(this).xy\r\n );\r\n this.$l.eyeVec = pb.sub(this.worldPos.xyz, ShaderHelper.getCameraPosition(this));\r\n this.$l.eyeVecNorm = pb.normalize(this.eyeVec);\r\n // The normal the mirror-like terms use - Fresnel, the reflection vector,\r\n // the specular lobe - turned towards the eye where the surface has\r\n // folded far enough to show its underside.\r\n //\r\n // Flipped on the sign of the cosine against the view direction, not on\r\n // `frontFacing`: the rasteriser's answer changes discontinuously along\r\n // the triangle edge where the fold happens, so the flipped normal jumps\r\n // by 2*N there and every term built on it steps with it. The cosine\r\n // crosses zero continuously.\r\n //\r\n // `eyeVecNorm` runs from the camera to the surface, so a face turned\r\n // towards the eye has a *negative* dot against it and the flip is the\r\n // positive case.\r\n this.$l.shadingNormal = this.$choice(\r\n pb.greaterThan(pb.dot(this.normal, this.eyeVecNorm), 0),\r\n pb.neg(this.normal),\r\n this.normal\r\n );\r\n // The normal the diffuse terms use, which is not the wave normal.\r\n //\r\n // Where a choppy displacement folds the surface the cross-product normal\r\n // is genuinely close to horizontal. That is the right normal for the\r\n // mirror - the specular lobe and the refraction go by the face's true\r\n // orientation - and the wrong one for anything lit diffusely: the sun is\r\n // nearly perpendicular to a folded wall, so a diffuse term built on it\r\n // loses the sun completely.\r\n //\r\n // Built on the eye-facing normal and then mixed towards up, so the two\r\n // corrections compose. The weight rises with |normal.y|: at |y| = 1 the\r\n // wave normal is kept exactly, and as the face tips over the up vector\r\n // takes it back. A smoothstep rather than |normal.y| itself, which would\r\n // stay dominated by the wall normal exactly where it is least wanted.\r\n this.$l.diffuseWeight = pb.smoothStep(0, 0.5, pb.abs(this.normal.y));\r\n this.$l.diffuseNormal = pb.normalize(\r\n pb.mix(pb.vec3(0, 1, 0), this.shadingNormal, this.diffuseWeight)\r\n );\r\n // Which face of the surface the camera is on. Taken from the rasteriser,\r\n // not from the wave normal: the choppy displacement folds the sheet, so\r\n // the pixels showing its underside also carry an upward normal, and a\r\n // test built on the normal would put every term on the wrong side of the\r\n // interface there.\r\n this.$l.frontFace = this.$builtins.frontFacing;\r\n this.$l.backFace = pb.not(this.frontFace);\r\n this.$l.underwaterEye = this.backFace;\r\n this.$l.depth = pb.length(pb.sub(this.wPos.xyz, this.worldPos));\r\n this.$l.viewPos = pb.mul(ShaderHelper.getViewMatrix(this), pb.vec4(this.worldPos, 1)).xyz;\r\n this.incidentVec = pb.normalize(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this)));\r\n this.reflectVecW = pb.reflect(this.incidentVec, this.shadingNormal);\r\n this.$l.reflectance = pb.vec3();\r\n this.$l.hitInfo = pb.vec4(0);\r\n // Which way a reflection has to go to have anything to hit. From above\r\n // that is upwards, off the surface into the sky; from below it is\r\n // downwards, back into the water. Testing for \"up\" regardless meant a\r\n // submerged pixel never traced at all and fell through to the sky bake,\r\n // which is the one thing that cannot be behind a surface seen from\r\n // underneath.\r\n this.$if(\r\n this.$choice(\r\n this.underwaterEye,\r\n pb.lessThan(this.reflectVecW.y, 0),\r\n pb.greaterThan(this.reflectVecW.y, 0)\r\n ),\r\n function () {\r\n this.reflectVec = pb.mul(ShaderHelper.getViewMatrix(this), pb.vec4(this.reflectVecW, 0)).xyz;\r\n this.hitInfo = ShaderHelper.getHiZDepthTexture(this)\r\n ? screenSpaceRayTracing_HiZ(\r\n this,\r\n this.viewPos,\r\n this.reflectVec,\r\n ShaderHelper.getViewMatrix(this),\r\n ShaderHelper.getProjectionMatrix(this),\r\n ShaderHelper.getInvProjectionMatrix(this),\r\n ShaderHelper.getCameraParams(this).xy,\r\n pb.int(ShaderHelper.getHiZDepthTextureMipLevelCount(this)),\r\n this.ssrParams.y,\r\n this.ssrParams.x,\r\n this.ssrParams.z,\r\n pb.vec4(ShaderHelper.getRenderSize(this), ShaderHelper.getHiZDepthTextureSize(this)),\r\n ShaderHelper.getHiZDepthTexture(this)\r\n )\r\n : screenSpaceRayTracing_Linear2D(\r\n this,\r\n this.viewPos,\r\n this.reflectVec,\r\n ShaderHelper.getViewMatrix(this),\r\n ShaderHelper.getProjectionMatrix(this),\r\n ShaderHelper.getInvProjectionMatrix(this),\r\n ShaderHelper.getCameraParams(this).xy,\r\n this.ssrParams.x,\r\n this.ssrParams.y,\r\n this.ssrParams.z,\r\n this.ssrParams.w,\r\n pb.vec4(ShaderHelper.getRenderSize(this), ShaderHelper.getLinearDepthTextureSize(this)),\r\n ShaderHelper.getLinearDepthTexture(this)\r\n );\r\n }\r\n );\r\n this.$l.refl = pb.reflect(\r\n pb.normalize(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this))),\r\n this.shadingNormal\r\n );\r\n // What the mirror shows where the screen-space trace found nothing.\r\n //\r\n // From above that is the sky. Rays reflecting downwards, and grazing\r\n // ones, land on the bake's lower hemisphere, which the atmosphere\r\n // renders nearly black, so the far ocean reads as a dark band. Flooring\r\n // the y and re-normalising pins those directions just above the horizon,\r\n // which is roughly what a grazing reflection does see; a reflection\r\n // already pointing into the sky is untouched. A floor rather than a soft\r\n // lift, so only the degenerate directions are nudged.\r\n //\r\n // From below there is no sky in that direction at all - the ray is\r\n // heading back down into the water - and what it eventually reaches is\r\n // the water itself. That is the medium's asymptotic colour, the same\r\n // limit the underwater pass converges to as the path length grows:\r\n // albedo * (1 - exp(-sigma_t * d)) * ambient with the exponential gone.\r\n // Sampling the sky bake there instead put a bright sky outside the Snell\r\n // window, which is exactly where nothing above the surface is visible.\r\n this.$l.reflMiss = pb.vec3();\r\n this.$if(this.underwaterEye, function () {\r\n this.$l.downwelling = ShaderHelper.sampleBakedSkyPreExposed(this, pb.vec3(0, 1, 0));\r\n this.reflMiss = pb.mul(this.mediumAlbedo, this.downwelling);\r\n }).$else(function () {\r\n this.refl.y = pb.max(this.refl.y, HORIZON_REFLECT_BIAS);\r\n this.refl = pb.normalize(this.refl);\r\n // Blended against the pre-exposed scene color, so the exposure-independent sky bake has\r\n // to be lifted into the same space.\r\n this.reflMiss = ShaderHelper.sampleBakedSkyPreExposed(this, this.refl);\r\n });\r\n this.reflectance = pb.mix(\r\n this.reflMiss,\r\n pb.textureSampleLevel(ShaderHelper.getSceneColorTexture(this), this.hitInfo.xy, 0).rgb,\r\n this.hitInfo.w\r\n );\r\n this.$l.refractInfo = that.waterRefraction(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.eyeVecNorm,\r\n this.screenUV,\r\n this.viewPos.z,\r\n this.wPos.w,\r\n this.wPos.xyz,\r\n this.depth\r\n );\r\n this.$l.refractUV = this.refractInfo.xy;\r\n // The medium is walked along the refracted path, not along the straight\r\n // line to the bed. A refracted ray reaches the same depth over a shorter\r\n // distance, and at a grazing view the two differ by a lot.\r\n this.depth = this.refractInfo.z;\r\n // How blurred what is behind the water reads. Scattering in the column\r\n // deflects the transmitted ray at every event, so the image arriving at\r\n // the surface is a convolution whose width grows with the optical depth;\r\n // sampling a coarser mip is the cheap stand-in for that.\r\n //\r\n // Log in the path length because each mip is a doubling of the filter\r\n // width, and driven by the *scattering* coefficient rather than the\r\n // extinction: absorption removes light without redirecting it, so it\r\n // darkens the background without blurring it.\r\n //\r\n // Zero from below. The ray leaving the underside travels through air to\r\n // whatever it reaches, so there is no medium along it to blur or absorb\r\n // with - what the eye already looked through to get here is the volume\r\n // the Underwater pass owns, and charging the same column twice turned\r\n // the world seen through the Snell window into a dark smear.\r\n this.$l.mediumPath = this.$choice(this.underwaterEye, pb.float(0), this.depth);\r\n this.$l.refractBlur = pb.log2(\r\n pb.add(1, pb.mul(this.mediumPath, pb.add(REFRACT_BLUR_GEOMETRIC, this.refractBlurDensity)))\r\n );\r\n this.$l.refraction = pb.textureSampleLevel(\r\n ShaderHelper.getSceneColorTexture(this),\r\n this.refractUV,\r\n pb.clamp(this.refractBlur, 0, REFRACT_BLUR_MAX_LOD)\r\n ).rgb;\r\n this.$l.refractionRaw = this.refraction;\r\n this.$l.absorption = this.getAbsorption(this.mediumPath);\r\n this.refraction = pb.mul(this.refraction, this.absorption);\r\n this.$l.fresnelTerm = this.fresnel(this.shadingNormal, pb.neg(this.eyeVecNorm), this.underwaterEye);\r\n // Foam coverage. The generator reports where the surface has folded over\r\n // on itself; the ramp turns that into how much of the texel is covered.\r\n this.$l.crestFoam = pb.clamp(\r\n pb.mul(pb.pow(pb.clamp(this.foamFactor, 0, 1), this.foamShadingParams.y), this.foamShadingParams.x),\r\n 0,\r\n 1\r\n );\r\n // (coverage, distance to the nearest surface around the pixel). The\r\n // distance is carried out for the debug view; the shading only wants x.\r\n this.$l.shoreFoamInfo = shoreFoam\r\n ? (this.waterShoreFoam(this.worldPos, this.viewPos, this.screenUV) as PBShaderExp)\r\n : pb.vec2(0, 0);\r\n this.$l.shoreFoam = this.shoreFoamInfo.x;\r\n // Two independent coverages of the same texel, so they compose as\r\n // overlapping area: `max` would ignore the smaller source entirely and\r\n // adding would run past 1.\r\n this.$l.foam = pb.sub(1, pb.mul(pb.sub(1, this.crestFoam), pb.sub(1, this.shoreFoam)));\r\n // Foam suppresses the specular lobe rather than adding to it: where it is\r\n // thick the mirror underneath stops being visible at all.\r\n this.fresnelTerm = pb.mul(this.fresnelTerm, pb.sub(1, this.foam));\r\n this.$l.finalColor = pb.mix(this.refraction, this.reflectance, this.fresnelTerm);\r\n // Per-term accumulators for the debug views. Dead in the `none` variant.\r\n this.$l.dbgSpecular = pb.vec3(0);\r\n this.$l.dbgNoL = pb.float(0);\r\n this.$l.dbgShadow = pb.vec3(1);\r\n this.$l.dbgSubsurface = pb.vec3(0);\r\n this.$l.dbgSunScatter = pb.vec3(0);\r\n this.$l.dbgScatter = pb.vec3(0);\r\n // What anything leaving the water body keeps on its way out, and the\r\n // share of the surface that is water rather than foam. The refraction\r\n // above already carries the first factor via the `mix`; every scattering\r\n // term below has to carry it too.\r\n this.$l.bodyWeight = pb.mul(pb.sub(1, this.fresnelTerm), pb.sub(1, this.foam));\r\n // The sun-scattering debug views below rebuild that term's factors, and\r\n // the light direction is only known inside this loop. Initialised so the\r\n // views are well defined even with no directional light in the scene.\r\n this.dbgLightDir = pb.vec3(0, 1, 0);\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff,\r\n extra\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n // Left behind for the sun-scattering debug views, which rebuild that\r\n // term's factors outside this loop.\r\n this.dbgLightDir = this.lightDir;\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n // Diffuse incidence, off the diffuse normal. Used by the foam and the\r\n // sun in-scattering below; NoL keeps the wave face for the mirror.\r\n this.$l.NoLdiffuse = pb.clamp(pb.dot(this.diffuseNormal, this.lightDir), 0, 1);\r\n this.dbgNoL = this.NoLdiffuse;\r\n this.$l.lightEnergy = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten);\r\n this.$l.specularTerm = this.lightSpecular(\r\n this.lightDir,\r\n this.eyeVecNorm,\r\n this.shadingNormal,\r\n this.lightEnergy,\r\n this.roughness\r\n );\r\n this.$l.lightContrib = this.specularTerm;\r\n // Sunlight that entered the far side of a wave and scattered back out\r\n // towards the eye - what makes a backlit crest glow. It has to come\r\n // from the light loop: the ambient scattering term below is built from\r\n // the environment irradiance, which has no direction.\r\n //\r\n // Standard translucency approximation - the transmitted direction is\r\n // the light continuing through the surface, bent by the normal, and\r\n // the term peaks when the eye looks back along it.\r\n this.$l.sssDir = pb.normalize(\r\n pb.add(pb.neg(this.lightDir), pb.mul(this.diffuseNormal, SSS_DISTORTION))\r\n );\r\n this.$l.sssFacing = pb.pow(pb.clamp(pb.dot(pb.neg(this.eyeVecNorm), this.sssDir), 0, 1), SSS_POWER);\r\n // Crests glow and troughs do not: height above the undisplaced surface\r\n // stands in for how much lit water the ray passed through. The medium's\r\n // albedo carries the hue; the magnitude is authored.\r\n this.$l.sssThickness = pb.clamp(\r\n pb.mul(pb.sub(1, this.diffuseNormal.y), this.subsurfaceParams.y),\r\n 0,\r\n 1\r\n );\r\n this.$l.subsurfaceTerm = pb.mul(\r\n this.lightEnergy,\r\n this.mediumAlbedo,\r\n pb.mul(this.sssFacing, this.sssThickness, this.subsurfaceParams.x)\r\n );\r\n this.lightContrib = pb.add(this.lightContrib, this.subsurfaceTerm);\r\n // Sunlight scattered back out of the water column, which is what gives\r\n // the body a direction-dependent colour at all.\r\n //\r\n // Directional only, and only with the eye above the surface. The\r\n // integral assumes a parallel beam of fixed slope; a point light's\r\n // falloff along the column and the underwater geometry both need a\r\n // different solution. The refraction and the ambient scattering still\r\n // carry the water colour in those cases.\r\n this.$l.sunScatterTerm = pb.vec3(0);\r\n this.$if(pb.and(pb.equal(type, LIGHT_TYPE_DIRECTIONAL), pb.not(this.underwaterEye)), function () {\r\n // Weighted by what the surface transmits on the way out and by how\r\n // much of it is still water rather than foam, like every other\r\n // term that comes from inside the body.\r\n this.sunScatterTerm = pb.mul(\r\n that.waterSunScattering(\r\n this,\r\n this.lightEnergy,\r\n this.lightDir,\r\n this.eyeVecNorm,\r\n this.NoLdiffuse,\r\n this.depth,\r\n this.foam\r\n ),\r\n this.bodyWeight\r\n );\r\n this.lightContrib = pb.add(this.lightContrib, this.sunScatterTerm);\r\n });\r\n // Foam is a rough dielectric layer, so it takes the light the way any\r\n // matte surface does.\r\n this.lightContrib = pb.add(\r\n this.lightContrib,\r\n pb.mul(this.lightEnergy, this.foamColor, this.foam, this.NoLdiffuse, 1 / Math.PI)\r\n );\r\n this.$l.shadow = pb.vec3(1);\r\n if (shadow) {\r\n // Water is a horizontal clipmap, so +Y is the geometric normal. The\r\n // wave normal would jitter the shadow lookup per-pixel.\r\n this.shadow = pb.vec3(that.calculateShadow(this, this.worldPos, pb.vec3(0, 1, 0), this.NoL));\r\n this.dbgShadow = this.shadow;\r\n this.lightContrib = pb.mul(this.lightContrib, this.shadow);\r\n }\r\n this.finalColor = pb.add(this.finalColor, this.lightContrib);\r\n this.dbgSpecular = pb.add(this.dbgSpecular, pb.mul(this.specularTerm, this.shadow));\r\n this.dbgSubsurface = pb.add(this.dbgSubsurface, pb.mul(this.subsurfaceTerm, this.shadow));\r\n this.dbgSunScatter = pb.add(this.dbgSunScatter, pb.mul(this.sunScatterTerm, this.shadow));\r\n });\r\n if (that.needCalculateEnvLight()) {\r\n this.$l.irradiance = that.getEnvLightIrradiance(this, this.diffuseNormal);\r\n // Scattering from the water body itself, and from the foam sitting on\r\n // it. `bodyWeight` is what the surface transmits on the way out times\r\n // the share of it that is still water.\r\n //\r\n // On the same path length the absorption uses, so this vanishes from\r\n // below: the column the eye is already inside belongs to the\r\n // Underwater pass, and adding the surface's own estimate of it on top\r\n // paints the water colour twice. The foam term below is unconditional\r\n // - a crest that has broken is white from underneath too.\r\n this.$l.sss = pb.mul(\r\n this.getScattering(this.mediumPath),\r\n this.irradiance,\r\n this.bodyWeight,\r\n 1 / Math.PI\r\n );\r\n this.finalColor = pb.add(this.finalColor, this.sss);\r\n this.dbgScatter = this.sss;\r\n this.finalColor = pb.add(\r\n this.finalColor,\r\n pb.mul(this.irradiance, this.foamColor, this.foam, 1 / Math.PI)\r\n );\r\n }\r\n switch (debugOutput) {\r\n case 'normal':\r\n this.$return(pb.add(pb.mul(this.normal, 0.5), pb.vec3(0.5)));\r\n break;\r\n case 'diffuseNormal':\r\n this.$return(pb.add(pb.mul(this.diffuseNormal, 0.5), pb.vec3(0.5)));\r\n break;\r\n case 'frontFacing':\r\n this.$return(this.$choice(this.$builtins.frontFacing, pb.vec3(1), pb.vec3(0)));\r\n break;\r\n case 'viewFacing': {\r\n // Raw, not clamped: a negative value means the wave normal faces\r\n // away from the eye at that pixel.\r\n this.$l.viewFacing = pb.dot(this.normal, pb.neg(this.eyeVecNorm));\r\n this.$return(pb.vec3(this.viewFacing));\r\n break;\r\n }\r\n case 'foam':\r\n this.$return(pb.vec3(this.foam));\r\n break;\r\n case 'shoreFoam':\r\n this.$return(pb.vec3(this.shoreFoam));\r\n break;\r\n case 'waterDepth':\r\n // Distance from the surface to whatever is behind it, metres / 10.\r\n // With the band switched off there is no such estimate, so the plain\r\n // height difference stands in.\r\n this.$return(\r\n pb.vec3(\r\n pb.mul(\r\n shoreFoam ? this.shoreFoamInfo.y : pb.max(pb.sub(this.worldPos.y, this.wPos.y), 0),\r\n 0.1\r\n )\r\n )\r\n );\r\n break;\r\n case 'fresnel':\r\n this.$return(pb.vec3(this.fresnelTerm));\r\n break;\r\n case 'reflection':\r\n this.$return(this.reflectance);\r\n break;\r\n case 'refraction':\r\n this.$return(this.refractionRaw);\r\n break;\r\n case 'absorption':\r\n this.$return(this.absorption);\r\n break;\r\n case 'scattering':\r\n this.$return(this.dbgScatter);\r\n break;\r\n case 'sunScattering':\r\n this.$return(this.dbgSunScatter);\r\n break;\r\n case 'sunNoL':\r\n this.$return(pb.vec3(pb.clamp(this.dbgNoL, 0, 1)));\r\n break;\r\n case 'shadow':\r\n this.$return(this.dbgShadow);\r\n break;\r\n case 'sunPhase': {\r\n // Recomputed from the same inputs rather than read back out of\r\n // waterSunScattering: the value belongs to that function's scope, and\r\n // the variant that wants it is the one that never calls it. Keep the\r\n // two expressions in step.\r\n this.$l.dbgLw = pb.refract(pb.neg(this.dbgLightDir), pb.vec3(0, 1, 0), 1 / 1.333);\r\n this.$l.dbgVw = pb.refract(this.eyeVecNorm, pb.vec3(0, 1, 0), 1 / 1.333);\r\n this.$l.dbgCosTheta = pb.neg(pb.dot(this.dbgLw, this.dbgVw));\r\n this.$l.dbgHg = waterScatterPhase(this, this.dbgCosTheta, this.sunScatterParams.y);\r\n this.$l.dbgLumWeights = pb.vec3(0.2126, 0.7152, 0.0722);\r\n this.$l.dbgThickness = pb.mul(\r\n pb.dot(this.mediumAlbedo, this.dbgLumWeights),\r\n pb.sub(1, pb.exp(pb.neg(pb.mul(pb.dot(this.mediumExtinction, this.dbgLumWeights), this.depth))))\r\n );\r\n this.$return(\r\n pb.vec3(\r\n pb.clamp(\r\n pb.mix(\r\n this.dbgHg,\r\n 1 / (4 * Math.PI),\r\n pb.smoothStep(0, 0.5, pb.clamp(this.dbgThickness, 0, 1))\r\n ),\r\n 0,\r\n 1\r\n )\r\n )\r\n );\r\n break;\r\n }\r\n case 'sunIntegral': {\r\n this.$l.dbgVy = pb.max(pb.neg(pb.refract(this.eyeVecNorm, pb.vec3(0, 1, 0), 1 / 1.333).y), 1e-3);\r\n this.$l.dbgSy = pb.max(\r\n pb.neg(pb.refract(pb.neg(this.dbgLightDir), pb.vec3(0, 1, 0), 1 / 1.333).y),\r\n 0.05\r\n );\r\n this.$l.dbgRr = pb.add(1, pb.div(this.dbgVy, this.dbgSy));\r\n this.$l.dbgIntegral = pb.div(\r\n pb.sub(\r\n pb.vec3(1),\r\n pb.exp(pb.neg(pb.mul(pb.mul(this.mediumExtinction, this.dbgRr), this.depth)))\r\n ),\r\n this.dbgRr\r\n );\r\n this.$return(pb.vec3(pb.clamp(pb.length(this.dbgIntegral), 0, 1)));\r\n break;\r\n }\r\n case 'subsurface':\r\n this.$return(this.dbgSubsurface);\r\n break;\r\n case 'specular':\r\n this.$return(this.dbgSpecular);\r\n break;\r\n case 'depth':\r\n this.$return(pb.vec3(pb.mul(this.depth, 0.1)));\r\n break;\r\n case 'refractUV':\r\n this.$return(\r\n pb.vec3(pb.add(pb.mul(pb.sub(this.refractUV, this.screenUV), 4), pb.vec2(0.5)), 0.5)\r\n );\r\n break;\r\n case 'nan': {\r\n // NaN is the only value that fails x == x. The normal is checked\r\n // separately from the colour so a NaN that a clamp downstream\r\n // swallowed still shows.\r\n this.$l.sum = pb.add(pb.dot(this.finalColor, pb.vec3(1)), pb.dot(this.normal, pb.vec3(1)));\r\n this.$l.bad = pb.or(pb.notEqual(this.sum, this.sum), pb.greaterThan(pb.abs(this.sum), 1e30));\r\n this.$return(this.$choice(this.bad, pb.vec3(1, 0, 0), pb.vec3(0)));\r\n break;\r\n }\r\n default:\r\n this.$return(this.finalColor);\r\n }\r\n }\r\n );\r\n return scope.waterShading(worldPos, worldNormal, foamFactor);\r\n }\r\n applyUniforms(bindGroup: BindGroup, ctx: DrawContext, needUpdate: boolean, pass: number) {\r\n super.applyUniforms(bindGroup, ctx, needUpdate, pass);\r\n const waveGenerator = this._waveGenerator.get();\r\n // Synced per bind group, not per material: the material owns one bind group\r\n // per pass/render-variant hash, so drawing for a second camera reuses a\r\n // different group whose wave uniforms were never written. WeakMap so a\r\n // released group is garbage collected with its entry.\r\n const lastWritten = this._waveVersionByBindGroup.get(bindGroup) ?? -1;\r\n if (waveGenerator && lastWritten !== waveGenerator.version) {\r\n waveGenerator.applyWaterBindGroup(bindGroup);\r\n this._waveVersionByBindGroup.set(bindGroup, waveGenerator.version);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n bindGroup.setValue('clipmapGridInfo', this._clipmapGridInfo);\r\n if (this.infinite) {\r\n bindGroup.setValue('skirtDistance', this._skirtDistance);\r\n } else {\r\n bindGroup.setValue('region', this._region);\r\n }\r\n if (this.needFragmentColor(ctx)) {\r\n // Dimensionless: the offset is derived in world space and projected, so\r\n // there is nothing here for the render size to scale.\r\n bindGroup.setValue('refractionScale', this._refractionScale);\r\n if (this.refractionMode === 'offset') {\r\n bindGroup.setValue('cheapRefractionDepth', this._cheapRefractionDepth);\r\n }\r\n bindGroup.setValue('reflectionStrength', this._reflectionStrength);\r\n bindGroup.setValue('ssrParams', this._ssrParams);\r\n this._subsurfaceParams.setXYZW(this._subsurfaceIntensity, this._subsurfaceSteepness, 0, 0);\r\n bindGroup.setValue('subsurfaceParams', this._subsurfaceParams);\r\n this._foamParams.setXYZW(this._foamAmount, this._foamFalloff, 0, 0);\r\n bindGroup.setValue('foamShadingParams', this._foamParams);\r\n bindGroup.setValue('foamColor', this._foamColor);\r\n if (this._shoreFoamEnabled) {\r\n this._shoreFoamParams.setXYZW(\r\n this._shoreFoamAmount,\r\n this._shoreFoamDepth,\r\n this._shoreFoamFalloff,\r\n // Cycles per metre, resolved from cycles per band width.\r\n this._shoreFoamScale / this._shoreFoamDepth\r\n );\r\n bindGroup.setValue('shoreFoamParams', this._shoreFoamParams);\r\n this._shoreFoamWashParams.setXYZW(\r\n this._shoreFoamWashAmount,\r\n this._shoreFoamWashSpeed,\r\n this._shoreFoamWashScale,\r\n // Query radius: the band's widest reach over the run-up cycle. Fixed\r\n // over the cycle because it sets the pyramid level the query samples,\r\n // and a level moving with the wash would step the band's resolution.\r\n this._shoreFoamDepth * (1 + this._shoreFoamWashAmount)\r\n );\r\n bindGroup.setValue('shoreFoamWashParams', this._shoreFoamWashParams);\r\n }\r\n bindGroup.setValue('mediumAlbedo', this._scatterAlbedo);\r\n // Needed in both medium modes: the sun-scattering integral is always\r\n // physical, even where the ramp overrides the depth-driven absorption.\r\n bindGroup.setValue('mediumExtinction', this._extinction);\r\n this._sunScatterParams.setXYZW(this._sunScatteringIntensity, this._scatterAnisotropy, 0, 0);\r\n bindGroup.setValue('sunScatterParams', this._sunScatterParams);\r\n // One LOD serves all three channels, so the per-channel scattering has to\r\n // collapse to a scalar. Luminance-weighted rather than a plain mean: the\r\n // blur is a perceptual effect and green carries most of what is seen.\r\n bindGroup.setValue(\r\n 'refractBlurDensity',\r\n (0.2126 * this._scattering.x + 0.7152 * this._scattering.y + 0.0722 * this._scattering.z) *\r\n this._scatteringScale *\r\n REFRACT_BLUR_DENSITY *\r\n this._refractionBlur\r\n );\r\n if (this.mediumMode === 'ramp') {\r\n bindGroup.setValue('depthMulti', this._depthMulti);\r\n bindGroup.setTexture(\r\n 'scatterRampTex',\r\n this._getScatterRampTexture(ctx.device),\r\n fetchSampler('clamp_linear_nomip')\r\n );\r\n bindGroup.setTexture(\r\n 'absorptionRampTex',\r\n this._getAbsorptionRampTexture(ctx.device),\r\n fetchSampler('clamp_linear_nomip')\r\n );\r\n }\r\n }\r\n if (this.waveGenerator) {\r\n this.waveGenerator.applyWaterBindGroup(bindGroup);\r\n }\r\n }\r\n needUpdate() {\r\n return !!this._waveGenerator.get()?.needUpdate();\r\n }\r\n update(frameId: number, elapsed: number) {\r\n const waveGenerator = this._waveGenerator.get();\r\n if (waveGenerator) {\r\n const updateFrameId = WaterMaterial._waveUpdateState.get(waveGenerator);\r\n if (updateFrameId !== frameId) {\r\n waveGenerator.update(elapsed);\r\n WaterMaterial._waveUpdateState.set(waveGenerator, frameId);\r\n }\r\n }\r\n }\r\n private _getRampTexture(device: AbstractDevice, grad: Interpolator) {\r\n const width = 128;\r\n const height = 1;\r\n const texture = device.createTexture2D('rgba8unorm', width, height, {\r\n mipmapping: false\r\n })!;\r\n const numTexels = width * height;\r\n const data = new Uint8Array(numTexels * 4);\r\n const tmpcolor = new Vector3();\r\n for (let i = 0; i < numTexels; i++) {\r\n grad.interpolate((i % width) / width, tmpcolor);\r\n data[i * 4 + 0] = (tmpcolor.x * 255) >> 0;\r\n data[i * 4 + 1] = (tmpcolor.y * 255) >> 0;\r\n data[i * 4 + 2] = (tmpcolor.z * 255) >> 0;\r\n data[i * 4 + 3] = 255;\r\n }\r\n texture.update(data, 0, 0, width, height);\r\n return texture;\r\n }\r\n private _getScatterRampTexture(device: AbstractDevice) {\r\n if (!this._scatterRampTexture.get()) {\r\n if (!WaterMaterial._defaultScatterRampTexture.get()) {\r\n WaterMaterial._defaultScatterRampTexture.set(\r\n this._getRampTexture(device, WaterMaterial._scatterGrad)\r\n );\r\n }\r\n this._scatterRampTexture.set(WaterMaterial._defaultScatterRampTexture.get());\r\n }\r\n return this._scatterRampTexture.get()!;\r\n }\r\n private _getAbsorptionRampTexture(device: AbstractDevice) {\r\n if (!this._absorptionRampTexture.get()) {\r\n if (!WaterMaterial._defaultAbsorptionRampTexture.get()) {\r\n WaterMaterial._defaultAbsorptionRampTexture.set(\r\n this._getRampTexture(device, WaterMaterial._absorptionGrad)\r\n );\r\n }\r\n this._absorptionRampTexture.set(WaterMaterial._defaultAbsorptionRampTexture.get());\r\n }\r\n return this._absorptionRampTexture.get()!;\r\n }\r\n}\r\n"],"names":["WATER_DEBUG_OUTPUTS","label","value","WATER_F0","WATER_BASE_ROUGHNESS","WATER_DISTANT_ROUGHNESS","WATER_IOR","AIR_TO_WATER_ETA","WATER_TO_AIR_ETA","REFRACT_MAX_PATH_RATIO","REFRACT_MARCH_STEPS","REFRACT_MARCH_THICKNESS","INFINITE_DEPTH_PULLIN","HORIZON_REFLECT_BIAS","REFRACT_EDGE_FADE","SCENE_SKY_DEPTH01","SSS_DISTORTION","SSS_POWER","DEFAULT_SCATTER_ANISOTROPY","MIN_SUN_SLOPE","REFRACT_BLUR_GEOMETRIC","REFRACT_BLUR_DENSITY","REFRACT_BLUR_MAX_LOD","SHORE_FOAM_NOISE_BITE","SHORE_FOAM_DRIFT_X","SHORE_FOAM_DRIFT_Z","SHORE_FOAM_OCTAVE_RATIO","SHORE_FOAM_OCTAVE_WEIGHTS","SHORE_FOAM_EDGE_SOFTNESS","SHORE_QUERY_TAP_SPREAD","SHORE_QUERY_SOFTMIN","SHORE_QUERY_MISS_REACH","SHORE_QUERY_DITHER_STRIDE","SHORE_QUERY_CELL_DEPTH_SPAN","WaterMaterial","applyMaterialMixins","MeshMaterial","mixinLight","FEATURE_MEDIUM_MODE","defineFeature","FEATURE_REFRACTION_MODE","FEATURE_INFINITE","FEATURE_SHORE_FOAM","FEATURE_DEBUG_OUTPUT","_absorptionGrad","Interpolator","Float32Array","_scatterGrad","_defaultScatterRampTexture","DWeakRef","_defaultAbsorptionRampTexture","_waveUpdateState","WeakMap","_region","_refractionScale","_depthMulti","_reflectionStrength","_scatterRampTexture","_absorptionRampTexture","_waveGenerator","_clipmapInfo","_clipmapGridInfo","_skirtDistance","_ssrParams","_causticsEnabled","_causticsIntensity","_causticsDepth","_causticsRange","_causticsFadeDistance","_causticsWarp","_causticsSceneDepth","_causticsDefocus","_causticsResolution","_causticsPhotonResolution","_causticsBlurPasses","_causticsTemporalStrength","_underwaterEnabled","_underwaterAmbientIntensity","_underwaterGodRays","_underwaterGodRayIntensity","_underwaterGodRaySteps","_underwaterGodRayShadow","_underwaterHysteresis","_subsurfaceIntensity","_subsurfaceSteepness","_subsurfaceParams","_sunScatteringIntensity","_scatterAnisotropy","_sunScatterParams","_refractionBlur","_cheapRefractionDepth","_foamAmount","_foamFalloff","_foamColor","_foamParams","_shoreFoamAmount","_shoreFoamDepth","_shoreFoamFalloff","_shoreFoamScale","_shoreFoamWashAmount","_shoreFoamWashSpeed","_shoreFoamWashScale","_shoreFoamParams","_shoreFoamWashParams","Vector4","_absorption","Vector3","_scattering","_extinction","_scatterAlbedo","_absorptionScale","_scatteringScale","_updateMediumCoefficients","DRef","_waveVersionByBindGroup","cullMode","useFeature","onDispose","dispose","region","val","equalsTo","set","uniformChanged","waveGenerator","get","optionChanged","scatterRampTexture","tex","_getScatterRampTexture","getDevice","absorptionRampTexture","_getAbsorptionRampTexture","mediumMode","featureUsed","refractionMode","debugOutput","infinite","absorption","absorptionScale","scattering","scatteringScale","extinction","scatterAlbedo","underwaterEnabled","underwaterAmbientIntensity","Math","max","underwaterGodRays","underwaterGodRayIntensity","underwaterGodRaySteps","floor","underwaterGodRayShadow","underwaterHysteresis","causticsEnabled","causticsIntensity","causticsDepth","causticsRange","causticsFadeDistance","causticsSceneDepth","causticsWarp","min","causticsDefocus","causticsResolution","causticsPhotonResolution","n","causticsBlurPasses","clamped","causticsTemporalStrength","subsurfaceIntensity","subsurfaceSteepness","sunScatteringIntensity","cheapRefractionDepth","refractionBlur","scatterAnisotropy","foamAmount","foamFalloff","foamColor","shoreFoamAmount","wasEnabled","type","shoreFoamDepth","shoreFoamFalloff","shoreFoamScale","shoreFoamWashAmount","shoreFoamWashSpeed","shoreFoamWashScale","_shoreFoamEnabled","_shoreFoamAvailable","scope","ShaderHelper","getHiZDepthTexture","setXYZ","x","y","z","depthMulti","refractionScale","reflectionStrength","needSceneColor","needSceneDepth","needHiZNearest","_createHash","getHash","setClipmapInfo","rotation","scale","offsetX","offsetY","setXYZW","setClipmapGridInfo","gridScale","gridOffsetX","gridOffsetY","setSkirtDistance","distance","supportInstancing","supportLighting","receivesWaterCaustics","vertexShader","pb","$builder","setupUniforms","$inputs","position","vec3","attrib","clipmapInfo","vec4","clipmapGridInfo","uniform","skirtDistance","float","$l","s","sin","c","cos","scale2","mul","clipmapMatrix","mat4","neg","sub","w","clipmapPos","xy","clipmapWorldPos","getWorldMatrix","xyz","worldNormal","worldPos","that","skirt","step","$if","greaterThan","camXZ","getCameraPosition","xz","outDir","normalize","outXZ","add","$else","calcVertexPositionAndNormal","$outputs","camPos","viewVec","viewDist","length","maxDist","getCameraParams","pullIn","div","projPos","setClipSpacePosition","getViewProjectionMatrix","resolveMotionVector","fragmentShader","needFragmentColor","ssrParams","subsurfaceParams","foamShadingParams","shoreFoamParams","shoreFoamWashParams","sunScatterParams","refractBlurDensity","mediumAlbedo","mediumExtinction","scatterRampTex","tex2D","absorptionRampTex","discardable","or","any","lessThan","zw","discard","normal","calcFragmentNormalAndFoam","mix","outColor","waterShading","drawContext","materialFlags","MaterialVaryingFlags","SCENE_STORE_ROUGHNESS","SCENE_STORE_NORMAL","outRoughness","waterRoughness","outputFragmentColor","func","dist","normalScale","clamp","$return","waterRefraction","eyeVecNorm","screenUV","surfaceViewZ","straightDepth01","straightWorldPos","straightDist","march","h","vec2","uv","waterRefractProjectUV","hitPos","uvBase","edge","waterRefractUV","refractDir","t","linearDepth","sampleLinearDepth","getLinearDepthTexture","sceneViewZ","cameraFar","rayViewZ","maxPath","tPrev","gapPrev","hitUV","hitPath","basePath","$for","refractStepZ","waterRefractStep","gap","abs","k","$break","underwater","not","$builtins","frontFacing","faceNormal","$choice","eta","greaterThanEqual","waterCrossDir","refractWave","refract","refractFlatNormal","sign","refractFlat","dot","refractUV","refractPath","refractDirView","getViewMatrix","marchResult","waterRefractMarch","sceneHit","samplePositionFromDepth","getInvViewProjectionMatrix","and","waterSunScattering","lightEnergy","lightDir","NoL","depth","foam","up","Lw","Vw","sy","vy","r","rr","cosTheta","hg","waterScatterPhase","lumWeights","extLum","albedoLum","thickness","exp","phase","PI","smoothStep","integral","entry","pow","foamFactor","ramp","shoreFoam","textureSampleLevel","rgb","bool","NoV","eyeVec","sinT2","f","cosT","sqrt","f0","f90","L","V","halfVec","NoH","specular","VoH","F","fresnelSchlick","alphaRoughness","roughness","D","distributionGGX","VIS","visGGX","lightColor","p","time","valueNoise","renderSize","getRenderSize","projMatrix","getProjectionMatrix","viewPos","pixelRadius","radius","level","log2","getHiZDepthTextureMipLevelCount","mipSize","exp2","texelStep","dither","getFramestamp","gridCoord","gridBase","gridFrac","softK","dMax","esum","wsum","gy","gx","nonLinearDepthToLinear","g","interleavedGradientNoise","fragCoord","log","getElapsedTime","surfaceDist","waterShoreProximity","washOffset","wash","soft","lessThanEqual","pattern","waterShoreFoamPattern","coverage","wPos","shadingNormal","diffuseWeight","diffuseNormal","frontFace","backFace","underwaterEye","incidentVec","reflectVecW","reflect","reflectance","hitInfo","reflectVec","screenSpaceRayTracing_HiZ","getInvProjectionMatrix","int","getHiZDepthTextureSize","screenSpaceRayTracing_Linear2D","getLinearDepthTextureSize","refl","reflMiss","downwelling","sampleBakedSkyPreExposed","getSceneColorTexture","refractInfo","mediumPath","refractBlur","refraction","refractionRaw","getAbsorption","fresnelTerm","fresnel","crestFoam","shoreFoamInfo","waterShoreFoam","finalColor","dbgSpecular","dbgNoL","dbgShadow","dbgSubsurface","dbgSunScatter","dbgScatter","bodyWeight","dbgLightDir","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","lightAtten","calculateLightAttenuation","calculateLightDirection","NoLdiffuse","a","specularTerm","lightSpecular","lightContrib","sssDir","sssFacing","sssThickness","subsurfaceTerm","sunScatterTerm","equal","LIGHT_TYPE_DIRECTIONAL","calculateShadow","needCalculateEnvLight","irradiance","getEnvLightIrradiance","sss","getScattering","viewFacing","dbgLw","dbgVw","dbgCosTheta","dbgHg","dbgLumWeights","dbgThickness","dbgVy","dbgSy","dbgRr","dbgIntegral","sum","bad","notEqual","applyUniforms","bindGroup","ctx","needUpdate","pass","lastWritten","version","applyWaterBindGroup","applyUniformValues","setValue","setTexture","device","fetchSampler","update","frameId","elapsed","updateFrameId","_getRampTexture","grad","width","height","texture","createTexture2D","mipmapping","numTexels","data","Uint8Array","tmpcolor","i","interpolate"],"mappings":";;;;;;;;;;;;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A6B,CAAC2E,GAAG,EAAA,CAAA;AACjF;AACA,QAAA,OAAO,IAAI,CAACnE,sBAAsB,CAACmE,GAAG,EAAA;AACxC;AACF;;;;"}
1
+ {"version":3,"file":"water.js","sources":["../../src/material/water.ts"],"sourcesContent":["import type {\n BindGroup,\n PBFunctionScope,\n PBInsideFunctionScope,\n PBShaderExp,\n Texture2D,\n Texture2DArray\n} from '@zephyr3d/device';\nimport { applyMaterialMixins, MeshMaterial } from './meshmaterial';\nimport type { DrawContext, WaveGenerator } from '../render';\nimport type { WaterInteraction } from '../render/water_interaction';\nimport { InteractiveWaveGenerator } from '../render/water_interaction';\nimport { ShoreWaveGenerator } from '../render/shore_wave_generator';\nimport type { ShoreWaveSettings } from '../render/shore_wave_generator';\nimport { FoamFieldWaveGenerator, WaterFoamField, WaveFoamSource } from '../render/water_foam';\nimport type { FoamFieldSource } from '../render/water_foam';\nimport { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_RECT, MaterialVaryingFlags } from '../values';\nimport { ShaderHelper } from './shader/helper';\nimport type { Nullable } from '@zephyr3d/base';\nimport { DRef, Vector3, Vector4 } from '@zephyr3d/base';\nimport { screenSpaceRayTracing_HiZ, screenSpaceRayTracing_Linear2D } from '../shaders/ssr';\nimport { fetchSampler } from '../utility/misc';\nimport { PHYSICAL_BAKE_EXPOSURE } from '../utility/physical';\nimport { mixinLight } from './mixins/lit';\nimport { distributionGGX, fresnelSchlick, visGGX } from '../shaders/pbr';\nimport { waterScatterPhase } from '../shaders/water_medium';\nimport { evaluateLTCRectLightTerms } from '../shaders/ltc_rect';\nimport { getLTCAmpLUT, getLTCMatLUT } from '../utility/textures/ltclut';\nimport { foamTexelSize, getDefaultFoamTexture, sampleFoamTexture } from '../utility/textures/foam';\nimport { RenderGraphExecutor } from '../render/rendergraph/executor';\n\n/**\n * How the refracted view sample is located.\n *\n * - `march`: walk the refracted ray against the scene depth buffer and sample at\n * the first crossing, at the cost of {@link REFRACT_MARCH_STEPS} depth fetches\n * per water pixel.\n * - `offset`: displace the screen UV by the refraction of the wave normal alone,\n * with no search. Much cheaper, but the sample does not land where the ray\n * actually goes and the medium tint uses the straight-line distance.\n *\n * The two agree on calm water viewed from above and diverge with wave steepness\n * and view angle.\n *\n * @public\n */\nexport type WaterRefractionMode = 'march' | 'offset';\n\n/**\n * Debug view of the water shading, replacing the final colour with one of its\n * intermediate terms.\n *\n * - `none`: normal shading.\n * - `normal`: wave normal, remapped to [0,1].\n * - `foam`: foam coverage after the amount/falloff ramp, as grey.\n * - `waterDepth`: height of the surface above the scene point behind it, in\n * metres / 10, as grey.\n * - `fresnel`: reflection weight after foam suppression, as grey.\n * - `reflection`: what the surface reflects (SSR blended over the sky).\n * - `refraction`: the scene sample behind the water, before the medium tint.\n * - `absorption`: medium transmittance over the refracted path.\n * - `scattering`: ambient in-scattering from the water body.\n * - `sunScattering`: directional in-scattering from the lights.\n * - `subsurface`: the backlit-crest translucency term.\n * - `subsurfaceThickness`: the crest gate that term is scaled by, bright on\n * crests and absorbed in troughs. Independent of the lights.\n * - `shadow`: the lights' shadow factor on the surface, as grey; white with\n * no shadowed light.\n * - `specular`: the lights' mirror highlights, shadowed, with nothing else.\n * - `depth`: refracted path length through the medium, metres / 10.\n * - `interaction`: the {@link WaterInteraction} field on its own, mid grey at\n * rest and reaching black and white at its amplitude clamp; dimmed outside\n * the field's window.\n * - `foamField`: the foam field on its own, its density as grey, black with no\n * foam; mid grey off the field, where foam does not linger.\n * - `shoreRegions`: raw carrier geometry, without wet-edge clipping or ground\n * projection. Blue is the base water, cyan the offshore shore-wave region,\n * orange the wet inland swash and magenta its dry support. Smooth colour\n * transitions show the shore-wave envelope, not separate meshes.\n * - `shoreLevels`: which level of the shore field answers, red, green, blue\n * and yellow from the finest, blended where levels hand over and darkening\n * towards the edge of the coarsest; bands every 2 metres of the distance to\n * the waterline, which should run on unbroken across the handovers. Dark grey\n * off the field.\n * - `swashHandover`: red is carrier wet coverage, green is reconstructed\n * ground wet coverage and blue is the ground-foam replacement weight.\n * Magenta identifies wet carrier pixels being replaced by dry ground.\n * - `swashFoamSources`: red is carrier foam density, green is wet ground\n * field density and blue is the surf's foam on the wet ground, before\n * texture cutting.\n * - `swashFoamCuts`: red is surface foam opacity, green is ground foam\n * opacity and blue is the ground replacement weight, after texture cutting.\n * - `swashVisibility`: reveals discarded beach fragments in red and fragments\n * whose selected depth lies behind the opaque surface in green. Blue is the\n * projected ground foam density. Bypasses wet clipping and uses ground depth on\n * valid beach pixels so otherwise invisible fragments can be inspected.\n *\n * - `swashGroundSupport`: red is the beach-bed mask, green the foam-field\n * coverage and blue the wet ground coverage. Like `swashVisibility`, reveals\n * clipped fragments at the ground depth to inspect the handover's support.\n *\n * Each value is a separate shader variant; the `none` variant carries no trace\n * of the others.\n *\n * @public\n */\nexport type WaterDebugOutput =\n | 'none'\n | 'normal'\n | 'foam'\n | 'waterDepth'\n | 'fresnel'\n | 'reflection'\n | 'refraction'\n | 'absorption'\n | 'scattering'\n | 'sunScattering'\n | 'subsurface'\n | 'subsurfaceThickness'\n | 'shadow'\n | 'specular'\n | 'depth'\n | 'interaction'\n | 'foamField'\n | 'shoreRegions'\n | 'shoreLevels'\n | 'swashHandover'\n | 'swashFoamSources'\n | 'swashFoamCuts'\n | 'swashVisibility'\n | 'swashGroundSupport';\n\n/** Label/value pairs for {@link WaterDebugOutput}, for editor enumerations. */\nexport const WATER_DEBUG_OUTPUTS = [\n { label: 'None', value: 'none' },\n { label: 'Normal', value: 'normal' },\n { label: 'Foam', value: 'foam' },\n { label: 'Water depth', value: 'waterDepth' },\n { label: 'Fresnel', value: 'fresnel' },\n { label: 'Reflection', value: 'reflection' },\n { label: 'Refraction', value: 'refraction' },\n { label: 'Absorption', value: 'absorption' },\n { label: 'Scattering', value: 'scattering' },\n { label: 'Sun scattering', value: 'sunScattering' },\n { label: 'Shadow', value: 'shadow' },\n { label: 'Subsurface', value: 'subsurface' },\n { label: 'Subsurface thickness', value: 'subsurfaceThickness' },\n { label: 'Specular', value: 'specular' },\n { label: 'Depth', value: 'depth' },\n { label: 'Interaction', value: 'interaction' },\n { label: 'Foam field', value: 'foamField' },\n { label: 'Shore regions (geometry)', value: 'shoreRegions' },\n { label: 'Shore field levels', value: 'shoreLevels' },\n { label: 'Swash handover (RGB)', value: 'swashHandover' },\n { label: 'Swash foam sources (RGB)', value: 'swashFoamSources' },\n { label: 'Swash foam cuts (RGB)', value: 'swashFoamCuts' },\n { label: 'Swash visibility (RGB)', value: 'swashVisibility' },\n { label: 'Swash ground support (RGB)', value: 'swashGroundSupport' }\n] as const;\n\n/** Fresnel reflectance of water at normal incidence, n = 1.333. */\nconst WATER_F0 = 0.02;\n/** Specular roughness with the waves resolved. */\nconst WATER_BASE_ROUGHNESS = 0.04;\n/** Specular roughness once distance has flattened the wave normals. */\nconst WATER_DISTANT_ROUGHNESS = 0.35;\n/**\n * Slope variance of a wind-driven sea for the mean Fresnel of the slopes\n * distance flattens out of the normals, from the clean-surface fit of Cox &\n * Munk, \"Measurement of the roughness of the sea surface from photographs of\n * the sun's glitter\" (JOSA 44(11), 1954): upwind sigma_u^2 = 3.16e-3 U and\n * crosswind sigma_c^2 = 0.003 + 1.92e-3 U, U the wind speed in m/s.\n */\nconst COX_MUNK_UPWIND = 3.16e-3;\nconst COX_MUNK_CROSSWIND_BASE = 0.003;\nconst COX_MUNK_CROSSWIND = 1.92e-3;\n/**\n * Roughness over which the sky reflection hands over from the sharp baked sky\n * to the environment's GGX-prefiltered radiance map, as Crest picks its\n * reflection mip by roughness.\n */\nconst SKY_PREFILTER_START = 0.06;\nconst SKY_PREFILTER_FULL = 0.15;\n/** Wrap of the foam's diffuse lighting, `(N.L + w) / (1 + w)`. At 0 a lee slope is unlit. */\nconst FOAM_LIGHT_WRAP = 0.5;\n/**\n * Share of the edge fade width over which the foam on a thin sheet fades: the\n * foam outlasts the water it floats on, down to the last centimetre or so.\n */\nconst FOAM_EDGE_FADE_SHARE = 0.2;\n/** Index of refraction of water. Must match the caustics pass. */\nconst WATER_IOR = 1.333;\nconst AIR_TO_WATER_ETA = 1 / WATER_IOR;\nconst WATER_TO_AIR_ETA = WATER_IOR;\n/** Cap on the refracted path, as a multiple of the straight-line distance. */\nconst REFRACT_MAX_PATH_RATIO = 4;\n/** Steps of the refracted-ray march over {@link REFRACT_MAX_PATH_RATIO}. */\nconst REFRACT_MARCH_STEPS = 24;\n/** Depth tolerance, in meters, for a march step to count as a hit. */\nconst REFRACT_MARCH_THICKNESS = 0.05;\n/**\n * Fraction of the far plane an infinite surface is pulled in to. Must stay\n * below 1: the cleared depth value is tested for by equality.\n */\nconst INFINITE_DEPTH_PULLIN = 0.99;\n/** Minimum reflection y for the sky bake lookup; its lower hemisphere is black. */\nconst HORIZON_REFLECT_BIAS = 0.08;\n/** UV width of the band the refraction offset fades over at the screen border. */\nconst REFRACT_EDGE_FADE = 0.06;\n/** Normalized depth at or above which the scene behind the water is sky. */\nconst SCENE_SKY_DEPTH01 = 0.999;\n/** Medium path, in meters, through water with only sky behind it: deep enough to absorb everything. */\nconst SKY_MEDIUM_PATH = 1e4;\n/** Floor on the subsurface term's sun-alignment factor. */\nconst SSS_SUN_ALIGN_FLOOR = 0.15;\n/** Floor on the subsurface term's grazing-view factor. */\nconst SSS_GRAZING_FLOOR = 0.1;\n/** Softplus width of the crest gate, as a fraction of the crest height. */\nconst SSS_HEIGHT_SOFTNESS = 0.6;\n/** Least crest height the gate is worked out over, in metres. See {@link WaterMaterial.subsurfaceCrestHeight}. */\nconst SSS_CREST_HEIGHT_MIN = 0.05;\n/** Floor on the crest gate's path length. */\nconst SSS_CREST_PATH_FLOOR = 0.2;\n/** Extinction multiplier of the crest gate over a unit path. */\nconst SSS_ABSORPTION_SCALE = 3;\n/**\n * Mean cosine of one scattering event. Real sea water is near 0.9, at which\n * almost nothing returns to a camera looking down.\n */\nexport const DEFAULT_SCATTER_ANISOTROPY = 0.7;\n/** Floor on the refracted sun ray's descent; only reached by a sun below the horizon. */\nconst MIN_SUN_SLOPE = 0.05;\n/** Refraction blur per meter of path from geometry alone, in mip widths. */\nconst REFRACT_BLUR_GEOMETRIC = 0.02;\n/** Maps the scattering coefficient (1/m) onto refraction blur mip widths per meter. */\nconst REFRACT_BLUR_DENSITY = 1.5;\n/** Cap on the refraction blur LOD. */\nexport const REFRACT_BLUR_MAX_LOD = 6;\n/**\n * The foam's look follows Crest's OceanFoam.hlsl (Wave Harmonic, MIT): a\n * white foam layer cut from the foam texture by the foam density with a\n * feathered black point, lit through a normal taken from the slope of that\n * cut over a step of a quarter texel per metre of view depth, with a narrow\n * glint; and beneath it bubbles, the same texture blurred three mips and\n * shifted by parallax as if under the surface, tinted and lit by the sky.\n * The texture drifts at FOAM_DRIFT metres per second along x and z, Crest's\n * time / 10.\n */\nconst FOAM_DRIFT = 0.1;\nconst FOAM_BUBBLE_MIP_SCALE = 8;\nconst FOAM_SPECULAR_POWER = 293;\nconst FOAM_SPECULAR_BOOST = 0.15;\n\nexport class WaterMaterial extends applyMaterialMixins(MeshMaterial, mixinLight) {\n private static readonly FEATURE_REFRACTION_MODE = this.defineFeature();\n private static readonly FEATURE_INFINITE = this.defineFeature();\n private static readonly FEATURE_DEBUG_OUTPUT = this.defineFeature();\n private static readonly _waveUpdateState: WeakMap<WaveGenerator, number> = new WeakMap();\n private static readonly _interactionUpdateState: WeakMap<WaterInteraction, number> = new WeakMap();\n private readonly _region: Vector4;\n private _refractionScale: number;\n private _reflectionStrength: number;\n private readonly _waveGenerator: DRef<WaveGenerator>;\n private readonly _interaction: DRef<WaterInteraction>;\n /**\n * The generator the shaders and every other consumer of the surface use: the\n * base generator wrapped with the interaction field while one is attached,\n * the base generator itself otherwise.\n */\n private _effectiveWaveGenerator: Nullable<WaveGenerator>;\n /** Settings of the shore waves, shared by reference with their generator. */\n private readonly _shoreWaves: ShoreWaveSettings = {\n height: 0,\n wavelength: 8,\n period: 6,\n zone: 20,\n sharpness: 0.7,\n lean: 0.5,\n irregularity: 0.6,\n waveFoamStrength: 1,\n waveFoamCoverage: 0.55,\n shorelineFoamMaxDepth: 0.65,\n shorelineFoamStrength: 2,\n wallFoamStrength: 1,\n wallFoamMinSpeed: 0.2,\n wallFoamMaxSpeed: 1.5,\n wallFoamDrift: 0.3,\n surfFoamDuration: 1.5,\n foamSettleDepth: 0.02,\n foamDriftDepth: 0.3,\n settledFoamFade: 0.25\n };\n /** The shore wave layer of the effective generator, while the waves are on. */\n private _shoreWaveGenerator: Nullable<ShoreWaveGenerator> = null;\n /** Foam with memory, carried by the water; kept across rebuilds of the generators. */\n private readonly _foamField = new WaterFoamField();\n /** The foam field layered over the base generator, innermost in the effective generator. */\n private _foamFieldGenerator: Nullable<FoamFieldWaveGenerator> = null;\n /**\n * The interaction layer of the effective generator while a field is attached,\n * wherever it sits in the chain (the shore waves wrap it when they are on).\n */\n private _interactiveWaveGenerator: Nullable<InteractiveWaveGenerator> = null;\n /** What feeds the foam field: the shore waves while they are on, else the open water. */\n private _foamSource: Nullable<FoamFieldSource> = null;\n /** Frame the foam field was last stepped in. */\n private _foamFrameId = -1;\n /** Frame of the last update. */\n private _frameId = 0;\n private _edgeFadeWidth = 0.05;\n /**\n * Thickness in metres over which a thin sheet of water fades in from the\n * ground under it, so swash running up the sand shows the sand through it.\n * 0 disables it.\n */\n get edgeFadeWidth() {\n return this._edgeFadeWidth;\n }\n set edgeFadeWidth(val: number) {\n val = Math.max(0, val);\n if (val !== this._edgeFadeWidth) {\n this._edgeFadeWidth = val;\n this.uniformChanged();\n }\n }\n /** Seconds of water clock at the last update, for the shore waves. */\n private _waveClock = 0;\n /** Wave uniform version last written, per bind group. */\n private _waveVersionByBindGroup: WeakMap<BindGroup, number>;\n private readonly _clipmapInfo: Vector4;\n private readonly _clipmapGridInfo: Vector4;\n private _skirtDistance: number;\n private readonly _ssrParams: Vector4;\n /** (wind direction x, z, Cox-Munk upwind slope variance, crosswind slope variance) */\n private readonly _unresolvedSlope: Vector4;\n /** sigma_a, 1/m, per RGB channel. */\n private readonly _absorption: Vector3;\n /** sigma_s, 1/m, per RGB channel. */\n private readonly _scattering: Vector3;\n /** sigma_t = sigma_a + sigma_s. */\n private readonly _extinction: Vector3;\n /** sigma_s / sigma_t. */\n private readonly _scatterAlbedo: Vector3;\n private _absorptionScale: number;\n private _scatteringScale: number;\n private _causticsEnabled: boolean;\n private _causticsIntensity: number;\n private _causticsDepth: number;\n private _causticsRange: number;\n private _causticsFadeDistance: number;\n private _causticsWarp: number;\n private _causticsMinDepth: number;\n private _causticsSceneDepth: boolean;\n private _causticsDefocus: number;\n private _causticsResolution: number;\n private _causticsPhotonResolution: number;\n private _causticsBlurPasses: number;\n private _causticsTemporalStrength: number;\n private _underwaterEnabled: boolean;\n private _underwaterAmbientIntensity: number;\n private _underwaterGodRays: boolean;\n private _underwaterGodRayIntensity: number;\n private _underwaterGodRaySteps: number;\n private _underwaterGodRayShadow: boolean;\n private _underwaterHysteresis: number;\n private _subsurfaceIntensity: number;\n private _subsurfaceCrestHeight: number;\n private readonly _subsurfaceTint: Vector3;\n private readonly _subsurfaceParams: Vector4;\n private _sunScatteringIntensity: number;\n private _scatterAnisotropy: number;\n private readonly _sunScatterParams: Vector4;\n private _refractionBlur: number;\n private _cheapRefractionDepth: number;\n private _foamAmount: number;\n private _foamFalloff: number;\n private readonly _foamColor: Vector3;\n private readonly _foamParams: Vector4;\n private _foamFeather: number;\n private _foamNormalStrength: number;\n private readonly _foamBubbleColor: Vector3;\n private _foamBubbleCoverage: number;\n private _foamBubbleDepth: number;\n private readonly _foamLookParams: Vector4;\n private readonly _foamTexture: DRef<Texture2D>;\n private _foamTextureSize = 4;\n constructor() {\n super();\n this._region = new Vector4(-99999, -99999, 99999, 99999);\n this._absorption = new Vector3(1.0, 0.25, 0.15);\n this._scattering = new Vector3(0.05, 0.12, 0.18);\n this._extinction = new Vector3();\n this._scatterAlbedo = new Vector3();\n this._absorptionScale = 1;\n this._scatteringScale = 1;\n this._updateMediumCoefficients();\n this._clipmapInfo = new Vector4();\n this._clipmapGridInfo = new Vector4();\n this._skirtDistance = 0;\n this._waveGenerator = new DRef();\n this._interaction = new DRef();\n this._effectiveWaveGenerator = null;\n this._waveVersionByBindGroup = new WeakMap();\n this._ssrParams = new Vector4(1000, 160, 0.5, 2);\n this._unresolvedSlope = new Vector4();\n this._refractionScale = 1;\n this._reflectionStrength = 1;\n this._causticsEnabled = true;\n this._causticsIntensity = 1;\n this._causticsDepth = 4;\n this._causticsRange = 60;\n this._causticsFadeDistance = 0;\n this._causticsWarp = 1.5;\n this._causticsMinDepth = 0.15;\n this._causticsSceneDepth = true;\n this._causticsDefocus = 0.12;\n this._causticsResolution = 1024;\n this._causticsPhotonResolution = 0;\n this._causticsBlurPasses = 2;\n this._causticsTemporalStrength = 0.85;\n this._underwaterEnabled = true;\n this._underwaterAmbientIntensity = 1;\n this._underwaterGodRays = true;\n this._underwaterGodRayIntensity = 1;\n this._underwaterGodRaySteps = 24;\n this._underwaterGodRayShadow = false;\n this._underwaterHysteresis = 0.05;\n this._subsurfaceIntensity = 0.5;\n this._subsurfaceCrestHeight = 1.5;\n this._subsurfaceTint = new Vector3(0.86, 0.98, 0.71);\n this._subsurfaceParams = new Vector4();\n this._sunScatteringIntensity = 1;\n this._scatterAnisotropy = DEFAULT_SCATTER_ANISOTROPY;\n this._sunScatterParams = new Vector4();\n this._refractionBlur = 1;\n this._cheapRefractionDepth = 1;\n this._foamAmount = 1;\n this._foamFalloff = 1.5;\n this._foamColor = new Vector3(0.92, 0.95, 0.97);\n this._foamParams = new Vector4();\n // Crest's defaults\n this._foamFeather = 0.4;\n this._foamNormalStrength = 3.5;\n this._foamBubbleColor = new Vector3(0.64, 0.83, 0.82);\n this._foamBubbleCoverage = 1.68;\n this._foamBubbleDepth = 0.14;\n this._foamLookParams = new Vector4();\n this._foamTexture = new DRef();\n this.cullMode = 'none';\n this.useFeature(WaterMaterial.FEATURE_REFRACTION_MODE, 'march' as WaterRefractionMode);\n this.useFeature(WaterMaterial.FEATURE_INFINITE, false);\n this.useFeature(WaterMaterial.FEATURE_DEBUG_OUTPUT, 'none' as WaterDebugOutput);\n }\n /** {@inheritDoc Material.onDispose} */\n protected onDispose() {\n super.onDispose();\n this._waveGenerator.dispose();\n this._interaction.dispose();\n this._shoreWaveGenerator?.dispose();\n this._shoreWaveGenerator = null;\n this._foamFieldGenerator?.dispose();\n this._foamFieldGenerator = null;\n this._foamSource = null;\n this._interactiveWaveGenerator = null;\n this._foamField.dispose();\n this._effectiveWaveGenerator = null;\n this._foamTexture.dispose();\n }\n /** @internal */\n get region() {\n return this._region;\n }\n /** @internal */\n set region(val: Vector4) {\n if (!val.equalsTo(this._region)) {\n this._region.set(val);\n this.uniformChanged();\n }\n }\n /**\n * The wave generator the surface is evaluated with.\n *\n * While an {@link interaction} is attached this is a wrapper that layers the\n * interaction field over {@link baseWaveGenerator}; every consumer of the\n * surface (the shaders, the surface-point query, the caustics) goes through\n * it and sees one displaced surface. Setting it sets the base generator.\n */\n get waveGenerator() {\n return this._effectiveWaveGenerator;\n }\n set waveGenerator(waveGenerator: Nullable<WaveGenerator>) {\n if (this._waveGenerator.get() !== waveGenerator) {\n this._waveGenerator.set(waveGenerator);\n this._rebuildEffectiveWaveGenerator();\n }\n }\n /** The generator supplying the ambient surface, without any interaction field. */\n get baseWaveGenerator() {\n return this._waveGenerator.get();\n }\n /**\n * Dynamic height field layered over the surface, or null for none. See\n * {@link WaterInteraction}.\n *\n * Ignored, with the base generator used on its own, on a device that cannot\n * host the field.\n */\n get interaction() {\n return this._interaction.get();\n }\n set interaction(val: Nullable<WaterInteraction>) {\n if (this._interaction.get() !== val) {\n this._interaction.set(val);\n this._rebuildEffectiveWaveGenerator();\n }\n }\n /** @internal */\n private _rebuildEffectiveWaveGenerator() {\n const base = this._waveGenerator.get();\n const interaction = this._interaction.get();\n this._shoreWaveGenerator?.dispose();\n this._shoreWaveGenerator = null;\n this._foamFieldGenerator?.dispose();\n this._foamFieldGenerator = null;\n this._foamSource = null;\n // A field left behind must not hold on to the generators disposed here\n this._interactiveWaveGenerator?.interaction.setAmbientSurface(null);\n this._interactiveWaveGenerator = null;\n let effective: Nullable<WaveGenerator> = null;\n if (base) {\n // Innermost the foam field, whose foam the shore waves and the\n // interaction field compose theirs over\n const that = this;\n this._foamFieldGenerator = new FoamFieldWaveGenerator(base, this._foamField, {\n getFoamTexture: () => that.foamTexture,\n getFoamTextureSize: () => that._foamTextureSize\n });\n effective = this._foamFieldGenerator;\n this._foamSource = new WaveFoamSource(base, this._foamField);\n }\n if (effective && this._shoreWaves.height > 0) {\n this._shoreWaveGenerator = new ShoreWaveGenerator(effective, this._shoreWaves, this._foamSource!);\n this._foamFieldGenerator!.flowSource = this._shoreWaveGenerator;\n this._foamSource = this._shoreWaveGenerator;\n effective = this._shoreWaveGenerator;\n }\n // Outermost the interaction field: its ripples ride the shore waves rather\n // than being faded with the open water's chop near the shore, and a query\n // of the surface without the disturbers finds it on top to rebuild\n if (effective && interaction && interaction.isOk()) {\n // The field reads the surface beneath it under each disturber, so a hull\n // riding the waves is measured against the water it floats on\n interaction.setAmbientSurface(effective);\n effective = new InteractiveWaveGenerator(effective, interaction);\n this._interactiveWaveGenerator = effective as InteractiveWaveGenerator;\n interaction.ensureResources();\n }\n this._effectiveWaveGenerator = effective;\n // Bind groups are pooled; a stale version must not suppress the upload.\n this._waveVersionByBindGroup = new WeakMap();\n this.optionChanged(true);\n }\n /** How the refracted view sample is located. Defaults to `march`. Compile-time feature. */\n get refractionMode(): WaterRefractionMode {\n return this.featureUsed<WaterRefractionMode>(WaterMaterial.FEATURE_REFRACTION_MODE) ?? 'march';\n }\n set refractionMode(val: WaterRefractionMode) {\n if (val !== this.refractionMode) {\n this.useFeature(WaterMaterial.FEATURE_REFRACTION_MODE, val);\n }\n }\n /**\n * Which intermediate shading term to display instead of the final colour.\n * Defaults to `none`. See {@link WaterDebugOutput}.\n */\n get debugOutput(): WaterDebugOutput {\n return this.featureUsed<WaterDebugOutput>(WaterMaterial.FEATURE_DEBUG_OUTPUT) ?? 'none';\n }\n set debugOutput(val: WaterDebugOutput) {\n if (val !== this.debugOutput) {\n this.useFeature(WaterMaterial.FEATURE_DEBUG_OUTPUT, val);\n }\n }\n /**\n * Whether the surface reaches the horizon rather than ending at {@link region}.\n * Off by default. The clipmap's outermost ring becomes a horizon skirt.\n */\n get infinite(): boolean {\n return this.featureUsed<boolean>(WaterMaterial.FEATURE_INFINITE) ?? false;\n }\n set infinite(val: boolean) {\n if (!!val !== this.infinite) {\n this.useFeature(WaterMaterial.FEATURE_INFINITE, !!val);\n }\n }\n /** Absorption coefficient sigma_a in 1/m, per RGB channel. */\n get absorption() {\n return this._absorption;\n }\n set absorption(val: Vector3) {\n if (!val.equalsTo(this._absorption)) {\n this._absorption.set(val);\n this._updateMediumCoefficients();\n this.uniformChanged();\n }\n }\n /** Scale for the absorption coefficient. */\n get absorptionScale() {\n return this._absorptionScale;\n }\n set absorptionScale(val: number) {\n if (val !== this._absorptionScale) {\n this._absorptionScale = val;\n this._updateMediumCoefficients();\n this.uniformChanged();\n }\n }\n /** Scattering coefficient sigma_s in 1/m, per RGB channel. */\n get scattering() {\n return this._scattering;\n }\n set scattering(val: Vector3) {\n if (!val.equalsTo(this._scattering)) {\n this._scattering.set(val);\n this._updateMediumCoefficients();\n this.uniformChanged();\n }\n }\n /** Scale for the scattering coefficient. */\n get scatteringScale() {\n return this._scatteringScale;\n }\n set scatteringScale(val: number) {\n if (val !== this._scatteringScale) {\n this._scatteringScale = val;\n this._updateMediumCoefficients();\n this.uniformChanged();\n }\n }\n /** sigma_t = sigma_a + sigma_s in 1/m. Shared with the caustics pass. Do not mutate. */\n get extinction() {\n return this._extinction;\n }\n /** Single-scattering albedo sigma_s / sigma_t. Do not mutate. */\n get scatterAlbedo() {\n return this._scatterAlbedo;\n }\n /**\n * Whether a camera inside this body of water sees the medium applied to the\n * whole scene. Uses the same coefficients as the surface shading.\n */\n get underwaterEnabled() {\n return this._underwaterEnabled;\n }\n set underwaterEnabled(val: boolean) {\n this._underwaterEnabled = !!val;\n }\n /** Scale on the downwelling sky radiance lighting the column from inside, 1 for physical. */\n get underwaterAmbientIntensity() {\n return this._underwaterAmbientIntensity;\n }\n set underwaterAmbientIntensity(val: number) {\n this._underwaterAmbientIntensity = Math.max(0, val);\n }\n /**\n * Whether sunlight shafts are marched through the water column. Reads the\n * caustic map, so it is off wherever that is unavailable.\n */\n get underwaterGodRays() {\n return this._underwaterGodRays;\n }\n set underwaterGodRays(val: boolean) {\n this._underwaterGodRays = !!val;\n }\n /** Strength of the light shafts, 1 for the value the medium implies. */\n get underwaterGodRayIntensity() {\n return this._underwaterGodRayIntensity;\n }\n set underwaterGodRayIntensity(val: number) {\n this._underwaterGodRayIntensity = Math.max(0, val);\n }\n /** Samples per view ray for the light shafts. Dithered; below about 8 reads as noise. */\n get underwaterGodRaySteps() {\n return this._underwaterGodRaySteps;\n }\n set underwaterGodRaySteps(val: number) {\n this._underwaterGodRaySteps = Math.max(1, Math.floor(val));\n }\n /**\n * Whether geometry in the water breaks the light shafts. Off by default; one\n * shadow map lookup per march step, roughly doubling the shafts' cost.\n */\n get underwaterGodRayShadow() {\n return this._underwaterGodRayShadow;\n }\n set underwaterGodRayShadow(val: boolean) {\n this._underwaterGodRayShadow = !!val;\n }\n /**\n * Half-width in meters of the dead band the submerged test uses around the\n * rest plane, so a camera at water level does not flip state every frame.\n */\n get underwaterHysteresis() {\n return this._underwaterHysteresis;\n }\n set underwaterHysteresis(val: number) {\n this._underwaterHysteresis = Math.max(0, val);\n }\n /**\n * Whether this water projects caustics onto the geometry below it. Requires a\n * shadow-casting directional light.\n */\n get causticsEnabled() {\n return this._causticsEnabled;\n }\n set causticsEnabled(val: boolean) {\n this._causticsEnabled = !!val;\n }\n /** Strength of the caustic contrast. 0 leaves the light unmodulated. */\n get causticsIntensity() {\n return this._causticsIntensity;\n }\n set causticsIntensity(val: number) {\n this._causticsIntensity = val;\n }\n /** Depth in meters below the surface where the caustics are in focus. */\n get causticsDepth() {\n return this._causticsDepth;\n }\n set causticsDepth(val: number) {\n this._causticsDepth = Math.max(0.01, val);\n }\n /** Furthest distance in meters from the camera the caustic map reaches. */\n get causticsRange() {\n return this._causticsRange;\n }\n set causticsRange(val: number) {\n this._causticsRange = Math.max(1, val);\n }\n /**\n * Width in meters of the fade band at the edge of the caustic map, or 0 to\n * derive it from {@link causticsRange}. Capped at 90% of the range.\n */\n get causticsFadeDistance() {\n return this._causticsFadeDistance;\n }\n set causticsFadeDistance(val: number) {\n this._causticsFadeDistance = Math.max(0, val);\n }\n /**\n * Whether photons land on the scene (via the sun's shadow cascade) instead of\n * on a plane at {@link causticsDepth}. On by default.\n */\n get causticsSceneDepth() {\n return this._causticsSceneDepth;\n }\n set causticsSceneDepth(val: boolean) {\n this._causticsSceneDepth = !!val;\n }\n /**\n * How strongly caustic map texels are concentrated near the camera, 0 for\n * uniform. Density is `1 + warp` times uniform at the centre and\n * `1 / (1 + warp)` at the border. Ignored while the map fits the water.\n */\n get causticsWarp() {\n return this._causticsWarp;\n }\n set causticsWarp(val: number) {\n this._causticsWarp = Math.max(0, Math.min(8, val));\n }\n /**\n * Water depth in metres below which no caustics show, faded in over half\n * of it either side; 0 shows them right up to the water's edge.\n */\n get causticsMinDepth() {\n return this._causticsMinDepth;\n }\n set causticsMinDepth(val: number) {\n this._causticsMinDepth = Math.max(0, val);\n }\n /** Caustic contrast falloff per meter away from {@link causticsDepth}. */\n get causticsDefocus() {\n return this._causticsDefocus;\n }\n set causticsDefocus(val: number) {\n this._causticsDefocus = Math.max(0, val);\n }\n /** Edge length of the square caustic map. */\n get causticsResolution() {\n return this._causticsResolution;\n }\n set causticsResolution(val: number) {\n this._causticsResolution = Math.max(16, Math.min(2048, val | 0));\n }\n /** Edge length of the photon grid, or 0 to size it from the map. Cost is quadratic. */\n get causticsPhotonResolution() {\n return this._causticsPhotonResolution;\n }\n set causticsPhotonResolution(val: number) {\n const n = val | 0;\n this._causticsPhotonResolution = n <= 0 ? 0 : Math.max(16, Math.min(4096, n));\n }\n /** Number of 2x2 blur iterations on the caustic map. Rounded up to even. */\n get causticsBlurPasses() {\n return this._causticsBlurPasses;\n }\n set causticsBlurPasses(val: number) {\n const clamped = Math.max(0, Math.min(4, val | 0));\n this._causticsBlurPasses = clamped + (clamped & 1);\n }\n /** Weight of the previous frame's caustic map in the current one, 0 to disable. */\n get causticsTemporalStrength() {\n return this._causticsTemporalStrength;\n }\n set causticsTemporalStrength(val: number) {\n this._causticsTemporalStrength = Math.max(0, Math.min(0.95, val));\n }\n /**\n * Strength of the glow of a backlit wave crest, 0 to disable. Authored, not\n * scaled by the light's intensity; {@link subsurfaceTint} supplies the hue.\n */\n get subsurfaceIntensity() {\n return this._subsurfaceIntensity;\n }\n set subsurfaceIntensity(val: number) {\n if (val !== this._subsurfaceIntensity) {\n this._subsurfaceIntensity = Math.max(0, val);\n this.uniformChanged();\n }\n }\n /**\n * Height above the still-water level, in meters, over which the lit wall of\n * a crest thins by a factor of `e`. Lower for a calm sea, higher so only the\n * tallest crests glow.\n */\n get subsurfaceCrestHeight() {\n return this._subsurfaceCrestHeight;\n }\n set subsurfaceCrestHeight(val: number) {\n // The gate softens over SSS_HEIGHT_SOFTNESS of this; too small a height\n // makes it a hard step at the still-water level.\n const clamped = Math.max(SSS_CREST_HEIGHT_MIN, val);\n if (clamped !== this._subsurfaceCrestHeight) {\n this._subsurfaceCrestHeight = clamped;\n this.uniformChanged();\n }\n }\n /** Colour of the crest glow, before the crest gate tints it with the medium's extinction. */\n get subsurfaceTint() {\n return this._subsurfaceTint;\n }\n set subsurfaceTint(val: Vector3) {\n if (!val.equalsTo(this._subsurfaceTint)) {\n this._subsurfaceTint.set(val);\n this.uniformChanged();\n }\n }\n /**\n * Strength of the sunlight scattered out of the water column towards the eye,\n * 1 for the physical value. 0 disables the term.\n */\n get sunScatteringIntensity() {\n return this._sunScatteringIntensity;\n }\n set sunScatteringIntensity(val: number) {\n const clamped = Math.max(0, val);\n if (clamped !== this._sunScatteringIntensity) {\n this._sunScatteringIntensity = clamped;\n this.uniformChanged();\n }\n }\n /**\n * Fixed depth in meters the `offset` refraction mode steps along the refracted\n * ray. Ignored by `march`. Deliberately not the scene distance, which would\n * double submerged objects across their silhouette.\n */\n get cheapRefractionDepth() {\n return this._cheapRefractionDepth;\n }\n set cheapRefractionDepth(val: number) {\n const clamped = Math.max(0, val);\n if (clamped !== this._cheapRefractionDepth) {\n this._cheapRefractionDepth = clamped;\n this.uniformChanged();\n }\n }\n /** Scale on the medium's refraction blur. 0 is sharp, 1 is what the medium implies. */\n get refractionBlur() {\n return this._refractionBlur;\n }\n set refractionBlur(val: number) {\n const clamped = Math.max(0, val);\n if (clamped !== this._refractionBlur) {\n this._refractionBlur = clamped;\n this.uniformChanged();\n }\n }\n /** Mean cosine of a single scattering event, in `[0, 0.95]`. 0 is isotropic. */\n get scatterAnisotropy() {\n return this._scatterAnisotropy;\n }\n set scatterAnisotropy(val: number) {\n const clamped = Math.max(0, Math.min(0.95, val));\n if (clamped !== this._scatterAnisotropy) {\n this._scatterAnisotropy = clamped;\n this.uniformChanged();\n }\n }\n /** Scale from the generator's fold measure to foam coverage, 0 to disable. */\n get foamAmount() {\n return this._foamAmount;\n }\n set foamAmount(val: number) {\n if (val !== this._foamAmount) {\n this._foamAmount = Math.max(0, val);\n this.uniformChanged();\n }\n }\n /** Power applied to foam coverage before scaling. Above 1 restricts foam to broken crests. */\n get foamFalloff() {\n return this._foamFalloff;\n }\n set foamFalloff(val: number) {\n if (val !== this._foamFalloff) {\n this._foamFalloff = Math.max(0.01, val);\n this.uniformChanged();\n }\n }\n /** Diffuse albedo of the foam. */\n get foamColor() {\n return this._foamColor;\n }\n set foamColor(val: Vector3) {\n if (!val.equalsTo(this._foamColor)) {\n this._foamColor.set(val);\n this.uniformChanged();\n }\n }\n /**\n * How gradually the white foam fades out at its edges, from a crisp cut\n * (near 0) to a soft blend into the bubbles beneath (1).\n */\n get foamFeather() {\n return this._foamFeather;\n }\n set foamFeather(val: number) {\n const clamped = Math.min(Math.max(val, 0.001), 1);\n if (clamped !== this._foamFeather) {\n this._foamFeather = clamped;\n this.uniformChanged();\n }\n }\n /** How much the white foam is lit as a lumpy relief rather than a flat sheet, 0 for flat. */\n get foamNormalStrength() {\n return this._foamNormalStrength;\n }\n set foamNormalStrength(val: number) {\n const clamped = Math.max(0, val);\n if (clamped !== this._foamNormalStrength) {\n this._foamNormalStrength = clamped;\n this.uniformChanged();\n }\n }\n /** Tint of the bubbles under the white foam, lit by the sky. */\n get foamBubbleColor() {\n return this._foamBubbleColor;\n }\n set foamBubbleColor(val: Vector3) {\n if (!val.equalsTo(this._foamBubbleColor)) {\n this._foamBubbleColor.set(val);\n this.uniformChanged();\n }\n }\n /** How far the bubbles spread around the white foam and how strongly they show, 0 for none. */\n get foamBubbleCoverage() {\n return this._foamBubbleCoverage;\n }\n set foamBubbleCoverage(val: number) {\n const clamped = Math.max(0, val);\n if (clamped !== this._foamBubbleCoverage) {\n this._foamBubbleCoverage = clamped;\n this.uniformChanged();\n }\n }\n /**\n * Texture the foam is cut from, its value in the red channel: the foam\n * density uncovers it from its brightest parts down, so bright clumps show\n * first and dark holes last. Null for the built-in bubble pattern (see\n * getDefaultFoamTexture), which reads as a texture of one's own would.\n * Tiles every {@link foamTextureSize} metres.\n */\n get foamTexture(): Nullable<Texture2D> {\n return this._foamTexture.get() ?? null;\n }\n set foamTexture(tex: Nullable<Texture2D>) {\n if (tex !== this.foamTexture) {\n this._foamTexture.set(tex);\n this.uniformChanged();\n }\n }\n /** Metres of water one repeat of the {@link foamTexture} covers. */\n get foamTextureSize() {\n return this._foamTextureSize;\n }\n set foamTextureSize(val: number) {\n const clamped = Math.max(0.01, val);\n if (clamped !== this._foamTextureSize) {\n this._foamTextureSize = clamped;\n this.uniformChanged();\n }\n }\n /** How deep under the surface the bubbles seem to float, in metres; they shift against the foam as the view moves. */\n get foamBubbleDepth() {\n return this._foamBubbleDepth;\n }\n set foamBubbleDepth(val: number) {\n const clamped = Math.max(0, val);\n if (clamped !== this._foamBubbleDepth) {\n this._foamBubbleDepth = clamped;\n this.uniformChanged();\n }\n }\n /** @internal */\n private _updateMediumCoefficients() {\n this._extinction.setXYZ(\n this._absorption.x * this._absorptionScale + this._scattering.x * this._scatteringScale,\n this._absorption.y * this._absorptionScale + this._scattering.y * this._scatteringScale,\n this._absorption.z * this._absorptionScale + this._scattering.z * this._scatteringScale\n );\n this._scatterAlbedo.setXYZ(\n this._extinction.x > 0 ? (this._scattering.x * this._scatteringScale) / this._extinction.x : 0,\n this._extinction.y > 0 ? (this._scattering.y * this._scatteringScale) / this._extinction.y : 0,\n this._extinction.z > 0 ? (this._scattering.z * this._scatteringScale) / this._extinction.z : 0\n );\n }\n /** Artistic scale on the refracted view offset. 1 is physical, 0 disables it. */\n get refractionScale() {\n return this._refractionScale;\n }\n set refractionScale(val) {\n const clamped = Math.max(0, val);\n if (clamped !== this._refractionScale) {\n this._refractionScale = clamped;\n this.uniformChanged();\n }\n }\n /** Scale on the Fresnel reflectance, 1 for physical. Scales F0 too, so 0 kills specular. */\n get reflectionStrength() {\n return this._reflectionStrength;\n }\n set reflectionStrength(val) {\n const clamped = Math.max(0, Math.min(1, val));\n if (clamped !== this._reflectionStrength) {\n this._reflectionStrength = clamped;\n this.uniformChanged();\n }\n }\n needSceneColor() {\n return true;\n }\n needSceneDepth() {\n return true;\n }\n protected _createHash() {\n return `${super._createHash()}:${this.waveGenerator?.getHash() ?? ''}`;\n }\n setClipmapInfo(rotation: number, scale: number, offsetX: number, offsetY: number) {\n this._clipmapInfo.setXYZW(rotation, scale, offsetX, offsetY);\n this.uniformChanged();\n }\n /**\n * @param tileResolution - Cells along a clipmap tile, for the spacing of the\n * mesh vertices the wave generator band-limits to; 0 for no limit.\n */\n setClipmapGridInfo(gridScale: number, gridOffsetX: number, gridOffsetY: number, tileResolution = 0) {\n if (\n this._clipmapGridInfo.x !== gridScale ||\n this._clipmapGridInfo.y !== gridOffsetX ||\n this._clipmapGridInfo.z !== gridOffsetY ||\n this._clipmapGridInfo.w !== tileResolution\n ) {\n this._clipmapGridInfo.setXYZW(gridScale, gridOffsetX, gridOffsetY, tileResolution);\n this.uniformChanged();\n }\n }\n /** Distance from the camera to the horizon skirt's outer edge. Only read while {@link infinite}. */\n setSkirtDistance(distance: number) {\n if (this._skirtDistance !== distance) {\n this._skirtDistance = distance;\n this.uniformChanged();\n }\n }\n supportInstancing() {\n return false;\n }\n supportLighting() {\n return true;\n }\n /**\n * {@inheritDoc IMixinLight.receivesWaterCaustics}\n *\n * Always false: the submersion test would read a water fragment as submerged\n * wherever the surface up-sun of it rides a crest.\n */\n receivesWaterCaustics(): boolean {\n return false;\n }\n vertexShader(scope: PBFunctionScope) {\n super.vertexShader(scope);\n const pb = scope.$builder;\n this.waveGenerator?.setupUniforms(scope, 2);\n scope.$inputs.position = pb.vec3().attrib('position');\n scope.$inputs.clipmapInfo = pb.vec4().attrib('texCoord0');\n scope.clipmapGridInfo = pb.vec4().uniform(2);\n if (this.infinite) {\n scope.skirtDistance = pb.float().uniform(2);\n }\n\n scope.$l.s = pb.sin(scope.$inputs.clipmapInfo.x);\n scope.$l.c = pb.cos(scope.$inputs.clipmapInfo.x);\n scope.$l.scale2 = pb.mul(scope.$inputs.clipmapInfo.y, scope.clipmapGridInfo.x);\n scope.$l.clipmapMatrix = pb.mat4(\n pb.mul(scope.c, scope.scale2),\n pb.mul(scope.s, scope.scale2),\n 0,\n 0,\n pb.neg(pb.mul(scope.s, scope.scale2)),\n pb.mul(scope.c, scope.scale2),\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n pb.sub(pb.mul(scope.$inputs.clipmapInfo.z, scope.clipmapGridInfo.x), scope.clipmapGridInfo.y),\n pb.sub(pb.mul(scope.$inputs.clipmapInfo.w, scope.clipmapGridInfo.x), scope.clipmapGridInfo.z),\n 0,\n 1\n );\n\n scope.$l.clipmapPos = pb.mul(scope.clipmapMatrix, pb.vec4(scope.$inputs.position, 1)).xy;\n scope.clipmapWorldPos = pb.mul(\n ShaderHelper.getWorldMatrix(scope),\n pb.vec4(scope.clipmapPos.x, 0, scope.clipmapPos.y, 1)\n ).xyz;\n scope.worldNormal = pb.vec3(0, 1, 0);\n scope.worldPos = scope.clipmapWorldPos;\n // Mesh vertex spacing: clipmap level L spans Chebyshev distances T 2^L to\n // 2T 2^L cells with cells 2^L across, so distance / T bounds it. Taken from\n // the distance, not the level, so both sides of a seam agree.\n scope.$l.camOffset = pb.abs(pb.sub(scope.clipmapWorldPos.xz, ShaderHelper.getCameraPosition(scope).xz));\n scope.$l.vertexSpacing = pb.mul(\n pb.max(\n scope.clipmapGridInfo.x,\n pb.div(pb.max(scope.camOffset.x, scope.camOffset.y), pb.max(scope.clipmapGridInfo.w, 1))\n ),\n pb.step(0.5, scope.clipmapGridInfo.w)\n );\n if (this.infinite) {\n const that = this;\n // position.z is 1 on the skirt ring's outer edge, 0 everywhere else.\n scope.$l.skirt = pb.step(0.5, scope.$inputs.position.z);\n scope\n .$if(pb.greaterThan(scope.skirt, 0), function () {\n // Pushed radially out from the camera, undisplaced, at the still-water level.\n this.$l.camXZ = ShaderHelper.getCameraPosition(this).xz;\n this.$l.outDir = pb.normalize(pb.sub(this.clipmapWorldPos.xz, this.camXZ));\n this.$l.outXZ = pb.add(this.camXZ, pb.mul(this.outDir, this.skirtDistance));\n this.worldPos = pb.vec3(this.outXZ.x, this.clipmapWorldPos.y, this.outXZ.y);\n })\n .$else(function () {\n that.waveGenerator?.calcVertexPositionAndNormal(\n this,\n this.clipmapWorldPos,\n this.worldPos,\n this.worldNormal,\n this.vertexSpacing\n );\n });\n scope.$outputs.skirt = scope.skirt;\n } else {\n this.waveGenerator?.calcVertexPositionAndNormal(\n scope,\n scope.clipmapWorldPos,\n scope.worldPos,\n scope.worldNormal,\n scope.vertexSpacing\n );\n }\n scope.$outputs.worldPos = scope.worldPos;\n scope.$outputs.clipmapPos = scope.clipmapWorldPos;\n scope.$outputs.worldNormal = scope.worldNormal;\n if (this.infinite) {\n // Vertices past the far plane are pulled in along their own view ray:\n // screen position is unchanged, only the written depth moves. Shading\n // keeps the true world position.\n scope.$l.camPos = ShaderHelper.getCameraPosition(scope).xyz;\n scope.$l.viewVec = pb.sub(scope.$outputs.worldPos, scope.camPos);\n scope.$l.viewDist = pb.max(pb.length(scope.viewVec), 1e-6);\n scope.$l.maxDist = pb.mul(ShaderHelper.getCameraParams(scope).y, INFINITE_DEPTH_PULLIN);\n scope.$l.pullIn = pb.min(pb.div(scope.maxDist, scope.viewDist), 1);\n scope.$l.projPos = pb.add(scope.camPos, pb.mul(scope.viewVec, scope.pullIn));\n ShaderHelper.setClipSpacePosition(\n scope,\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.projPos, 1))\n );\n } else {\n ShaderHelper.setClipSpacePosition(\n scope,\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1))\n );\n }\n const gen = this.waveGenerator;\n if (gen?.calcPrevVertexPosition && ShaderHelper.getPrevUnjitteredViewProjectionMatrix(scope)) {\n scope.$l.prevWorldPos = pb.vec3();\n gen.calcPrevVertexPosition(scope, scope.clipmapWorldPos, scope.prevWorldPos, scope.vertexSpacing);\n if (this.infinite) {\n // The skirt does not move\n scope.prevWorldPos = pb.mix(scope.prevWorldPos, scope.$outputs.worldPos, scope.skirt);\n }\n ShaderHelper.resolveMotionVector(scope, scope.$outputs.worldPos, scope.prevWorldPos);\n } else {\n ShaderHelper.resolveMotionVector(scope, scope.$outputs.worldPos, scope.$outputs.worldPos);\n }\n }\n fragmentShader(scope: PBFunctionScope) {\n super.fragmentShader(scope);\n const pb = scope.$builder;\n this.waveGenerator?.setupUniforms(scope, 2);\n if (!this.infinite) {\n scope.region = pb.vec4().uniform(2);\n }\n if (this.needFragmentColor()) {\n scope.refractionScale = pb.float().uniform(2);\n if (this.refractionMode === 'offset') {\n scope.cheapRefractionDepth = pb.float().uniform(2);\n }\n scope.reflectionStrength = pb.float().uniform(2);\n // (wind direction x, z, upwind slope variance, crosswind slope variance)\n scope.unresolvedSlope = pb.vec4().uniform(2);\n // Sky bake to the live pre-exposed space, as the visible sky is drawn\n scope.skyReflectScale = pb.float().uniform(2);\n scope.ssrParams = pb.vec4().uniform(2);\n // Eye vs. rest plane from the CPU submersion test: 1 above, -1 below,\n // 0 unknown (compare in the shader).\n scope.eyeSide = pb.float().uniform(2);\n // (intensity, crest absorption height in m, 0, 0)\n scope.subsurfaceParams = pb.vec4().uniform(2);\n scope.subsurfaceTint = pb.vec3().uniform(2);\n // (coverage scale, coverage falloff, 0, 0)\n scope.foamShadingParams = pb.vec4().uniform(2);\n scope.foamColor = pb.vec3().uniform(2);\n // (white foam feather, foam normal strength, bubble coverage, bubble depth in m)\n scope.foamLookParams = pb.vec4().uniform(2);\n scope.foamBubbleColor = pb.vec3().uniform(2);\n scope.foamTex = pb.tex2D().uniform(2);\n // uv of the foam texture per metre\n scope.foamUVScale = pb.float().uniform(2);\n // Thickness in metres a sheet of water fades in over, 0 for none\n scope.edgeFadeWidth = pb.float().uniform(2);\n // (intensity, anisotropy, 0, 0)\n scope.sunScatterParams = pb.vec4().uniform(2);\n // Mip widths per meter of path; one scalar LOD for all three channels.\n scope.refractBlurDensity = pb.float().uniform(2);\n scope.mediumAlbedo = pb.vec3().uniform(2);\n scope.mediumExtinction = pb.vec3().uniform(2);\n // Rect light specular (evaluateLTCRectLightTerms).\n scope.zLTCMatLut = pb.tex2D().uniform(2);\n scope.zLTCAmpLut = pb.tex2D().uniform(2);\n }\n if (!this.infinite) {\n scope.$l.discardable = pb.or(\n pb.any(pb.lessThan(scope.$inputs.worldPos.xz, scope.region.xy)),\n pb.any(pb.greaterThan(scope.$inputs.worldPos.xz, scope.region.zw))\n );\n scope.$if(scope.discardable, function () {\n pb.discard();\n });\n }\n if (this.debugOutput === 'shoreRegions' || this.debugOutput === 'shoreLevels') {\n // Show the actual displaced carrier in every pass. Wet-edge discard and\n // ground-depth projection would otherwise conceal its geometry or create\n // an apparent boundary unrelated to rasterized mesh coverage.\n if (this.needFragmentColor()) {\n if (this.debugOutput === 'shoreLevels') {\n scope.$l.outColor = pb.vec4(\n this._shoreWaveGenerator\n ? this._shoreWaveGenerator.calcDebugLevels(scope, scope.$inputs.clipmapPos.xz)\n : pb.vec3(0.1),\n 1\n );\n } else {\n scope.$l.shoreRegion = this._shoreWaveGenerator\n ? this._shoreWaveGenerator.calcDebugRegion(scope, scope.$inputs.clipmapPos.xz)\n : pb.vec3(0, 0, 1);\n scope.$l.shoreColor = scope.$choice(\n pb.greaterThan(scope.shoreRegion.y, 0.5),\n scope.$choice(\n pb.greaterThan(scope.shoreRegion.z, 1e-3),\n pb.vec3(1, 0.3, 0.02),\n pb.vec3(0.85, 0.02, 0.8)\n ),\n pb.vec3(0, 0.85, 1)\n );\n scope.$l.outColor = pb.vec4(\n pb.mix(pb.vec3(0.02, 0.12, 0.9), scope.shoreColor, scope.shoreRegion.x),\n 1\n );\n }\n if (\n this.drawContext.materialFlags &\n (MaterialVaryingFlags.SCENE_STORE_ROUGHNESS | MaterialVaryingFlags.SCENE_STORE_NORMAL)\n ) {\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.outColor, pb.vec4(0), scope.outColor);\n } else {\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.outColor);\n }\n } else {\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\n }\n return;\n }\n if (this.needFragmentColor()) {\n // Screen derivatives of the undisplaced position, taken here in uniform\n // control flow; the foam textures are sampled with them under branches.\n scope.$l.restXZGrad = pb.vec4(\n pb.dpdx(scope.$inputs.clipmapPos.xz),\n pb.dpdy(scope.$inputs.clipmapPos.xz)\n );\n // The foam texture here, drifting; a generator carrying foam of its own\n // blends in where its foam is\n scope.$l.foamSample = sampleFoamTexture(\n scope,\n scope.foamTex,\n pb.mul(\n pb.add(\n scope.$inputs.clipmapPos.xz,\n pb.vec2(pb.mul(ShaderHelper.getElapsedTime(scope), FOAM_DRIFT))\n ),\n scope.foamUVScale\n ),\n scope.restXZGrad,\n scope.foamUVScale\n );\n scope.$l.normal = this.waveGenerator\n ? this.waveGenerator.calcFragmentNormalAndFoam(\n scope,\n scope.$inputs.clipmapPos.xz,\n scope.$inputs.worldNormal,\n scope.foamSample,\n this.waveGenerator.calcUnresolvedSlopeVariance ? scope.restXZGrad : undefined\n )\n : pb.vec4(scope.$inputs.worldNormal, 0);\n if (this.infinite) {\n // Flat and foamless on the skirt: waves evaluated at kilometres per\n // pixel alias into speckle.\n scope.normal = pb.mix(scope.normal, pb.vec4(0, 1, 0, 0), scope.$inputs.skirt);\n }\n // Vertical wave displacement, interpolated from the vertices. Zero on the skirt.\n scope.$l.crestHeight = pb.sub(scope.$inputs.worldPos.y, scope.$inputs.clipmapPos.y);\n const surfaceCoverage = this.waveGenerator?.calcSurfaceCoverage;\n scope.$l.surfaceCoverage = surfaceCoverage\n ? surfaceCoverage.call(this.waveGenerator, scope, scope.$inputs.clipmapPos.xz)\n : pb.float(1);\n const sheetThickness = this.waveGenerator?.calcSheetThickness;\n scope.$l.sheetThickness = sheetThickness\n ? sheetThickness.call(this.waveGenerator, scope, scope.$inputs.clipmapPos.xz)\n : pb.float(-1);\n if (this._shoreWaveGenerator) {\n // Near the shore the foam is at least the near-shore density, joining\n // the breaking waves' foam to the beach's (see nearShore).\n scope.normal.w = this._shoreWaveGenerator.calcNearShoreFoam(\n scope,\n scope.$inputs.clipmapPos.xz,\n scope.normal.w\n );\n }\n // Reconstruct the opaque surface before the swash's discard. Deposited\n // foam is projected onto this ground, independently of the raised mesh.\n scope.$l.scenePos = ShaderHelper.samplePositionFromDepth(\n scope,\n ShaderHelper.getLinearDepthTexture(scope),\n pb.div(scope.$builtins.fragCoord.xy, ShaderHelper.getRenderSize(scope)),\n ShaderHelper.getJitteredInvVPMatrix(scope),\n ShaderHelper.getCameraParams(scope).xy\n );\n scope.$l.groundFoamDensity = pb.float(0);\n scope.$l.groundFoamSample = pb.vec3(0);\n scope.$l.groundFoamWeight = pb.float(0);\n scope.$l.groundNormal = pb.vec3(0, 1, 0);\n if (this.debugOutput === 'swashVisibility') {\n scope.$l.visibilityDepthFail = pb.float(0);\n }\n if (this.debugOutput === 'swashGroundSupport') {\n scope.$l.groundFieldCoverage = pb.float(0);\n scope.$l.groundWetCoverage = pb.float(0);\n } else if (this.debugOutput === 'swashHandover') {\n scope.$l.groundWetCoverage = pb.float(0);\n } else if (this.debugOutput === 'swashFoamSources') {\n scope.$l.groundFieldDensity = pb.float(0);\n scope.$l.groundSurfDensity = pb.float(0);\n }\n if (this._shoreWaveGenerator && this._foamFieldGenerator) {\n // Derivatives precede all coverage branches; pattern coordinates stay\n // fixed to the sand even while the water and camera move.\n scope.$l.groundGrad = pb.vec4(pb.dpdx(scope.scenePos.xz), pb.dpdy(scope.scenePos.xz));\n scope.$l.groundCross = pb.cross(pb.dpdx(scope.scenePos.xyz), pb.dpdy(scope.scenePos.xyz));\n scope.groundNormal = pb.normalize(\n pb.add(pb.mul(scope.groundCross, pb.sign(scope.groundCross.y)), pb.vec3(0, 1e-8, 0))\n );\n scope.$l.groundMask = this._shoreWaveGenerator.calcFoamGroundMask(scope, scope.scenePos.xyz);\n const field = this._foamField;\n const shore = this._shoreWaveGenerator;\n const debugOutput = this.debugOutput;\n scope.$if(\n pb.and(pb.lessThan(scope.scenePos.w, SCENE_SKY_DEPTH01), pb.greaterThan(scope.groundMask, 0)),\n function () {\n // The field's foam at the actual ground position: on a thin sheet and\n // on the sand it drained from alike, the field holding it there\n // (FOAM_SETTLE of the shore waves)\n this.$l.groundMobile = field.sample(this, this.scenePos.xz);\n this.$l.groundWet = shore.calcSurfaceCoverage(this, this.scenePos.xz);\n this.$l.groundThickness = shore.calcSheetThickness(this, this.scenePos.xz);\n // Coverage and handover describe the same carrier point. Using the\n // ground point's thickness here leaves a gap at grazing angles:\n // the carrier can be dry while its projected ground is still wet.\n this.$l.groundHandoverThickness = this.$choice(\n pb.greaterThanEqual(this.sheetThickness, 0),\n this.sheetThickness,\n this.groundThickness\n );\n if (debugOutput === 'swashGroundSupport') {\n this.groundWetCoverage = this.groundWet;\n this.groundFieldCoverage = this.groundMobile.y;\n } else if (debugOutput === 'swashHandover') {\n this.groundWetCoverage = this.groundWet;\n } else if (debugOutput === 'swashFoamSources') {\n this.groundFieldDensity = this.groundMobile.x;\n this.groundSurfDensity = pb.mul(\n shore.calcNearShoreFoam(this, this.scenePos.xz, pb.float(0)),\n this.groundWet\n );\n }\n this.groundFoamWeight = pb.mul(\n this.groundMask,\n this.groundMobile.y,\n // Unknown thickness must retain the water surface. In particular,\n // a valid sand bed outside the shore-wave zone is not a dry sheet.\n this.$choice(\n pb.greaterThanEqual(this.groundHandoverThickness, 0),\n pb.sub(1, pb.smoothStep(0.01, 0.06, this.groundHandoverThickness)),\n pb.float(0)\n )\n );\n // The surf's foam only where the sheet now is; the field's wherever it holds it\n this.groundFoamDensity = pb.clamp(\n pb.max(\n this.groundMobile.x,\n pb.mul(shore.calcNearShoreFoam(this, this.scenePos.xz, pb.float(0)), this.groundWet)\n ),\n 0,\n 1\n );\n this.$if(pb.greaterThan(this.groundFoamDensity, 1e-3), function () {\n // The water's foam pattern at the ground: it stands still near\n // the shore (see nearShore), so the beach's foam and the water's\n // are one pattern through the handover.\n this.groundFoamSample = WaterFoamField.flowPattern(\n this,\n this.ffFoamTex,\n this.ffFoamUVScale,\n this.ffClock.x,\n this.scenePos.xz,\n this.groundGrad,\n shore.calcFoamFlow(this, this.scenePos.xz, this.ffDrift)\n );\n });\n }\n );\n // The thin-film foam and its depth use the same ground transition.\n // Otherwise a wet carrier can still clip the projected foam against\n // the terrain right where the two layers meet.\n scope.$builtins.fragDepth = pb.mix(\n scope.$builtins.fragCoord.z,\n ShaderHelper.linearNormalizedToNonLinearDepth(\n scope,\n pb.max(pb.sub(scope.scenePos.w, pb.div(0.001, ShaderHelper.getCameraParams(scope).y)), 0),\n ShaderHelper.getCameraParams(scope).xy\n ),\n scope.$choice(pb.lessThanEqual(scope.surfaceCoverage, 1e-3), pb.float(1), scope.groundFoamWeight)\n );\n }\n const revealSwash =\n this.debugOutput === 'foamField' ||\n this.debugOutput === 'swashVisibility' ||\n this.debugOutput === 'swashGroundSupport';\n if (revealSwash && this._shoreWaveGenerator && this._foamFieldGenerator) {\n if (this.debugOutput === 'swashVisibility') {\n scope.visibilityDepthFail = scope.$choice(\n pb.greaterThan(\n pb.mul(\n pb.sub(\n ShaderHelper.nonLinearDepthToLinearNormalized(\n scope,\n scope.$builtins.fragDepth as PBShaderExp\n ),\n scope.scenePos.w\n ),\n ShaderHelper.getCameraParams(scope).y\n ),\n 0.0001\n ),\n pb.float(1),\n pb.float(0)\n );\n }\n scope.$if(\n pb.and(pb.lessThan(scope.scenePos.w, SCENE_SKY_DEPTH01), pb.greaterThan(scope.groundMask, 0)),\n function () {\n this.$builtins.fragDepth = ShaderHelper.linearNormalizedToNonLinearDepth(\n this,\n pb.max(pb.sub(this.scenePos.w, pb.div(0.001, ShaderHelper.getCameraParams(this).y)), 0),\n ShaderHelper.getCameraParams(this).xy\n );\n }\n );\n }\n scope.$l.swashDiscard = pb.and(\n pb.lessThanEqual(scope.surfaceCoverage, 1e-3),\n pb.lessThanEqual(pb.mul(scope.groundFoamDensity, scope.groundFoamWeight), 1e-3)\n );\n // Past the wet edge, only the foam actually left on the ground draws.\n if (surfaceCoverage && !revealSwash) {\n scope.$if(scope.swashDiscard, function () {\n pb.discard();\n });\n }\n if (this.debugOutput === 'swashGroundSupport') {\n scope.$l.outColor = pb.vec4(\n this._shoreWaveGenerator && this._foamFieldGenerator ? scope.groundMask : pb.float(0),\n scope.groundFieldCoverage,\n scope.groundWetCoverage,\n 1\n );\n } else if (this.debugOutput === 'swashVisibility') {\n scope.$l.outColor = pb.vec4(\n scope.$choice(scope.swashDiscard, pb.float(1), pb.float(0)),\n scope.visibilityDepthFail,\n scope.groundFoamDensity,\n 1\n );\n } else if (this.debugOutput === 'swashHandover') {\n scope.$l.outColor = pb.vec4(\n scope.surfaceCoverage,\n scope.groundWetCoverage,\n scope.groundFoamWeight,\n 1\n );\n } else if (this.debugOutput === 'swashFoamSources') {\n scope.$l.outColor = pb.vec4(scope.normal.w, scope.groundFieldDensity, scope.groundSurfDensity, 1);\n } else if (this.debugOutput === 'interaction') {\n // The field on its own, grey at rest, scaled so its amplitude clamp\n // reaches black and white; dimmed outside the window so its reach shows.\n if (this._interactiveWaveGenerator) {\n const interaction = this._interactiveWaveGenerator.interaction;\n scope.$l.wiDebugHeight = pb.div(\n interaction.sampleHeight(scope, scope.$inputs.clipmapPos.xz),\n scope.wiParams2.y\n );\n scope.$l.wiDebugMask = pb.mix(\n pb.float(0.55),\n pb.float(1),\n interaction.windowMask(scope, scope.$inputs.clipmapPos.xz)\n );\n } else {\n scope.$l.wiDebugHeight = pb.float(0);\n scope.$l.wiDebugMask = pb.float(1);\n }\n scope.$l.outColor = pb.vec4(\n pb.vec3(pb.mul(pb.add(0.5, pb.mul(scope.wiDebugHeight, 0.5)), scope.wiDebugMask)),\n 1\n );\n } else if (this.debugOutput === 'foamField') {\n // The field's density; mid grey off the field, where coverage is 0\n if (this._foamFieldGenerator) {\n scope.$l.ffDebug = this._foamField.sample(scope, scope.$inputs.clipmapPos.xz);\n } else {\n scope.$l.ffDebug = pb.vec3(0);\n }\n scope.$l.outColor = pb.vec4(\n pb.vec3(pb.mix(pb.float(0.5), pb.max(scope.ffDebug.x, scope.ffDebug.z), scope.ffDebug.y)),\n 1\n );\n } else {\n // The foam field's wall foam layer, see FOAM_WALL\n scope.$l.wallFoam = this._foamFieldGenerator\n ? pb.mul(\n this._foamField.sample(scope, scope.$inputs.clipmapPos.xz).z,\n this.infinite ? pb.sub(1, scope.$inputs.skirt) : pb.float(1)\n )\n : pb.float(0);\n scope.$l.outColor = pb.vec4(\n this.waterShading(\n scope,\n scope.$inputs.worldPos,\n scope.normal.xyz,\n scope.normal.w,\n scope.crestHeight,\n scope.$inputs.clipmapPos.xz,\n scope.restXZGrad,\n scope.foamSample,\n scope.surfaceCoverage,\n scope.sheetThickness,\n scope.wallFoam,\n scope.scenePos,\n scope.groundFoamDensity,\n scope.groundFoamSample,\n scope.groundNormal,\n scope.groundFoamWeight\n ),\n 1\n );\n }\n if (\n this.drawContext.materialFlags &\n (MaterialVaryingFlags.SCENE_STORE_ROUGHNESS | MaterialVaryingFlags.SCENE_STORE_NORMAL)\n ) {\n scope.$l.outRoughness = pb.vec4(\n pb.vec3(this.waterRoughness(scope, scope.$inputs.worldPos, scope.restXZGrad)),\n 0\n );\n this.outputFragmentColor(\n scope,\n scope.$inputs.worldPos,\n scope.outColor,\n scope.outRoughness,\n scope.outColor\n );\n } else {\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.outColor);\n }\n } else {\n // The support mesh over dry sand is only a carrier for the colour pass.\n // It must not replace terrain depth or its motion vectors in other passes.\n const coverage = this.waveGenerator?.calcSurfaceCoverage;\n if (coverage) {\n scope.$l.surfaceCoverage = coverage.call(this.waveGenerator, scope, scope.$inputs.clipmapPos.xz);\n scope.$if(pb.lessThanEqual(scope.surfaceCoverage, 1e-3), function () {\n pb.discard();\n });\n }\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\n }\n }\n /**\n * Covariance (x, z, xz) of the wave slopes the shading normal no longer shows\n * at this pixel, or null when the wave generator cannot tell.\n */\n unresolvedSlopeVariance(scope: PBInsideFunctionScope, restXZGrad: PBShaderExp): Nullable<PBShaderExp> {\n const gen = this.waveGenerator;\n return gen?.calcUnresolvedSlopeVariance ? gen.calcUnresolvedSlopeVariance(scope, restXZGrad) : null;\n }\n /**\n * Specular roughness at a world position. The slopes too fine for the pixel\n * leave the normal and are handed to the lobe, GGX alpha^2 taking their\n * variance (Beckmann m^2 = 2 sigma^2 per axis). Without the generator's\n * account of them, distance flattens the normals and the lobe widens with it.\n * Also written to the scene roughness buffer.\n */\n waterRoughness(scope: PBInsideFunctionScope, worldPos: PBShaderExp, restXZGrad: PBShaderExp) {\n const pb = scope.$builder;\n const that = this;\n pb.func('waterRoughness', [pb.vec3('worldPos'), pb.vec4('restXZGrad')], function () {\n const slopeVar = that.unresolvedSlopeVariance(this, this.restXZGrad);\n if (slopeVar) {\n this.$l.slopeVar = slopeVar;\n this.$l.alpha2 = pb.add(\n WATER_BASE_ROUGHNESS ** 4,\n pb.max(pb.add(this.slopeVar.x, this.slopeVar.y), 0)\n );\n this.$return(pb.sqrt(pb.sqrt(this.alpha2)));\n } else {\n this.$l.dist = pb.length(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this)));\n this.$l.normalScale = pb.clamp(pb.div(100, this.dist), 0, 1);\n this.$return(pb.mix(WATER_DISTANT_ROUGHNESS, WATER_BASE_ROUGHNESS, this.normalScale));\n }\n });\n return scope.waterRoughness(worldPos, restXZGrad) as PBShaderExp;\n }\n /**\n * Where to sample the scene behind the water, and the medium path length to it.\n *\n * Refracts the view ray by Snell's law and marches it against the scene depth.\n * Depth-convention independent: projection only reads `clip.xy / clip.w` and\n * all depth comparisons are in view space.\n *\n * @param scope - Current shader scope\n * @param worldPos - Surface point being shaded\n * @param normal - Wave normal at that point, pointing up out of the water\n * @param eyeVecNorm - Normalized direction from the camera to the surface\n * @param screenUV - Screen UV of the surface point\n * @param surfaceViewZ - View-space z of the surface point\n * @param straightDepth01 - Normalized linear depth of the scene behind it\n * @param straightWorldPos - Unrefracted scene world position behind the surface\n * @param straightDist - Straight-line distance from the surface to that scene\n * @param underwater - Whether the eye is below the surface\n * @returns `vec3(uv, pathLength)` - where to sample, and the medium path in meters,\n * {@link BOTTOMLESS_PATH} with only sky behind the surface\n */\n waterRefraction(\n scope: PBInsideFunctionScope,\n worldPos: PBShaderExp,\n normal: PBShaderExp,\n eyeVecNorm: PBShaderExp,\n screenUV: PBShaderExp,\n surfaceViewZ: PBShaderExp,\n straightDepth01: PBShaderExp,\n straightWorldPos: PBShaderExp,\n straightDist: PBShaderExp,\n underwater: PBShaderExp\n ) {\n const pb = scope.$builder;\n const march = this.refractionMode === 'march';\n // Only ever used as a difference of two UVs, so TAA jitter and clip-space Y\n // orientation cancel. Inverse of ShaderHelper.samplePositionFromDepth's mapping.\n pb.func('waterRefractProjectUV', [pb.vec3('worldPos')], function () {\n this.$l.h = pb.mul(ShaderHelper.getViewProjectionMatrix(this), pb.vec4(this.worldPos, 1));\n this.$return(pb.add(pb.mul(pb.div(this.h.xy, pb.max(this.h.w, 1e-6)), 0.5), pb.vec2(0.5)));\n });\n // Sample UV for a refracted ray ending at `hitPos`, faded to the straight\n // sample at the screen border.\n pb.func(\n 'waterRefractUV',\n [pb.vec2('screenUV'), pb.vec2('uvBase'), pb.vec3('hitPos'), pb.float('scale')],\n function () {\n this.$l.uv = pb.add(\n this.screenUV,\n pb.mul(pb.sub(this.waterRefractProjectUV(this.hitPos), this.uvBase), this.scale)\n );\n this.$l.edge = pb.min(\n pb.min(this.uv.x, pb.sub(1, this.uv.x)),\n pb.min(this.uv.y, pb.sub(1, this.uv.y))\n );\n this.$return(pb.mix(this.screenUV, this.uv, pb.clamp(pb.div(this.edge, REFRACT_EDGE_FADE), 0, 1)));\n }\n );\n // Declared only in `march` mode: a dead function still forces the depth\n // texture and projection matrices into the bind group.\n if (march) {\n // Returns (uv, rayViewZ - sceneViewZ) at `t` meters along the ray.\n // Positive: ray still in front of the scene. Negative: passed through it.\n pb.func(\n 'waterRefractStep',\n [\n pb.vec3('worldPos'),\n pb.vec3('refractDir'),\n pb.vec2('screenUV'),\n pb.vec2('uvBase'),\n pb.float('rayViewZ'),\n pb.float('cameraFar'),\n pb.float('t')\n ],\n function () {\n this.$l.uv = this.waterRefractUV(\n this.screenUV,\n this.uvBase,\n pb.add(this.worldPos, pb.mul(this.refractDir, this.t)),\n this.refractionScale\n );\n this.$l.linearDepth = ShaderHelper.sampleLinearDepth(\n this,\n ShaderHelper.getLinearDepthTexture(this),\n this.uv,\n 0\n );\n this.$l.sceneViewZ = pb.mul(pb.neg(this.linearDepth), this.cameraFar);\n this.$return(pb.vec3(this.uv, pb.sub(this.rayViewZ, this.sceneViewZ)));\n }\n );\n // First crossing of the refracted ray with the depth buffer. A hit is a\n // step inside the thickness band or a sign change of the gap; an object\n // poking out of the water is negative from the first step and never hits.\n pb.func(\n 'waterRefractMarch',\n [\n pb.vec3('worldPos'),\n pb.vec3('refractDir'),\n pb.vec2('screenUV'),\n pb.vec2('uvBase'),\n pb.float('surfaceViewZ'),\n pb.float('refractStepZ'),\n pb.float('cameraFar'),\n pb.float('maxPath'),\n pb.float('basePath')\n ],\n function () {\n this.$l.step = pb.div(pb.sub(this.maxPath, 0.05), pb.float(REFRACT_MARCH_STEPS));\n this.$l.tPrev = pb.float(0.05);\n this.$l.gapPrev = pb.float(1);\n this.$l.hitUV = this.screenUV;\n this.$l.hitPath = this.basePath;\n this.$for(pb.float('i'), 0, REFRACT_MARCH_STEPS, function () {\n this.$l.t = pb.add(this.tPrev, this.step);\n this.$l.rayViewZ = pb.add(this.surfaceViewZ, pb.mul(this.refractStepZ, this.t));\n this.$l.s = this.waterRefractStep(\n this.worldPos,\n this.refractDir,\n this.screenUV,\n this.uvBase,\n this.rayViewZ,\n this.cameraFar,\n this.t\n );\n this.$l.gap = this.s.z;\n this.$if(\n pb.or(\n pb.lessThan(pb.abs(this.gap), REFRACT_MARCH_THICKNESS),\n pb.lessThan(pb.mul(this.gapPrev, this.gap), 0)\n ),\n function () {\n // Interpolate to the exact crossing.\n this.$l.k = pb.div(this.gapPrev, pb.sub(this.gapPrev, this.gap));\n this.hitUV = this.s.xy;\n this.hitPath = pb.mix(this.tPrev, this.t, this.k);\n this.$break();\n }\n ).$else(function () {\n this.tPrev = this.t;\n this.gapPrev = this.gap;\n });\n });\n this.$return(pb.vec3(this.hitUV, this.hitPath));\n }\n );\n }\n pb.func(\n 'waterRefraction',\n [\n pb.vec3('worldPos'),\n pb.vec3('normal'),\n pb.vec3('eyeVecNorm'),\n pb.vec2('screenUV'),\n pb.float('surfaceViewZ'),\n pb.float('straightDepth01'),\n pb.vec3('straightWorldPos'),\n pb.float('straightDist'),\n pb.bool('underwater')\n ],\n function () {\n this.$l.faceNormal = this.$choice(this.underwater, pb.neg(this.normal), this.normal);\n this.$l.eta = this.$choice(this.underwater, pb.float(WATER_TO_AIR_ETA), pb.float(AIR_TO_WATER_ETA));\n this.$l.uvBase = this.waterRefractProjectUV(this.worldPos);\n // Sky behind the water has no bottom. Its point lies on the far plane,\n // so the straight distance falls to 0 where the surface crosses that\n // plane and the water there would show the sky unabsorbed.\n this.$if(pb.greaterThanEqual(this.straightDepth01, SCENE_SKY_DEPTH01), function () {\n this.$return(pb.vec3(this.screenUV, SKY_MEDIUM_PATH));\n });\n this.$l.waterCrossDir = pb.normalize(pb.sub(this.straightWorldPos, this.worldPos));\n // refractDir = view line + (refract by wave normal - refract by flat\n // normal), so calm water samples exactly the straight hit. The flat\n // normal carries the same facing flip so the two cancel from either side.\n this.$l.refractWave = pb.refract(this.eyeVecNorm, this.faceNormal, this.eta);\n this.$l.refractFlatNormal = pb.vec3(0, pb.sign(this.faceNormal.y), 0);\n this.$l.refractFlat = pb.refract(this.eyeVecNorm, this.refractFlatNormal, this.eta);\n // Total internal reflection makes refract return zero.\n this.$l.refractDir = pb.add(this.waterCrossDir, pb.sub(this.refractWave, this.refractFlat));\n this.$if(pb.lessThan(pb.length(pb.sub(this.refractWave, this.refractFlat)), 1e-4), function () {\n this.refractDir = this.waterCrossDir;\n });\n this.$if(pb.lessThan(pb.dot(this.refractDir, this.refractDir), 1e-6), function () {\n this.refractDir = this.waterCrossDir;\n });\n this.refractDir = pb.normalize(this.refractDir);\n this.$l.refractUV = this.screenUV;\n this.$l.refractPath = this.straightDist;\n if (!march) {\n // Fixed step, not the scene distance: that jumps across silhouettes\n // and paints a second copy of the object.\n this.refractUV = this.waterRefractUV(\n this.screenUV,\n this.uvBase,\n pb.add(this.worldPos, pb.mul(this.refractDir, this.cheapRefractionDepth)),\n this.refractionScale\n );\n this.$return(pb.vec3(this.refractUV, this.refractPath));\n } else {\n this.$l.refractDirView = pb.mul(ShaderHelper.getViewMatrix(this), pb.vec4(this.refractDir, 0)).xyz;\n this.$l.refractStepZ = pb.min(this.refractDirView.z, -1e-4);\n this.$l.maxPath = pb.mul(this.straightDist, REFRACT_MAX_PATH_RATIO);\n this.$l.marchResult = this.waterRefractMarch(\n this.worldPos,\n this.refractDir,\n this.screenUV,\n this.uvBase,\n this.surfaceViewZ,\n this.refractStepZ,\n ShaderHelper.getCameraParams(this).y,\n this.maxPath,\n this.straightDist\n );\n this.refractUV = this.marchResult.xy;\n this.refractPath = pb.clamp(this.marchResult.z, 0, this.maxPath);\n // A finite scene point above the surface at the refracted UV is an\n // object poking through: fall back to the straight sample.\n this.$l.sceneHit = ShaderHelper.samplePositionFromDepth(\n this,\n ShaderHelper.getLinearDepthTexture(this),\n this.refractUV,\n ShaderHelper.getJitteredInvVPMatrix(this),\n ShaderHelper.getCameraParams(this).xy\n );\n this.$if(\n pb.and(pb.lessThan(this.sceneHit.w, 0.999), pb.greaterThan(this.sceneHit.y, this.worldPos.y)),\n function () {\n this.refractUV = this.screenUV;\n this.refractPath = this.straightDist;\n }\n );\n this.$return(pb.vec3(this.refractUV, this.refractPath));\n }\n }\n );\n return scope.waterRefraction(\n worldPos,\n normal,\n eyeVecNorm,\n screenUV,\n surfaceViewZ,\n straightDepth01,\n straightWorldPos,\n straightDist,\n underwater\n ) as PBShaderExp;\n }\n /**\n * Sunlight scattered out of the water column towards the eye. Closed-form\n * single scattering in a homogeneous medium.\n *\n * With `t` the distance along the refracted view ray, `d` its length in the\n * water, `vy`/`sy` the descent rates of the view and sun rays, and\n * `r = vy / sy`:\n *\n * ```\n * S = integral(0..d) sigma_s * p * E * exp(-sigma_t * t * (1 + r)) dt\n * = albedo * p * E * (1 - exp(-sigma_t * (1 + r) * d)) / (1 + r)\n * ```\n *\n * No `NoL` factor: that geometry is already in `r`. Only the entry Fresnel is\n * applied; the exit transmission is applied once by the caller. Assumes the\n * eye is above the surface.\n *\n * @param scope - Current shader scope.\n * @param lightEnergy - Sun irradiance perpendicular to the beam, after shadowing.\n * @param lightDir - Unit vector from the surface towards the light.\n * @param eyeVecNorm - Unit vector from the camera towards the surface.\n * @param NoL - Cosine of the sun's incidence on the wave normal.\n * @param depth - Refracted path length through the medium, in meters.\n * @returns Radiance scattered towards the eye, before the exit Fresnel.\n */\n waterSunScattering(\n scope: PBInsideFunctionScope,\n lightEnergy: PBShaderExp,\n lightDir: PBShaderExp,\n eyeVecNorm: PBShaderExp,\n NoL: PBShaderExp,\n depth: PBShaderExp,\n foam: PBShaderExp\n ) {\n const pb = scope.$builder;\n pb.func(\n 'waterSunScattering',\n [\n pb.vec3('lightEnergy'),\n pb.vec3('lightDir'),\n pb.vec3('eyeVecNorm'),\n pb.float('NoL'),\n pb.float('depth'),\n pb.float('foam')\n ],\n function () {\n this.$l.up = pb.vec3(0, 1, 0);\n // Directions inside the water. The sun travels opposite to `lightDir`.\n this.$l.Lw = pb.refract(pb.neg(this.lightDir), this.up, AIR_TO_WATER_ETA);\n this.$l.Vw = pb.refract(this.eyeVecNorm, this.up, AIR_TO_WATER_ETA);\n this.$l.sy = pb.max(pb.neg(this.Lw.y), MIN_SUN_SLOPE);\n this.$l.vy = pb.max(pb.neg(this.Vw.y), 1e-3);\n this.$l.r = pb.div(this.vy, this.sy);\n this.$l.rr = pb.add(1, this.r);\n this.$l.cosTheta = pb.neg(pb.dot(this.Lw, this.Vw));\n this.$l.hg = waterScatterPhase(this, this.cosTheta, this.sunScatterParams.y);\n // Blend towards isotropic with optical thickness (multiple scattering).\n // Luminance-weighted: the phase is wavelength independent.\n this.$l.lumWeights = pb.vec3(0.2126, 0.7152, 0.0722);\n this.$l.extLum = pb.dot(this.mediumExtinction, this.lumWeights);\n this.$l.albedoLum = pb.dot(this.mediumAlbedo, this.lumWeights);\n this.$l.thickness = pb.mul(\n this.albedoLum,\n pb.sub(1, pb.exp(pb.neg(pb.mul(this.extLum, this.depth))))\n );\n this.$l.phase = pb.mix(\n this.hg,\n 1 / (4 * Math.PI),\n pb.smoothStep(0, 0.5, pb.clamp(this.thickness, 0, 1))\n );\n this.$l.k = pb.mul(this.mediumExtinction, this.rr);\n this.$l.integral = pb.div(pb.sub(pb.vec3(1), pb.exp(pb.neg(pb.mul(this.k, this.depth)))), this.rr);\n // Entry Fresnel. Zero at NoL <= 0, where the subsurface term takes over.\n // Foam is a mass of bubbles, not a mirror, so it blends towards full\n // transmission.\n this.$l.entry = pb.sub(1, pb.add(WATER_F0, pb.mul(1 - WATER_F0, pb.pow(pb.sub(1, this.NoL), 5))));\n this.$l.entry = pb.mix(this.entry, pb.float(1), this.foam);\n this.$return(\n pb.mul(\n this.mediumAlbedo,\n this.lightEnergy,\n this.integral,\n pb.mul(this.phase, this.entry, this.sunScatterParams.x)\n )\n );\n }\n );\n return scope.waterSunScattering(lightEnergy, lightDir, eyeVecNorm, NoL, depth, foam) as PBShaderExp;\n }\n waterShading(\n scope: PBInsideFunctionScope,\n worldPos: PBShaderExp,\n worldNormal: PBShaderExp,\n foamFactor: PBShaderExp,\n crestHeight: PBShaderExp,\n restXZ: PBShaderExp,\n restXZGrad: PBShaderExp,\n foamSample: PBShaderExp,\n coverage: PBShaderExp,\n sheetThickness: PBShaderExp,\n wallFoam: PBShaderExp,\n scenePos: PBShaderExp,\n groundFoamDensity: PBShaderExp,\n groundFoamSample: PBShaderExp,\n groundNormal: PBShaderExp,\n groundFoamWeight: PBShaderExp\n ) {\n const pb = scope.$builder;\n const that = this;\n const debugOutput = this.debugOutput;\n const hasGroundFoam = !!(this._shoreWaveGenerator && this._foamFieldGenerator);\n // The environment's prefiltered radiance, for the distant sky reflection\n const envLight = this.needCalculateEnvLight() ? (this.drawContext.env?.light.envLight ?? null) : null;\n // Transmittance over `depth` meters of path.\n pb.func('getAbsorption', [pb.float('depth')], function () {\n this.$return(pb.exp(pb.neg(pb.mul(this.mediumExtinction, this.depth))));\n });\n // Fraction of incident irradiance scattered back over `depth` meters of path.\n pb.func('getScattering', [pb.float('depth')], function () {\n this.$return(\n pb.mul(\n this.mediumAlbedo,\n pb.sub(pb.vec3(1), pb.exp(pb.neg(pb.mul(this.mediumExtinction, this.depth))))\n )\n );\n });\n // Mean Fresnel over a Gaussian distribution of unresolved slopes of standard\n // deviation `sigmaV` along the view direction, Bruneton, Neyret & Holzschuch,\n // \"Real-time Realistic Ocean Lighting using Seamless Transitions from Geometry\n // to BRDF\" (Eurographics 2010), as their ocean demo fits it:\n // (1 - cos)^(5 exp(-2.69 sigma)) / (1 + 22.7 sigma^1.5), Schlick at sigma = 0.\n pb.func('meanFresnel', [pb.float('cosThetaV'), pb.float('sigmaV')], function () {\n this.$return(\n pb.div(\n pb.pow(pb.sub(1, this.cosThetaV), pb.mul(5, pb.exp(pb.mul(-2.69, this.sigmaV)))),\n pb.add(1, pb.mul(22.7, pb.pow(this.sigmaV, 1.5)))\n )\n );\n });\n pb.func(\n 'fresnel',\n [pb.vec3('normal'), pb.vec3('eyeVec'), pb.bool('underwater'), pb.float('sigmaV')],\n function () {\n // abs, not clamp: a folded crest flips the sign inside one wave, and a\n // clamp would drop to F0 exactly at the most grazing geometry.\n this.$l.NoV = pb.clamp(pb.abs(pb.dot(this.normal, this.eyeVec)), 0, 1);\n this.$if(this.underwater, function () {\n this.$l.sinT2 = pb.mul(WATER_TO_AIR_ETA * WATER_TO_AIR_ETA, pb.sub(1, pb.mul(this.NoV, this.NoV)));\n // Total internal reflection outside the Snell window. Not scaled by\n // reflectionStrength: there is no transmitted ray to reveal.\n this.$l.f = pb.float(1);\n this.$if(pb.lessThan(this.sinT2, 1), function () {\n // Schlick takes the cosine on the less dense side. F0 is symmetric.\n this.$l.cosT = pb.sqrt(pb.max(pb.sub(1, this.sinT2), 0));\n this.f = pb.clamp(\n pb.mul(\n pb.add(WATER_F0, pb.mul(1 - WATER_F0, pb.pow(pb.sub(1, this.cosT), 5))),\n this.reflectionStrength\n ),\n 0,\n 1\n );\n });\n this.$return(this.f);\n });\n this.$l.f = pb.add(WATER_F0, pb.mul(1 - WATER_F0, this.meanFresnel(this.NoV, this.sigmaV)));\n this.$return(pb.clamp(pb.mul(this.f, this.reflectionStrength), 0, 1));\n }\n );\n pb.func(\n 'lightSpecular',\n [\n pb.vec3('lightDir'),\n pb.vec3('eyeVecNorm'),\n pb.vec3('normal'),\n pb.vec3('lightColor'),\n pb.float('roughness')\n ],\n function () {\n this.$l.f0 = pb.vec3(WATER_F0);\n this.$l.f90 = pb.vec3(1);\n this.$l.L = this.lightDir;\n this.$l.V = pb.neg(this.eyeVecNorm);\n this.$l.halfVec = pb.normalize(pb.add(this.L, this.V));\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.halfVec), 0, 1);\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\n this.$l.specular = pb.vec3(0);\n this.$if(pb.greaterThan(this.NoL, 0), function () {\n this.$l.VoH = pb.clamp(pb.dot(this.V, this.halfVec), 0, 1);\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.V), 0, 1);\n this.$l.F = fresnelSchlick(this, this.VoH, this.f0, this.f90);\n this.$l.alphaRoughness = pb.mul(this.roughness, this.roughness);\n this.$l.D = distributionGGX(this, this.NoH, this.alphaRoughness);\n this.$l.VIS = visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\n this.specular = pb.mul(this.D, this.VIS, this.F, this.lightColor);\n });\n this.$return(this.specular);\n }\n );\n // White foam revealed from a foam texture sample (value, slopes along x\n // and z) by a density, Crest's feathered black point; as (white foam, its\n // slope along x, along z).\n pb.func('waterWhiteFoam', [pb.float('density'), pb.vec3('tex'), pb.float('feather')], function () {\n this.$l.t = pb.clamp(\n pb.div(pb.sub(this.tex.x, pb.sub(1, pb.clamp(this.density, 0, 1))), this.feather),\n 0,\n 1\n );\n this.$return(\n pb.vec3(\n pb.mul(this.t, this.t, pb.sub(3, pb.mul(this.t, 2))),\n pb.mul(this.tex.yz, pb.div(pb.mul(6, this.t, pb.sub(1, this.t)), this.feather))\n )\n );\n });\n pb.func(\n 'waterShading',\n [\n pb.vec3('worldPos'),\n pb.vec3('worldNormal'),\n pb.float('foamFactor'),\n pb.float('crestHeight'),\n pb.vec2('restXZ'),\n pb.vec4('restXZGrad'),\n pb.vec3('foamSample'),\n pb.float('coverage'),\n pb.float('sheetThickness'),\n pb.float('wallFoam'),\n pb.vec4('scenePos'),\n pb.float('groundFoamDensity'),\n pb.vec3('groundFoamSample'),\n pb.vec3('groundNormal'),\n pb.float('groundFoamWeight')\n ],\n function () {\n this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), ShaderHelper.getRenderSize(this));\n this.$l.dist = pb.length(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this)));\n const slopeVar = that.unresolvedSlopeVariance(this, this.restXZGrad);\n if (slopeVar) {\n // The generator has already faded the slopes too fine for the pixel\n this.$l.slopeVar = slopeVar;\n this.$l.normal = pb.normalize(this.worldNormal);\n } else {\n this.$l.normalScale = pb.clamp(pb.div(100, this.dist), 0, 1);\n this.$l.normal = pb.normalize(\n pb.mul(this.worldNormal, pb.vec3(this.normalScale, 1, this.normalScale))\n );\n }\n this.$l.roughness = that.waterRoughness(this, this.worldPos, this.restXZGrad);\n this.$l.wPos = this.scenePos;\n this.$l.eyeVec = pb.sub(this.worldPos.xyz, ShaderHelper.getCameraPosition(this));\n this.$l.eyeVecNorm = pb.normalize(this.eyeVec);\n // Mirror-term normal, turned towards the eye on a folded underside.\n // Flipped on the cosine, not on `frontFacing`, which is discontinuous\n // along the fold's triangle edge. `eyeVecNorm` points camera -> surface,\n // so the flip case is the positive dot.\n this.$l.shadingNormal = this.$choice(\n pb.greaterThan(pb.dot(this.normal, this.eyeVecNorm), 0),\n pb.neg(this.normal),\n this.normal\n );\n // Diffuse-term normal, from the unflipped wave normal (the eye-facing\n // flip would point it into the lower hemisphere on any steep back\n // slope), mixed towards up as normal.y falls.\n this.$l.diffuseWeight = pb.smoothStep(0, 0.5, this.normal.y);\n this.$l.diffuseNormal = pb.normalize(pb.mix(pb.vec3(0, 1, 0), this.normal, this.diffuseWeight));\n // Eye below the rest plane, not `!frontFacing`: a choppy fold (J < 0)\n // flips the winding and would read as seen from below.\n this.$l.restLevel = pb.sub(this.worldPos.y, this.crestHeight);\n this.$l.underwaterEye = pb.or(\n pb.lessThan(this.eyeSide, 0),\n pb.and(\n pb.equal(this.eyeSide, 0),\n pb.lessThan(ShaderHelper.getCameraPosition(this).y, this.restLevel)\n )\n );\n this.$l.depth = pb.length(pb.sub(this.wPos.xyz, this.worldPos));\n this.$l.viewPos = pb.mul(ShaderHelper.getViewMatrix(this), pb.vec4(this.worldPos, 1)).xyz;\n this.incidentVec = pb.normalize(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this)));\n this.reflectVecW = pb.reflect(this.incidentVec, this.shadingNormal);\n this.$l.reflectance = pb.vec3();\n this.$l.hitInfo = pb.vec4(0);\n // Trace only rays leaving the surface: up from above, down from below.\n this.$if(\n this.$choice(\n this.underwaterEye,\n pb.lessThan(this.reflectVecW.y, 0),\n pb.greaterThan(this.reflectVecW.y, 0)\n ),\n function () {\n this.reflectVec = pb.mul(ShaderHelper.getViewMatrix(this), pb.vec4(this.reflectVecW, 0)).xyz;\n this.hitInfo = ShaderHelper.getHiZDepthTexture(this)\n ? screenSpaceRayTracing_HiZ(\n this,\n this.viewPos,\n this.reflectVec,\n ShaderHelper.getViewMatrix(this),\n ShaderHelper.getProjectionMatrix(this),\n ShaderHelper.getInvProjectionMatrix(this),\n ShaderHelper.getCameraParams(this).xy,\n pb.int(ShaderHelper.getHiZDepthTextureMipLevelCount(this)),\n this.ssrParams.y,\n this.ssrParams.x,\n this.ssrParams.z,\n pb.vec4(ShaderHelper.getRenderSize(this), ShaderHelper.getHiZDepthTextureSize(this)),\n ShaderHelper.getHiZDepthTexture(this)\n )\n : screenSpaceRayTracing_Linear2D(\n this,\n this.viewPos,\n this.reflectVec,\n ShaderHelper.getViewMatrix(this),\n ShaderHelper.getProjectionMatrix(this),\n ShaderHelper.getInvProjectionMatrix(this),\n ShaderHelper.getCameraParams(this).xy,\n this.ssrParams.x,\n this.ssrParams.y,\n this.ssrParams.z,\n this.ssrParams.w,\n pb.vec4(ShaderHelper.getRenderSize(this), ShaderHelper.getLinearDepthTextureSize(this)),\n ShaderHelper.getLinearDepthTexture(this)\n );\n }\n );\n this.$l.refl = pb.reflect(\n pb.normalize(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this))),\n this.shadingNormal\n );\n // Fallback where the trace misses. From above: the sky, with the\n // reflection y floored so grazing rays do not read the bake's black\n // lower hemisphere. From below: the medium's asymptotic colour\n // albedo * ambient, the d -> inf limit of the underwater pass.\n this.$l.reflMiss = pb.vec3();\n this.$if(this.underwaterEye, function () {\n this.$l.downwelling = ShaderHelper.sampleBakedSkyPreExposed(this, pb.vec3(0, 1, 0));\n this.reflMiss = pb.mul(this.mediumAlbedo, this.downwelling);\n }).$else(function () {\n this.refl.y = pb.max(this.refl.y, HORIZON_REFLECT_BIAS);\n this.refl = pb.normalize(this.refl);\n // The mirror image of the visible sky, at its on-screen scale: the bake\n // brought to the live exposure without the environment light's\n // strength, which dims the IBL and not the sky itself.\n this.reflMiss = pb.mul(\n pb.textureSampleLevel(ShaderHelper.getBakedSkyTexture(this), this.refl, 0).rgb,\n this.skyReflectScale\n );\n if (envLight?.hasRadiance()) {\n // Blurred as the distant normals are: the prefiltered radiance at\n // the surface's roughness, in the same pre-exposed space\n this.$l.skyBlur = pb.smoothStep(SKY_PREFILTER_START, SKY_PREFILTER_FULL, this.roughness);\n this.$if(pb.greaterThan(this.skyBlur, 0), function () {\n this.reflMiss = pb.mix(\n this.reflMiss,\n pb.mul(envLight.getRadiance(this, this.refl, this.roughness)!.rgb, this.skyReflectScale),\n this.skyBlur\n );\n });\n }\n });\n // The traced reflection blurred by roughness as Uludag's cone-traced\n // reflections blur it (\"Hi-Z Screen-Space Cone-Traced Reflections\",\n // GPU Pro 5, 2014): the lobe as a cone of half angle\n // acos(0.244^(1 / (n + 1))) for a Phong power n, here\n // n = 2 / alpha^2 - 2 for the GGX alpha (Walter et al., \"Microfacet\n // Models for Refraction through Rough Surfaces\", EGSR 2007); its\n // footprint where the ray hits the radius of the circle inscribed in\n // the isosceles triangle of the cone over the screen-space ray, in\n // pixels; and the scene colour read at the level of that radius\n this.$l.alpha = pb.mul(this.roughness, this.roughness);\n this.$l.phongPower = pb.max(pb.sub(pb.div(2, pb.max(pb.mul(this.alpha, this.alpha), 1e-6)), 2), 0);\n this.$l.coneCos = pb.pow(0.244, pb.div(1, pb.add(this.phongPower, 1)));\n this.$l.coneTan = pb.div(\n pb.sqrt(pb.max(pb.sub(1, pb.mul(this.coneCos, this.coneCos)), 0)),\n pb.max(this.coneCos, 1e-4)\n );\n this.$l.coneBase = pb.mul(2, this.coneTan, this.hitInfo.z);\n this.$l.coneRadius = pb.div(\n pb.mul(\n this.coneBase,\n pb.sub(\n pb.sqrt(\n pb.add(pb.mul(this.coneBase, this.coneBase), pb.mul(4, this.hitInfo.z, this.hitInfo.z))\n ),\n this.coneBase\n )\n ),\n pb.max(pb.mul(4, this.hitInfo.z), 1e-4)\n );\n this.$l.reflectLod = pb.clamp(pb.log2(pb.max(this.coneRadius, 1)), 0, REFRACT_BLUR_MAX_LOD);\n this.reflectance = pb.mix(\n this.reflMiss,\n pb.textureSampleLevel(ShaderHelper.getSceneColorTexture(this), this.hitInfo.xy, this.reflectLod)\n .rgb,\n this.hitInfo.w\n );\n this.$l.refractInfo = that.waterRefraction(\n this,\n this.worldPos,\n this.normal,\n this.eyeVecNorm,\n this.screenUV,\n this.viewPos.z,\n this.wPos.w,\n this.wPos.xyz,\n this.depth,\n this.underwaterEye\n );\n this.$l.refractUV = this.refractInfo.xy;\n // Medium path is the refracted length, not the straight line.\n this.depth = this.refractInfo.z;\n // Zero from below: the column the eye is inside belongs to the\n // Underwater pass, and charging it twice smears the Snell window.\n this.$l.mediumPath = this.$choice(this.underwaterEye, pb.float(0), this.depth);\n // Blur LOD: log2 in path length (each mip doubles the width), driven by\n // scattering rather than extinction (absorption darkens without blurring).\n this.$l.refractBlur = pb.log2(\n pb.add(1, pb.mul(this.mediumPath, pb.add(REFRACT_BLUR_GEOMETRIC, this.refractBlurDensity)))\n );\n this.$l.refraction = pb.textureSampleLevel(\n ShaderHelper.getSceneColorTexture(this),\n this.refractUV,\n pb.clamp(this.refractBlur, 0, REFRACT_BLUR_MAX_LOD)\n ).rgb;\n this.$l.refractionRaw = this.refraction;\n this.$l.absorption = this.getAbsorption(this.mediumPath);\n this.refraction = pb.mul(this.refraction, this.absorption);\n this.$l.viewXZ = pb.neg(this.eyeVecNorm.xz);\n if (slopeVar) {\n // Variance of the slopes the normal no longer shows along the view\n // direction, as Bruneton's MeanFresnel takes it\n this.$l.sigmaV = pb.sqrt(\n pb.max(\n pb.div(\n pb.add(\n pb.mul(this.viewXZ.x, this.viewXZ.x, this.slopeVar.x),\n pb.mul(this.viewXZ.y, this.viewXZ.y, this.slopeVar.y),\n pb.mul(this.viewXZ.x, this.viewXZ.y, this.slopeVar.z, 2)\n ),\n pb.max(pb.dot(this.viewXZ, this.viewXZ), 1e-6)\n ),\n 0\n )\n );\n } else {\n // Variance of the slopes the flattened normal no longer shows, (1 - k^2)\n // of the sea's for a slope scaled by k, along the view direction in wind\n // space as Bruneton's MeanFresnel takes it\n this.$l.viewWind = pb.vec2(\n pb.dot(this.viewXZ, this.unresolvedSlope.xy),\n pb.dot(this.viewXZ, pb.vec2(pb.neg(this.unresolvedSlope.y), this.unresolvedSlope.x))\n );\n this.$l.viewWindT = pb.div(\n pb.mul(this.viewWind, this.viewWind),\n pb.max(pb.dot(this.viewXZ, this.viewXZ), 1e-6)\n );\n this.$l.sigmaV = pb.sqrt(\n pb.mul(\n pb.dot(this.viewWindT, this.unresolvedSlope.zw),\n pb.sub(1, pb.mul(this.normalScale, this.normalScale))\n )\n );\n }\n this.$l.fresnelTerm = this.fresnel(\n this.shadingNormal,\n pb.neg(this.eyeVecNorm),\n this.underwaterEye,\n this.sigmaV\n );\n // Foam density from the wave generator: crests, wakes, breaking shore waves\n this.$l.crestDensity = pb.clamp(\n pb.mul(pb.pow(pb.clamp(this.foamFactor, 0, 1), this.foamShadingParams.y), this.foamShadingParams.x),\n 0,\n 1\n );\n this.$l.crestWhite = this.waterWhiteFoam(this.crestDensity, this.foamSample, this.foamLookParams.x);\n // Wall foam, cut from the same texture by its own density: whole against\n // the wall, fraying as it thins. Its strength scales opacity after the cut.\n this.$l.wallDensity = pb.clamp(this.wallFoam, 0, 1);\n this.$l.wallCut = this.waterWhiteFoam(this.wallDensity, this.foamSample, this.foamLookParams.x);\n this.$l.wallWhite = pb.mul(this.wallCut.x, this.foamShadingParams.z);\n // The two layers combine as independent covers.\n this.$l.foam = pb.sub(1, pb.mul(pb.sub(1, this.crestWhite.x), pb.sub(1, this.wallWhite)));\n this.$l.foamGrad = pb.add(\n pb.mul(this.crestWhite.yz, pb.sub(1, this.wallWhite)),\n pb.mul(this.wallCut.yz, this.foamShadingParams.z, pb.sub(1, this.crestWhite.x))\n );\n this.$l.bubbleDensity = pb.sub(\n 1,\n pb.mul(pb.sub(1, this.crestDensity), pb.sub(1, pb.mul(this.wallDensity, this.foamShadingParams.z)))\n );\n // Normal of the white foam's relief: Crest differences the cut over a\n // quarter texel per metre of view depth, which keeps the relief at a\n // distance; the slope times that step here\n this.$l.foamStep = pb.mul(this.dist, 0.25, foamTexelSize(this, this.foamTex, this.foamUVScale));\n this.$l.foamNormal = pb.normalize(\n pb.add(\n this.diffuseNormal,\n pb.mul(\n pb.vec3(pb.neg(this.foamGrad.x), 0, pb.neg(this.foamGrad.y)),\n this.foamLookParams.y,\n this.foamStep\n )\n )\n );\n // The white foam covers the water, its mirror and what is seen through\n // it alike, as Crest lays it over the finished water colour\n // (lerp(col, whiteFoam, a)): both only on the share without foam.\n // `bodyWeight`, the exit transmission on that share, weighs the\n // refraction and every body term below.\n this.$l.waterShare = pb.sub(1, this.foam);\n this.$l.bodyWeight = pb.mul(pb.sub(1, this.fresnelTerm), this.waterShare);\n this.fresnelTerm = pb.mul(this.fresnelTerm, this.waterShare);\n this.$l.finalColor = pb.add(\n pb.mul(this.refraction, this.bodyWeight),\n pb.mul(this.reflectance, this.fresnelTerm)\n );\n // Prefer the wave generator's own ground for the thickness of thin swash.\n this.$l.edgeThickness = this.$choice(\n pb.greaterThanEqual(this.sheetThickness, 0),\n this.sheetThickness,\n // Sky reconstructs to the far plane, which can lie above an infinite\n // surface. With no bottom there, keep the water and foam fully visible.\n this.$choice(\n pb.greaterThanEqual(this.wPos.w, SCENE_SKY_DEPTH01),\n pb.max(this.edgeFadeWidth, 1e-4),\n pb.sub(this.worldPos.y, this.wPos.y)\n )\n );\n this.$l.foamFade = pb.mul(\n this.$choice(\n pb.greaterThanEqual(this.sheetThickness, 0),\n pb.float(1),\n this.$choice(\n pb.greaterThan(this.edgeFadeWidth, 0),\n pb.smoothStep(\n 0,\n pb.max(pb.mul(this.edgeFadeWidth, FOAM_EDGE_FADE_SHARE), 1e-4),\n this.edgeThickness\n ),\n pb.float(1)\n )\n ),\n this.coverage\n );\n // Light the foam sends back, kept apart so the edge fade below can keep\n // the foam on a sheet too thin to show the water\n this.$l.foamRadiance = pb.vec3(0);\n this.$l.groundFoamOpacity = pb.float(0);\n this.$l.groundFoamRadiance = pb.vec3(0);\n if (hasGroundFoam) {\n this.$if(pb.greaterThan(this.groundFoamDensity, 1e-3), function () {\n this.$l.groundFoamWhite = this.waterWhiteFoam(\n pb.clamp(\n pb.mul(pb.pow(this.groundFoamDensity, this.foamShadingParams.y), this.foamShadingParams.x),\n 0,\n 1\n ),\n this.groundFoamSample,\n this.foamLookParams.x\n );\n this.groundFoamOpacity = this.groundFoamWhite.x;\n });\n // The carrier P can still foam while its projected ground Q is dry.\n // Keep that visible cover through the handoff; once P drains, only\n // the ground foam remains. Set opacity before lighting both covers.\n this.groundFoamOpacity = pb.max(this.groundFoamOpacity, pb.mul(this.foam, this.foamFade));\n }\n // Debug accumulators. Dead in the `none` variant.\n this.$l.dbgSubsurface = pb.vec3(0);\n this.$l.dbgSunScatter = pb.vec3(0);\n this.$l.dbgShadow = pb.vec3(1);\n this.$l.dbgSpecular = pb.vec3(0);\n // Subsurface crest gate, after Ceto: the lit wall thins with height,\n // path = max(floor, exp(-softplus(h / H))), gate = exp(-sigma_t *\n // scale * path). On the vertex displacement, not the normal tilt,\n // which is zero at the crest and carries every ripple.\n this.$l.sssT = pb.div(this.crestHeight, this.subsurfaceParams.y);\n // softplus in the overflow-safe form max(t,0) + w*log(1+exp(-|t|/w)).\n this.$l.sssRise = pb.add(\n pb.max(this.sssT, 0),\n pb.mul(\n SSS_HEIGHT_SOFTNESS,\n pb.log(pb.add(1, pb.exp(pb.div(pb.neg(pb.abs(this.sssT)), SSS_HEIGHT_SOFTNESS))))\n )\n );\n this.$l.sssPath = pb.max(pb.exp(pb.neg(this.sssRise)), SSS_CREST_PATH_FLOOR);\n this.$l.sssThickness = pb.exp(\n pb.neg(pb.mul(this.mediumExtinction, pb.mul(this.sssPath, SSS_ABSORPTION_SCALE)))\n );\n // For the debug views that rebuild the sun terms outside the loop.\n this.dbgLightDir = pb.vec3(0, 1, 0);\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\n this.$l.lightAtten = that.calculateLightAttenuation(\n this,\n type,\n this.worldPos,\n posRange,\n dirCutoff,\n extra\n );\n this.$l.lightDir = that.calculateLightDirection(\n this,\n type,\n this.worldPos,\n posRange,\n dirCutoff,\n extra\n );\n this.dbgLightDir = this.lightDir;\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\n this.$l.NoLdiffuse = pb.clamp(pb.dot(this.diffuseNormal, this.lightDir), 0, 1);\n // From the raw cosine, so a lee slope below zero still wraps up.\n this.$l.NoLfoam = pb.clamp(\n pb.div(pb.add(pb.dot(this.foamNormal, this.lightDir), FOAM_LIGHT_WRAP), 1 + FOAM_LIGHT_WRAP),\n 0,\n 1\n );\n this.$l.lightEnergy = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten);\n this.$l.specularTerm = pb.vec3(0);\n // A rect light's mirror image is the rect itself: integrate the GGX\n // lobe over it with LTC, as the PBR materials do. One direction would\n // shrink it to a point highlight on a surface this smooth.\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\n this.$l.rectTerms = evaluateLTCRectLightTerms(\n this,\n this.worldPos,\n this.shadingNormal,\n pb.neg(this.eyeVecNorm),\n this.roughness,\n posRange,\n dirCutoff.xyz,\n extra.xyz\n );\n this.specularTerm = pb.mul(\n colorIntensity.rgb,\n colorIntensity.a,\n this.rectTerms.x,\n pb.add(pb.mul(this.rectTerms.y, WATER_F0), pb.mul(this.rectTerms.z, 1 - WATER_F0))\n );\n }).$else(function () {\n this.specularTerm = this.lightSpecular(\n this.lightDir,\n this.eyeVecNorm,\n this.shadingNormal,\n this.lightEnergy,\n this.roughness\n );\n });\n this.$l.lightContrib = this.specularTerm;\n // Backlit-crest subsurface, after Ceto: grazing^2 * (view ray mirrored\n // in the rest plane, against the sun)^4 * sun-above-horizon fade.\n // Both cosines are floored.\n this.$l.sssToEye = pb.neg(this.eyeVecNorm);\n this.$l.sssGrazing = pb.sub(1, pb.clamp(this.sssToEye.y, 0, 1));\n this.sssGrazing = pb.mix(SSS_GRAZING_FLOOR, 1, pb.mul(this.sssGrazing, this.sssGrazing));\n this.$l.sssMirror = pb.reflect(this.sssToEye, pb.vec3(0, 1, 0));\n this.$l.sssAlign = pb.clamp(pb.dot(pb.neg(this.sssMirror), this.lightDir), 0, 1);\n this.sssAlign = pb.mul(this.sssAlign, this.sssAlign);\n this.sssAlign = pb.mix(SSS_SUN_ALIGN_FLOOR, 1, pb.mul(this.sssAlign, this.sssAlign));\n this.$l.sssSunUp = pb.smoothStep(0, 0.1, this.lightDir.y);\n this.$l.sssFacing = pb.mul(this.sssGrazing, this.sssAlign, this.sssSunUp);\n // Scaled by the light colour as in Crest, and by 1 / pi like the other\n // diffuse terms. Directional lights only; carries `bodyWeight`.\n this.$l.subsurfaceTerm = pb.vec3(0);\n this.$if(pb.equal(type, LIGHT_TYPE_DIRECTIONAL), function () {\n this.subsurfaceTerm = pb.mul(\n this.subsurfaceTint,\n this.lightEnergy,\n pb.mul(this.sssFacing, this.sssThickness, this.subsurfaceParams.x, 1 / Math.PI),\n this.bodyWeight\n );\n this.lightContrib = pb.add(this.lightContrib, this.subsurfaceTerm);\n });\n // Directional only (the integral assumes a parallel beam) and from\n // above only.\n this.$l.sunScatterTerm = pb.vec3(0);\n this.$if(pb.and(pb.equal(type, LIGHT_TYPE_DIRECTIONAL), pb.not(this.underwaterEye)), function () {\n this.sunScatterTerm = pb.mul(\n that.waterSunScattering(\n this,\n this.lightEnergy,\n this.lightDir,\n this.eyeVecNorm,\n this.NoLdiffuse,\n this.depth,\n this.foam\n ),\n this.bodyWeight\n );\n this.lightContrib = pb.add(this.lightContrib, this.sunScatterTerm);\n });\n // Foam as a matte layer, with Crest's narrow glint off its relief.\n this.$l.foamGlint = pb.mul(\n pb.pow(\n pb.max(pb.dot(pb.reflect(this.eyeVecNorm, this.foamNormal), this.lightDir), 0),\n FOAM_SPECULAR_POWER\n ),\n FOAM_SPECULAR_BOOST\n );\n this.$l.foamLight = pb.mul(\n this.lightEnergy,\n this.foam,\n pb.add(pb.mul(this.foamColor, this.NoLfoam, 1 / Math.PI), pb.vec3(this.foamGlint))\n );\n this.lightContrib = pb.add(this.lightContrib, this.foamLight);\n this.$l.shadow = pb.vec3(1);\n if (shadow) {\n // +Y, not the wave normal, which would jitter the lookup per pixel.\n this.shadow = pb.vec3(that.calculateShadow(this, this.worldPos, pb.vec3(0, 1, 0), this.NoL));\n this.lightContrib = pb.mul(this.lightContrib, this.shadow);\n }\n this.foamRadiance = pb.add(this.foamRadiance, pb.mul(this.foamLight, this.shadow));\n if (hasGroundFoam) {\n this.$if(pb.greaterThan(this.groundFoamOpacity, 0), function () {\n this.$l.groundNoL = pb.clamp(\n pb.div(\n pb.add(pb.dot(this.groundNormal, this.lightDir), FOAM_LIGHT_WRAP),\n 1 + FOAM_LIGHT_WRAP\n ),\n 0,\n 1\n );\n this.$l.groundShadow = pb.vec3(1);\n if (shadow) {\n this.groundShadow = pb.vec3(\n that.calculateShadow(this, this.wPos.xyz, this.groundNormal, this.groundNoL)\n );\n }\n this.groundFoamRadiance = pb.add(\n this.groundFoamRadiance,\n pb.mul(\n this.lightEnergy,\n this.foamColor,\n this.groundNoL,\n this.groundShadow,\n this.groundFoamOpacity,\n 1 / Math.PI\n )\n );\n });\n }\n this.finalColor = pb.add(this.finalColor, this.lightContrib);\n this.dbgSubsurface = pb.add(this.dbgSubsurface, pb.mul(this.subsurfaceTerm, this.shadow));\n this.dbgSunScatter = pb.add(this.dbgSunScatter, pb.mul(this.sunScatterTerm, this.shadow));\n this.dbgShadow = pb.min(this.dbgShadow, this.shadow);\n this.dbgSpecular = pb.add(this.dbgSpecular, pb.mul(this.specularTerm, this.shadow));\n });\n if (that.needCalculateEnvLight()) {\n this.$l.irradiance = that.getEnvLightIrradiance(this, this.diffuseNormal);\n // On `mediumPath`, so zero from below. The foam term is unconditional.\n this.$l.sss = pb.mul(\n this.getScattering(this.mediumPath),\n this.irradiance,\n this.bodyWeight,\n 1 / Math.PI\n );\n this.finalColor = pb.add(this.finalColor, this.sss);\n this.$l.foamAmbient = pb.mul(this.irradiance, this.foamColor, this.foam, 1 / Math.PI);\n this.finalColor = pb.add(this.finalColor, this.foamAmbient);\n this.foamRadiance = pb.add(this.foamRadiance, this.foamAmbient);\n if (hasGroundFoam) {\n this.groundFoamRadiance = pb.add(\n this.groundFoamRadiance,\n pb.mul(\n that.getEnvLightIrradiance(this, this.groundNormal),\n this.foamColor,\n this.groundFoamOpacity,\n 1 / Math.PI\n )\n );\n }\n // Bubbles under the white foam, part of the water body as in Crest,\n // so under the white foam and the mirror: the foam texture blurred and\n // shifted by parallax, as seen at a depth under the surface\n this.$if(pb.greaterThan(this.bubbleDensity, 0), function () {\n this.$l.toEye = pb.neg(this.eyeVecNorm);\n this.$l.bubbleShift = pb.div(\n pb.mul(this.toEye.xz, pb.neg(this.foamLookParams.w)),\n pb.max(pb.dot(this.diffuseNormal, this.toEye), 0.1)\n );\n this.$l.bubbleTex = sampleFoamTexture(\n this,\n this.foamTex,\n pb.mul(\n pb.add(\n this.restXZ,\n this.bubbleShift,\n pb.vec2(pb.mul(ShaderHelper.getElapsedTime(this), FOAM_DRIFT))\n ),\n this.foamUVScale\n ),\n this.restXZGrad,\n this.foamUVScale,\n FOAM_BUBBLE_MIP_SCALE,\n false\n ).x;\n this.finalColor = pb.add(\n this.finalColor,\n pb.mul(\n this.irradiance,\n this.foamBubbleColor,\n this.bubbleTex,\n pb.clamp(pb.mul(this.bubbleDensity, this.foamLookParams.z), 0, 1),\n this.bodyWeight,\n 1 / Math.PI\n )\n );\n });\n }\n // A thin sheet fades into the scene behind it. Where the generator\n // knows the wet edge, its coverage keeps foam visible on even a\n // millimetre-thick sheet; elsewhere foam fades by the measured depth.\n this.$if(pb.not(this.underwaterEye), function () {\n this.$l.edgeFade = pb.mul(\n this.$choice(\n pb.greaterThan(this.edgeFadeWidth, 0),\n pb.smoothStep(0, pb.max(this.edgeFadeWidth, 1e-4), this.edgeThickness),\n pb.float(1)\n ),\n this.coverage\n );\n this.$if(pb.lessThan(this.edgeFade, 1), function () {\n this.$l.behind = pb.textureSampleLevel(\n ShaderHelper.getSceneColorTexture(this),\n this.screenUV,\n 0\n ).rgb;\n // finalColor = water (on the share without foam) + foam light: the\n // water fades into what is behind, under the foam\n this.finalColor = pb.add(\n pb.mix(\n pb.mul(this.behind, pb.sub(1, pb.mul(this.foam, this.foamFade))),\n pb.sub(this.finalColor, this.foamRadiance),\n this.edgeFade\n ),\n pb.mul(this.foamRadiance, this.foamFade)\n );\n });\n if (hasGroundFoam) {\n this.$if(pb.greaterThan(this.groundFoamWeight, 0), function () {\n this.$l.groundBehind = pb.textureSampleLevel(\n ShaderHelper.getSceneColorTexture(this),\n this.screenUV,\n 0\n ).rgb;\n // One crossfade between complete covers. Attenuating the mobile\n // foam before overlaying ground foam applies this weight twice\n // and exposes sand in the middle even if both covers are white.\n this.$l.groundColor = pb.add(\n pb.mul(this.groundBehind, pb.sub(1, this.groundFoamOpacity)),\n this.groundFoamRadiance\n );\n this.finalColor = pb.mix(this.finalColor, this.groundColor, this.groundFoamWeight);\n });\n }\n });\n switch (debugOutput) {\n case 'normal':\n this.$if(pb.lessThan(this.diffuseNormal.y, 0.01), function () {\n this.$return(pb.vec3(1, 0, 0));\n }).$else(function () {\n this.$return(pb.add(pb.mul(this.diffuseNormal, 0.5), pb.vec3(0.5)));\n });\n break;\n case 'foam':\n this.$return(pb.vec3(pb.mix(this.foam, this.groundFoamOpacity, this.groundFoamWeight)));\n break;\n case 'swashFoamCuts':\n this.$return(pb.vec3(this.foam, this.groundFoamOpacity, this.groundFoamWeight));\n break;\n case 'waterDepth':\n this.$return(pb.vec3(pb.mul(pb.max(pb.sub(this.worldPos.y, this.wPos.y), 0), 0.1)));\n break;\n case 'fresnel':\n this.$return(pb.vec3(this.fresnelTerm));\n break;\n case 'reflection':\n this.$return(this.reflectance);\n break;\n case 'refraction':\n this.$return(this.refractionRaw);\n break;\n case 'absorption':\n this.$return(this.absorption);\n break;\n case 'scattering':\n this.$return(this.sss);\n break;\n case 'sunScattering':\n this.$return(this.dbgSunScatter);\n break;\n case 'subsurface':\n this.$return(this.dbgSubsurface);\n break;\n case 'subsurfaceThickness':\n this.$return(pb.vec3(this.sssThickness));\n break;\n case 'shadow':\n this.$return(this.dbgShadow);\n break;\n case 'specular':\n this.$return(this.dbgSpecular);\n break;\n case 'depth':\n this.$return(pb.vec3(pb.mul(this.depth, 0.1)));\n break;\n default:\n this.$return(this.finalColor);\n }\n }\n );\n return scope.waterShading(\n worldPos,\n worldNormal,\n foamFactor,\n crestHeight,\n restXZ,\n restXZGrad,\n foamSample,\n coverage,\n sheetThickness,\n wallFoam,\n scenePos,\n groundFoamDensity,\n groundFoamSample,\n groundNormal,\n groundFoamWeight\n );\n }\n applyUniforms(bindGroup: BindGroup, ctx: DrawContext, needUpdate: boolean, pass: number) {\n super.applyUniforms(bindGroup, ctx, needUpdate, pass);\n const waveGenerator = this._effectiveWaveGenerator;\n // Per bind group: the material owns one per pass/variant hash.\n const lastWritten = this._waveVersionByBindGroup.get(bindGroup) ?? -1;\n if (waveGenerator && lastWritten !== waveGenerator.version) {\n waveGenerator.applyWaterBindGroup(bindGroup);\n this._waveVersionByBindGroup.set(bindGroup, waveGenerator.version);\n }\n }\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\n super.applyUniformValues(bindGroup, ctx, pass);\n bindGroup.setValue('clipmapGridInfo', this._clipmapGridInfo);\n if (this.infinite) {\n bindGroup.setValue('skirtDistance', this._skirtDistance);\n } else {\n bindGroup.setValue('region', this._region);\n }\n if (this.needFragmentColor(ctx)) {\n bindGroup.setValue('refractionScale', this._refractionScale);\n if (this.refractionMode === 'offset') {\n bindGroup.setValue('cheapRefractionDepth', this._cheapRefractionDepth);\n }\n bindGroup.setValue('reflectionStrength', this._reflectionStrength);\n const wind = this._waveGenerator.get()?.wind;\n const windSpeed = wind ? Math.hypot(wind.x, wind.y) : 0;\n this._unresolvedSlope.setXYZW(\n windSpeed > 0 ? wind!.x / windSpeed : 1,\n windSpeed > 0 ? wind!.y / windSpeed : 0,\n COX_MUNK_UPWIND * windSpeed,\n COX_MUNK_CROSSWIND_BASE + COX_MUNK_CROSSWIND * windSpeed\n );\n bindGroup.setValue('unresolvedSlope', this._unresolvedSlope);\n bindGroup.setValue(\n 'skyReflectScale',\n ctx.scene.lightingMode === 'physical' ? ShaderHelper.getPreExposure(ctx) / PHYSICAL_BAKE_EXPOSURE : 1\n );\n bindGroup.setValue('ssrParams', this._ssrParams);\n const eyeUnder = ctx.underwater;\n bindGroup.setValue('eyeSide', eyeUnder ? (eyeUnder.material === this ? -1 : 0) : 1);\n this._subsurfaceParams.setXYZW(this._subsurfaceIntensity, this._subsurfaceCrestHeight, 0, 0);\n bindGroup.setValue('subsurfaceParams', this._subsurfaceParams);\n bindGroup.setValue('subsurfaceTint', this._subsurfaceTint);\n this._foamParams.setXYZW(\n this._foamAmount,\n this._foamFalloff,\n this._shoreWaves.height > 0 ? this._shoreWaves.wallFoamStrength! : 0,\n 0\n );\n bindGroup.setValue('foamShadingParams', this._foamParams);\n bindGroup.setValue('foamColor', this._foamColor);\n this._foamLookParams.setXYZW(\n this._foamFeather,\n this._foamNormalStrength,\n this._foamBubbleCoverage,\n this._foamBubbleDepth\n );\n bindGroup.setValue('foamLookParams', this._foamLookParams);\n bindGroup.setValue('foamBubbleColor', this._foamBubbleColor);\n bindGroup.setTexture(\n 'foamTex',\n this.foamTexture ?? getDefaultFoamTexture(),\n fetchSampler('repeat_linear')\n );\n bindGroup.setValue('foamUVScale', 1 / this._foamTextureSize);\n bindGroup.setValue('edgeFadeWidth', this._edgeFadeWidth);\n bindGroup.setValue('mediumAlbedo', this._scatterAlbedo);\n bindGroup.setValue('mediumExtinction', this._extinction);\n bindGroup.setTexture('zLTCMatLut', getLTCMatLUT());\n bindGroup.setTexture('zLTCAmpLut', getLTCAmpLUT());\n this._sunScatterParams.setXYZW(this._sunScatteringIntensity, this._scatterAnisotropy, 0, 0);\n bindGroup.setValue('sunScatterParams', this._sunScatterParams);\n // Luminance-weighted scalar: one blur LOD serves all three channels.\n bindGroup.setValue(\n 'refractBlurDensity',\n (0.2126 * this._scattering.x + 0.7152 * this._scattering.y + 0.0722 * this._scattering.z) *\n this._scatteringScale *\n REFRACT_BLUR_DENSITY *\n this._refractionBlur\n );\n }\n if (this.waveGenerator) {\n this.waveGenerator.applyWaterBindGroup(bindGroup);\n }\n }\n needUpdate() {\n return (\n !!this._waveGenerator.get()?.needUpdate() || !!this._interaction.get() || !!this._shoreWaveGenerator\n );\n }\n /**\n * Crest to trough height in metres of the waves rolling in to the shore and\n * running up the beach, 0 for none. See {@link ShoreWaveGenerator}. Needs\n * the scene signed distance field (WebGPU); without it the waves are off.\n */\n get shoreWaveHeight() {\n return this._shoreWaves.height;\n }\n set shoreWaveHeight(val: number) {\n val = Math.max(0, val);\n const wasOn = this._shoreWaves.height > 0;\n this._shoreWaves.height = val;\n if (wasOn !== val > 0) {\n this._rebuildEffectiveWaveGenerator();\n }\n }\n /** Distance in metres between shore wave crests at the outer edge of their zone; they bunch up towards the shore. */\n get shoreWaveLength() {\n return this._shoreWaves.wavelength;\n }\n set shoreWaveLength(val: number) {\n this._shoreWaves.wavelength = Math.max(0.5, val);\n }\n /** Seconds between successive shore waves. */\n get shoreWavePeriod() {\n return this._shoreWaves.period;\n }\n set shoreWavePeriod(val: number) {\n this._shoreWaves.period = Math.max(0.5, val);\n }\n /** How far out from the waterline the shore waves rise, in metres. */\n get shoreWaveZone() {\n return this._shoreWaves.zone;\n }\n set shoreWaveZone(val: number) {\n this._shoreWaves.zone = Math.max(1, val);\n }\n /** How sharp the shore wave crests become at the shore, 0 for a sine and towards 1 for a cusp. */\n get shoreWaveSharpness() {\n return this._shoreWaves.sharpness;\n }\n set shoreWaveSharpness(val: number) {\n this._shoreWaves.sharpness = Math.min(Math.max(val, 0), 0.95);\n }\n /** How far the shore wave crests lean towards the shore there, 0 for upright, 1 for a steep front face. */\n get shoreWaveLean() {\n return this._shoreWaves.lean;\n }\n set shoreWaveLean(val: number) {\n this._shoreWaves.lean = Math.min(Math.max(val, 0), 1);\n }\n /** How irregular the shore waves are, 0..1: 0 for parallel crests a fixed wavelength apart, higher for each wave with a period and a bend of its own. */\n get shoreWaveIrregularity() {\n return this._shoreWaves.irregularity!;\n }\n set shoreWaveIrregularity(val: number) {\n this._shoreWaves.irregularity = Math.min(Math.max(val, 0), 1);\n }\n /** How fast the foam fades, per second (Crest's Foam Fade Rate): lower leaves longer trails behind breaking waves. */\n get foamFadeRate() {\n return this._foamField.fadeRate;\n }\n set foamFadeRate(val: number) {\n this._foamField.fadeRate = val;\n }\n /** How much foam the open water's breaking crests leave behind to drift and fade; 0 keeps foam only while a crest breaks. */\n get foamTrailStrength() {\n return this._foamField.baseStrength;\n }\n set foamTrailStrength(val: number) {\n this._foamField.baseStrength = val;\n }\n /** Share of the wind speed the foam drifts at, about 0.03 in nature. */\n get foamDrift() {\n return this._foamField.drift;\n }\n set foamDrift(val: number) {\n this._foamField.drift = val;\n }\n /** Side in metres of the finest square of water around the view whose foam lingers, in the most detail; coarser squares reach eight times as far, beyond which foam shows only while crests break. */\n get foamFieldSize() {\n return this._foamField.size;\n }\n set foamFieldSize(val: number) {\n this._foamField.size = val;\n }\n /** How much foam the breaking shore waves make (Crest's Wave Foam Strength). */\n get shoreWaveFoamStrength() {\n return this._shoreWaves.waveFoamStrength!;\n }\n set shoreWaveFoamStrength(val: number) {\n this._shoreWaves.waveFoamStrength = Math.max(0, val);\n }\n /** How much of the shore waves makes foam, 0..1, higher for more (Crest's Wave Foam Coverage). */\n get shoreWaveFoamCoverage() {\n return this._shoreWaves.waveFoamCoverage!;\n }\n set shoreWaveFoamCoverage(val: number) {\n this._shoreWaves.waveFoamCoverage = Math.min(Math.max(val, 0), 1);\n }\n /** Water shallower than this many metres makes foam (Crest's Shoreline Foam Max Depth). */\n get shoreWaveShallowFoamDepth() {\n return this._shoreWaves.shorelineFoamMaxDepth!;\n }\n set shoreWaveShallowFoamDepth(val: number) {\n this._shoreWaves.shorelineFoamMaxDepth = Math.max(0.01, val);\n }\n /** How much foam shallow water makes (Crest's Shoreline Foam Strength). */\n get shoreWaveShallowFoamStrength() {\n return this._shoreWaves.shorelineFoamStrength!;\n }\n set shoreWaveShallowFoamStrength(val: number) {\n this._shoreWaves.shorelineFoamStrength = Math.max(0, val);\n }\n /** How opaque the foam is that the water makes against walls, rocks and piers standing in it, 0..1; it always rings them whole. */\n get wallFoamStrength() {\n return this._shoreWaves.wallFoamStrength!;\n }\n set wallFoamStrength(val: number) {\n this._shoreWaves.wallFoamStrength = Math.min(Math.max(val, 0), 1);\n this.uniformChanged();\n }\n /** Speed in metres per second the water has to hit a wall at before it makes any foam there. */\n get wallFoamMinSpeed() {\n return this._shoreWaves.wallFoamMinSpeed!;\n }\n set wallFoamMinSpeed(val: number) {\n this._shoreWaves.wallFoamMinSpeed = Math.max(0, val);\n }\n /** Speed in metres per second at which water hitting a wall makes the most foam. */\n get wallFoamMaxSpeed() {\n return this._shoreWaves.wallFoamMaxSpeed!;\n }\n set wallFoamMaxSpeed(val: number) {\n this._shoreWaves.wallFoamMaxSpeed = Math.max(0.01, val);\n }\n /** Speed in metres per second the foam drifts out from walls, rocks and piers at: higher for a wider ring of foam around them. */\n get wallFoamDrift() {\n return this._shoreWaves.wallFoamDrift!;\n }\n set wallFoamDrift(val: number) {\n this._shoreWaves.wallFoamDrift = Math.max(0, val);\n }\n /**\n * Seconds the foam each breaking wave brings in lasts: higher for longer\n * white trails behind the crests and foam that stays on the swash all the\n * way up the beach, lower for brief flashes of white at the crests.\n */\n get surfFoamDuration() {\n return this._shoreWaves.surfFoamDuration!;\n }\n set surfFoamDuration(val: number) {\n this._shoreWaves.surfFoamDuration = Math.max(0.05, val);\n }\n /**\n * Water depth in metres at and below which foam stops drifting and stays\n * where it is: higher to leave foam lying over a wider band of the shallows\n * and the beach, lower to let it drift until the water is almost gone.\n */\n get foamSettleDepth() {\n return this._shoreWaves.foamSettleDepth!;\n }\n set foamSettleDepth(val: number) {\n this._shoreWaves.foamSettleDepth = Math.max(0, val);\n }\n /**\n * Water depth in metres at and beyond which foam drifts freely: higher to\n * slow the foam over a wider band of shallow water, lower to keep it moving\n * until close in.\n */\n get foamDriftDepth() {\n return this._shoreWaves.foamDriftDepth!;\n }\n set foamDriftDepth(val: number) {\n this._shoreWaves.foamDriftDepth = Math.max(0, val);\n }\n /**\n * How fast foam that has settled in shallow water and on the sand fades, as\n * a share of the foam's fade: lower to leave it lying on the beach longer\n * after the wave has drained, 1 to fade it as fast as foam on open water.\n */\n get settledFoamFade() {\n return this._shoreWaves.settledFoamFade!;\n }\n set settledFoamFade(val: number) {\n this._shoreWaves.settledFoamFade = Math.min(Math.max(val, 0.01), 1);\n }\n /**\n * Hands the shore waves this frame's waterline fields: the shore field in\n * levels, null when there is none, which turns them off; and the wall field,\n * null for no foam against walls. Called by the water every frame.\n * @internal\n */\n setShoreWaveFrame(\n shore: Nullable<Texture2DArray>,\n shoreRegions: readonly Vector4[],\n wall: Nullable<Texture2DArray>,\n wallRegion: Vector4,\n level: number\n ) {\n this._shoreWaveGenerator?.setFrame(shore, shoreRegions, wall, wallRegion, level, this._waveClock);\n }\n /**\n * Steps the foam field around the water the view looks at, once a frame\n * however many views there are. Called by the water after\n * {@link setShoreWaveFrame}, which its sources read.\n * @param focusX - World x the field is centred on.\n * @param focusZ - World z the field is centred on.\n * @internal\n */\n updateFoamField(focusX: number, focusZ: number) {\n if (!this._foamSource || this._foamFrameId === this._frameId) {\n return;\n }\n this._foamFrameId = this._frameId;\n this._foamField.stepAround(\n focusX,\n focusZ,\n this._waveClock,\n this._waveGenerator.get()?.wind ?? null,\n this._foamSource\n );\n }\n update(frameId: number, elapsed: number) {\n this._frameId = frameId;\n this._waveClock = elapsed;\n // The base generator and the field are stepped separately, each guarded by\n // its own per-frame mark, so a generator shared between two bodies of water\n // is still stepped once even when each body wraps it with its own field.\n const waveGenerator = this._waveGenerator.get();\n if (waveGenerator) {\n const updateFrameId = WaterMaterial._waveUpdateState.get(waveGenerator);\n if (updateFrameId !== frameId) {\n RenderGraphExecutor.profileScope('WaterWaves', () => waveGenerator.update(elapsed));\n WaterMaterial._waveUpdateState.set(waveGenerator, frameId);\n }\n }\n const interaction = this._interaction.get();\n if (interaction && this._interactiveWaveGenerator) {\n const updateFrameId = WaterMaterial._interactionUpdateState.get(interaction);\n if (updateFrameId !== frameId) {\n RenderGraphExecutor.profileScope('WaterInteraction', () => interaction.update(elapsed));\n WaterMaterial._interactionUpdateState.set(interaction, frameId);\n }\n }\n }\n}\n"],"names":["WATER_DEBUG_OUTPUTS","label","value","WATER_F0","WATER_BASE_ROUGHNESS","WATER_DISTANT_ROUGHNESS","COX_MUNK_UPWIND","COX_MUNK_CROSSWIND_BASE","COX_MUNK_CROSSWIND","SKY_PREFILTER_START","SKY_PREFILTER_FULL","FOAM_LIGHT_WRAP","FOAM_EDGE_FADE_SHARE","WATER_IOR","AIR_TO_WATER_ETA","WATER_TO_AIR_ETA","REFRACT_MAX_PATH_RATIO","REFRACT_MARCH_STEPS","REFRACT_MARCH_THICKNESS","INFINITE_DEPTH_PULLIN","HORIZON_REFLECT_BIAS","REFRACT_EDGE_FADE","SCENE_SKY_DEPTH01","SKY_MEDIUM_PATH","SSS_SUN_ALIGN_FLOOR","SSS_GRAZING_FLOOR","SSS_HEIGHT_SOFTNESS","SSS_CREST_HEIGHT_MIN","SSS_CREST_PATH_FLOOR","SSS_ABSORPTION_SCALE","DEFAULT_SCATTER_ANISOTROPY","MIN_SUN_SLOPE","REFRACT_BLUR_GEOMETRIC","REFRACT_BLUR_DENSITY","REFRACT_BLUR_MAX_LOD","FOAM_DRIFT","FOAM_BUBBLE_MIP_SCALE","FOAM_SPECULAR_POWER","FOAM_SPECULAR_BOOST","WaterMaterial","applyMaterialMixins","MeshMaterial","mixinLight","FEATURE_REFRACTION_MODE","defineFeature","FEATURE_INFINITE","FEATURE_DEBUG_OUTPUT","_waveUpdateState","WeakMap","_interactionUpdateState","_region","_refractionScale","_reflectionStrength","_waveGenerator","_interaction","height","wavelength","period","zone","sharpness","lean","irregularity","waveFoamStrength","waveFoamCoverage","shorelineFoamMaxDepth","shorelineFoamStrength","wallFoamStrength","wallFoamMinSpeed","wallFoamMaxSpeed","wallFoamDrift","surfFoamDuration","foamSettleDepth","foamDriftDepth","settledFoamFade","_shoreWaveGenerator","_foamField","WaterFoamField","_foamFieldGenerator","_interactiveWaveGenerator","_foamSource","_foamFrameId","_frameId","_edgeFadeWidth","edgeFadeWidth","val","Math","max","uniformChanged","_waveClock","_clipmapInfo","_clipmapGridInfo","_skirtDistance","_ssrParams","_absorptionScale","_scatteringScale","_causticsEnabled","_causticsIntensity","_causticsDepth","_causticsRange","_causticsFadeDistance","_causticsWarp","_causticsMinDepth","_causticsSceneDepth","_causticsDefocus","_causticsResolution","_causticsPhotonResolution","_causticsBlurPasses","_causticsTemporalStrength","_underwaterEnabled","_underwaterAmbientIntensity","_underwaterGodRays","_underwaterGodRayIntensity","_underwaterGodRaySteps","_underwaterGodRayShadow","_underwaterHysteresis","_subsurfaceIntensity","_subsurfaceCrestHeight","_subsurfaceTint","_subsurfaceParams","_sunScatteringIntensity","_scatterAnisotropy","_sunScatterParams","_refractionBlur","_cheapRefractionDepth","_foamAmount","_foamFalloff","_foamColor","_foamParams","_foamFeather","_foamNormalStrength","_foamBubbleColor","_foamBubbleCoverage","_foamBubbleDepth","_foamLookParams","_foamTexture","_foamTextureSize","Vector4","_absorption","Vector3","_scattering","_extinction","_scatterAlbedo","_updateMediumCoefficients","DRef","_effectiveWaveGenerator","_waveVersionByBindGroup","_unresolvedSlope","cullMode","useFeature","onDispose","dispose","region","equalsTo","set","waveGenerator","get","_rebuildEffectiveWaveGenerator","baseWaveGenerator","interaction","base","setAmbientSurface","effective","that","FoamFieldWaveGenerator","getFoamTexture","foamTexture","getFoamTextureSize","WaveFoamSource","_shoreWaves","ShoreWaveGenerator","flowSource","isOk","InteractiveWaveGenerator","ensureResources","optionChanged","refractionMode","featureUsed","debugOutput","infinite","absorption","absorptionScale","scattering","scatteringScale","extinction","scatterAlbedo","underwaterEnabled","underwaterAmbientIntensity","underwaterGodRays","underwaterGodRayIntensity","underwaterGodRaySteps","floor","underwaterGodRayShadow","underwaterHysteresis","causticsEnabled","causticsIntensity","causticsDepth","causticsRange","causticsFadeDistance","causticsSceneDepth","causticsWarp","min","causticsMinDepth","causticsDefocus","causticsResolution","causticsPhotonResolution","n","causticsBlurPasses","clamped","causticsTemporalStrength","subsurfaceIntensity","subsurfaceCrestHeight","subsurfaceTint","sunScatteringIntensity","cheapRefractionDepth","refractionBlur","scatterAnisotropy","foamAmount","foamFalloff","foamColor","foamFeather","foamNormalStrength","foamBubbleColor","foamBubbleCoverage","tex","foamTextureSize","foamBubbleDepth","setXYZ","x","y","z","refractionScale","reflectionStrength","needSceneColor","needSceneDepth","_createHash","getHash","setClipmapInfo","rotation","scale","offsetX","offsetY","setXYZW","setClipmapGridInfo","gridScale","gridOffsetX","gridOffsetY","tileResolution","w","setSkirtDistance","distance","supportInstancing","supportLighting","receivesWaterCaustics","vertexShader","scope","pb","$builder","setupUniforms","$inputs","position","vec3","attrib","clipmapInfo","vec4","clipmapGridInfo","uniform","skirtDistance","float","$l","s","sin","c","cos","scale2","mul","clipmapMatrix","mat4","neg","sub","clipmapPos","xy","clipmapWorldPos","ShaderHelper","getWorldMatrix","xyz","worldNormal","worldPos","camOffset","abs","xz","getCameraPosition","vertexSpacing","div","step","skirt","$if","greaterThan","camXZ","outDir","normalize","outXZ","add","$else","calcVertexPositionAndNormal","$outputs","camPos","viewVec","viewDist","length","maxDist","getCameraParams","pullIn","projPos","setClipSpacePosition","getViewProjectionMatrix","gen","calcPrevVertexPosition","getPrevUnjitteredViewProjectionMatrix","prevWorldPos","mix","resolveMotionVector","fragmentShader","needFragmentColor","unresolvedSlope","skyReflectScale","ssrParams","eyeSide","subsurfaceParams","foamShadingParams","foamLookParams","foamTex","tex2D","foamUVScale","sunScatterParams","refractBlurDensity","mediumAlbedo","mediumExtinction","zLTCMatLut","zLTCAmpLut","discardable","or","any","lessThan","zw","discard","outColor","calcDebugLevels","shoreRegion","calcDebugRegion","shoreColor","$choice","drawContext","materialFlags","MaterialVaryingFlags","SCENE_STORE_ROUGHNESS","SCENE_STORE_NORMAL","outputFragmentColor","restXZGrad","dpdx","dpdy","foamSample","sampleFoamTexture","vec2","getElapsedTime","normal","calcFragmentNormalAndFoam","calcUnresolvedSlopeVariance","undefined","crestHeight","surfaceCoverage","calcSurfaceCoverage","call","sheetThickness","calcSheetThickness","calcNearShoreFoam","scenePos","samplePositionFromDepth","getLinearDepthTexture","$builtins","fragCoord","getRenderSize","getJitteredInvVPMatrix","groundFoamDensity","groundFoamSample","groundFoamWeight","groundNormal","visibilityDepthFail","groundFieldCoverage","groundWetCoverage","groundFieldDensity","groundSurfDensity","groundGrad","groundCross","cross","sign","groundMask","calcFoamGroundMask","field","shore","and","groundMobile","sample","groundWet","groundThickness","groundHandoverThickness","greaterThanEqual","smoothStep","clamp","flowPattern","ffFoamTex","ffFoamUVScale","ffClock","calcFoamFlow","ffDrift","fragDepth","linearNormalizedToNonLinearDepth","lessThanEqual","revealSwash","nonLinearDepthToLinearNormalized","swashDiscard","wiDebugHeight","sampleHeight","wiParams2","wiDebugMask","windowMask","ffDebug","wallFoam","waterShading","outRoughness","waterRoughness","coverage","unresolvedSlopeVariance","func","slopeVar","alpha2","$return","sqrt","dist","normalScale","waterRefraction","eyeVecNorm","screenUV","surfaceViewZ","straightDepth01","straightWorldPos","straightDist","underwater","march","h","uv","waterRefractProjectUV","hitPos","uvBase","edge","waterRefractUV","refractDir","t","linearDepth","sampleLinearDepth","sceneViewZ","cameraFar","rayViewZ","maxPath","tPrev","gapPrev","hitUV","hitPath","basePath","$for","refractStepZ","waterRefractStep","gap","k","$break","bool","faceNormal","eta","waterCrossDir","refractWave","refract","refractFlatNormal","refractFlat","dot","refractUV","refractPath","refractDirView","getViewMatrix","marchResult","waterRefractMarch","sceneHit","waterSunScattering","lightEnergy","lightDir","NoL","depth","foam","up","Lw","Vw","sy","vy","r","rr","cosTheta","hg","waterScatterPhase","lumWeights","extLum","albedoLum","thickness","exp","phase","PI","integral","entry","pow","foamFactor","restXZ","hasGroundFoam","envLight","needCalculateEnvLight","env","light","cosThetaV","sigmaV","NoV","eyeVec","sinT2","f","cosT","meanFresnel","f0","f90","L","V","halfVec","NoH","specular","VoH","F","fresnelSchlick","alphaRoughness","roughness","D","distributionGGX","VIS","visGGX","lightColor","density","feather","yz","wPos","shadingNormal","diffuseWeight","diffuseNormal","restLevel","underwaterEye","equal","viewPos","incidentVec","reflectVecW","reflect","reflectance","hitInfo","reflectVec","getHiZDepthTexture","screenSpaceRayTracing_HiZ","getProjectionMatrix","getInvProjectionMatrix","int","getHiZDepthTextureMipLevelCount","getHiZDepthTextureSize","screenSpaceRayTracing_Linear2D","getLinearDepthTextureSize","refl","reflMiss","downwelling","sampleBakedSkyPreExposed","textureSampleLevel","getBakedSkyTexture","rgb","hasRadiance","skyBlur","getRadiance","alpha","phongPower","coneCos","coneTan","coneBase","coneRadius","reflectLod","log2","getSceneColorTexture","refractInfo","mediumPath","refractBlur","refraction","refractionRaw","getAbsorption","viewXZ","viewWind","viewWindT","fresnelTerm","fresnel","crestDensity","crestWhite","waterWhiteFoam","wallDensity","wallCut","wallWhite","foamGrad","bubbleDensity","foamStep","foamTexelSize","foamNormal","waterShare","bodyWeight","finalColor","edgeThickness","foamFade","foamRadiance","groundFoamOpacity","groundFoamRadiance","groundFoamWhite","dbgSubsurface","dbgSunScatter","dbgShadow","dbgSpecular","sssT","sssRise","log","sssPath","sssThickness","dbgLightDir","forEachLight","type","posRange","dirCutoff","colorIntensity","extra","shadow","lightAtten","calculateLightAttenuation","calculateLightDirection","NoLdiffuse","NoLfoam","a","specularTerm","LIGHT_TYPE_RECT","rectTerms","evaluateLTCRectLightTerms","lightSpecular","lightContrib","sssToEye","sssGrazing","sssMirror","sssAlign","sssSunUp","sssFacing","subsurfaceTerm","LIGHT_TYPE_DIRECTIONAL","sunScatterTerm","not","foamGlint","foamLight","calculateShadow","groundNoL","groundShadow","irradiance","getEnvLightIrradiance","sss","getScattering","foamAmbient","toEye","bubbleShift","bubbleTex","edgeFade","behind","groundBehind","groundColor","applyUniforms","bindGroup","ctx","needUpdate","pass","lastWritten","version","applyWaterBindGroup","applyUniformValues","setValue","wind","windSpeed","hypot","scene","lightingMode","getPreExposure","PHYSICAL_BAKE_EXPOSURE","eyeUnder","material","setTexture","getDefaultFoamTexture","fetchSampler","getLTCMatLUT","getLTCAmpLUT","shoreWaveHeight","wasOn","shoreWaveLength","shoreWavePeriod","shoreWaveZone","shoreWaveSharpness","shoreWaveLean","shoreWaveIrregularity","foamFadeRate","fadeRate","foamTrailStrength","baseStrength","foamDrift","drift","foamFieldSize","size","shoreWaveFoamStrength","shoreWaveFoamCoverage","shoreWaveShallowFoamDepth","shoreWaveShallowFoamStrength","setShoreWaveFrame","shoreRegions","wall","wallRegion","level","setFrame","updateFoamField","focusX","focusZ","stepAround","update","frameId","elapsed","updateFrameId","RenderGraphExecutor","profileScope"],"mappings":";;;;;;;;;;;;;;;;;;AAoIA,gFACO,MAAMA,mBAAsB,GAAA;AACjC,IAAA;QAAEC,KAAO,EAAA,MAAA;QAAQC,KAAO,EAAA;AAAO,KAAA;AAC/B,IAAA;QAAED,KAAO,EAAA,QAAA;QAAUC,KAAO,EAAA;AAAS,KAAA;AACnC,IAAA;QAAED,KAAO,EAAA,MAAA;QAAQC,KAAO,EAAA;AAAO,KAAA;AAC/B,IAAA;QAAED,KAAO,EAAA,aAAA;QAAeC,KAAO,EAAA;AAAa,KAAA;AAC5C,IAAA;QAAED,KAAO,EAAA,SAAA;QAAWC,KAAO,EAAA;AAAU,KAAA;AACrC,IAAA;QAAED,KAAO,EAAA,YAAA;QAAcC,KAAO,EAAA;AAAa,KAAA;AAC3C,IAAA;QAAED,KAAO,EAAA,YAAA;QAAcC,KAAO,EAAA;AAAa,KAAA;AAC3C,IAAA;QAAED,KAAO,EAAA,YAAA;QAAcC,KAAO,EAAA;AAAa,KAAA;AAC3C,IAAA;QAAED,KAAO,EAAA,YAAA;QAAcC,KAAO,EAAA;AAAa,KAAA;AAC3C,IAAA;QAAED,KAAO,EAAA,gBAAA;QAAkBC,KAAO,EAAA;AAAgB,KAAA;AAClD,IAAA;QAAED,KAAO,EAAA,QAAA;QAAUC,KAAO,EAAA;AAAS,KAAA;AACnC,IAAA;QAAED,KAAO,EAAA,YAAA;QAAcC,KAAO,EAAA;AAAa,KAAA;AAC3C,IAAA;QAAED,KAAO,EAAA,sBAAA;QAAwBC,KAAO,EAAA;AAAsB,KAAA;AAC9D,IAAA;QAAED,KAAO,EAAA,UAAA;QAAYC,K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