@zephyr3d/scene 0.9.25 → 0.9.27
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.
- package/dist/animation/animationset.js +92 -30
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/hair/gpu_hair_simulation.js +1090 -0
- package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +7 -5
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -4
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +79 -25
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +577 -179
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +4 -3
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
- package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +2 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +11 -3
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +10 -0
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +53 -43
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptingsystem.js +119 -6
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +3 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +284 -67
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zhair/zhair_format.js +288 -0
- package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
- package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
- package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
- package/dist/asset/model.js +184 -69
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +268 -44
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -1
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +9044 -5139
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/material/eye.js +932 -0
- package/dist/material/eye.js.map +1 -0
- package/dist/material/hair.js +917 -0
- package/dist/material/hair.js.map +1 -0
- package/dist/material/hairstrand.js +842 -0
- package/dist/material/hairstrand.js.map +1 -0
- package/dist/material/hairstrand_data.js +162 -0
- package/dist/material/hairstrand_data.js.map +1 -0
- package/dist/material/lambert.js +5 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +48 -10
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +120 -19
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +1 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -4
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +106 -19
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +4 -4
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +48 -11
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mtoon.js +6 -5
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrblueprint.js +146 -28
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrblueprint_instance.js +501 -0
- package/dist/material/pbrblueprint_instance.js.map +1 -0
- package/dist/material/pbrmr.js +15 -16
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +734 -23
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +55 -0
- package/dist/material/shader/terrain_blend.js.map +1 -0
- package/dist/material/skin.js +192 -32
- package/dist/material/skin.js.map +1 -1
- package/dist/material/spriteblueprint.js +16 -1
- package/dist/material/spriteblueprint.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +86 -23
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/water.js +2059 -72
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js +167 -7
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/coloradjust.js +2 -1
- package/dist/posteffect/coloradjust.js.map +1 -1
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +2 -1
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -1
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +664 -56
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +46 -44
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +368 -69
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +16 -9
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +121 -36
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js +44 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +8 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +156 -5
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +20 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +36 -2
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +26 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +3 -2
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +1 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +6 -3
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +57 -15
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +130 -20
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +3 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +80 -22
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +6 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/oit.js +29 -0
- package/dist/render/oit.js.map +1 -0
- package/dist/render/render_queue.js +39 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +4 -0
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +1 -0
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +2 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +379 -10
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/shadow_mask_pass.js +73 -8
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/sky.js +166 -126
- package/dist/render/sky.js.map +1 -1
- package/dist/render/underwater.js +624 -0
- package/dist/render/underwater.js.map +1 -0
- package/dist/render/water_caustics.js +1380 -0
- package/dist/render/water_caustics.js.map +1 -0
- package/dist/render/weightedblended_oit.js +3 -2
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +8 -0
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -0
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +4 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/hair.js +963 -0
- package/dist/scene/hair.js.map +1 -0
- package/dist/scene/light.js +5 -1
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +481 -47
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +3 -0
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +3 -0
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +6 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +3 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -1
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +3 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +3 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +6 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/texture_cache.js +309 -0
- package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
- package/dist/scene/water.js +546 -4
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/diffusion.js +54 -0
- package/dist/shaders/diffusion.js.map +1 -0
- package/dist/shaders/shadow.js +33 -21
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/temporal.js +71 -33
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +22 -19
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +56 -0
- package/dist/shaders/water_medium.js.map +1 -0
- package/dist/shadow/dom.js +546 -0
- package/dist/shadow/dom.js.map +1 -0
- package/dist/shadow/pcf_opt.js +3 -5
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +1 -1
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/receiver_bias.js +41 -0
- package/dist/shadow/receiver_bias.js.map +1 -0
- package/dist/shadow/shader.js +20 -60
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +89 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +1 -1
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +150 -37
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/shape.js +11 -2
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +50 -9
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +112 -2
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/func.js +142 -49
- package/dist/utility/blueprint/material/func.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +490 -25
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +898 -4
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +434 -101
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +401 -5
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +186 -26
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +26 -5
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/hair.js +1141 -0
- package/dist/utility/serialization/scene/hair.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +84 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1867 -166
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +231 -14
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +141 -7
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +18 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +4 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +4 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +4 -0
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1105 -21
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +9 -8
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/values.js +49 -2
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/render/rendergraph/frame_graph_context.js +0 -41
- package/dist/render/rendergraph/frame_graph_context.js.map +0 -1
- package/dist/shaders/ssgi.js +0 -63
- package/dist/shaders/ssgi.js.map +0 -1
- package/dist/shaders/ssgi_reprojection.js +0 -118
- package/dist/shaders/ssgi_reprojection.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 { 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 { getDevice } from '../app/api';\r\n\r\nexport class WaterMaterial extends applyMaterialMixins(MeshMaterial, mixinLight) {\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 _displace: number;\r\n private _depthMulti: number;\r\n private _refractionStrength: number;\r\n private readonly _scatterRampTexture: DRef<Texture2D>;\r\n private readonly _absorptionRampTexture: DRef<Texture2D>;\r\n private readonly _waveGenerator: DRef<WaveGenerator>;\r\n private _waveVersion: number;\r\n private readonly _clipmapInfo: Vector4;\r\n private readonly _clipmapGridInfo: Vector4;\r\n private readonly _ssrParams: Vector4;\r\n constructor() {\r\n super();\r\n this._region = new Vector4(-99999, -99999, 99999, 99999);\r\n this._clipmapInfo = new Vector4();\r\n this._clipmapGridInfo = new Vector4();\r\n this._waveGenerator = new DRef();\r\n this._waveVersion = -1;\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._displace = 16;\r\n this._depthMulti = 0.1;\r\n this._refractionStrength = 0;\r\n this.cullMode = 'none';\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 this._waveVersion = -1;\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 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 get displace() {\r\n return this._displace;\r\n }\r\n set displace(val) {\r\n if (val !== this._displace) {\r\n this._displace = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get refractionStrength() {\r\n return this._refractionStrength;\r\n }\r\n set refractionStrength(val) {\r\n if (val !== this._refractionStrength) {\r\n this._refractionStrength = val;\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 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 supportInstancing() {\r\n return false;\r\n }\r\n supportLighting() {\r\n return true;\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\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 this.waveGenerator?.calcVertexPositionAndNormal(\r\n scope,\r\n scope.clipmapWorldPos,\r\n scope.worldPos,\r\n scope.worldNormal\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 ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1))\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 scope.region = pb.vec4().uniform(2);\r\n if (this.needFragmentColor()) {\r\n scope.displace = pb.float().uniform(2);\r\n scope.depthMulti = pb.float().uniform(2);\r\n scope.refractionStrength = pb.float().uniform(2);\r\n scope.ssrParams = pb.vec4().uniform(2);\r\n scope.scatterRampTex = pb.tex2D().uniform(2);\r\n scope.absorptionRampTex = pb.tex2D().uniform(2);\r\n }\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 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 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 scope.$l.outRoughness = pb.vec4(1, 1, 1, 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 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 pb.func('getAbsorption', [pb.float('depth')], function () {\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 });\r\n pb.func('getScattering', [pb.float('depth')], function () {\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 });\r\n pb.func('fresnel', [pb.vec3('normal'), pb.vec3('eyeVec')], function () {\r\n this.$return(\r\n pb.clamp(\r\n pb.sub(pb.pow(pb.sub(1, pb.dot(this.normal, this.eyeVec)), 5), this.refractionStrength),\r\n 0,\r\n 1\r\n )\r\n );\r\n });\r\n pb.func(\r\n 'lightSpecular',\r\n [pb.vec3('lightDir'), pb.vec3('eyeVecNorm'), pb.vec3('normal'), pb.vec3('lightColor')],\r\n function () {\r\n this.$l.roughness = pb.float(0.04);\r\n this.$l.f0 = pb.vec3(0.02);\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 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.displacedTexCoord = pb.add(this.screenUV, pb.mul(this.normal.xz, this.displace));\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 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.normal);\r\n this.$l.reflectance = pb.vec3();\r\n this.$l.hitInfo = pb.vec4(0);\r\n this.$if(pb.greaterThan(this.reflectVecW.y, 0), 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 this.$l.refl = pb.reflect(\r\n pb.normalize(pb.sub(this.worldPos, ShaderHelper.getCameraPosition(this))),\r\n this.normal\r\n );\r\n this.refl.y = pb.max(this.refl.y, 0.1);\r\n this.reflectance = pb.mix(\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 ShaderHelper.sampleBakedSkyPreExposed(this, this.refl),\r\n pb.textureSampleLevel(ShaderHelper.getSceneColorTexture(this), this.hitInfo.xy, 0).rgb,\r\n this.hitInfo.w\r\n );\r\n this.$l.refractUV = this.displacedTexCoord;\r\n this.$l.displacedPos = ShaderHelper.samplePositionFromDepth(\r\n this,\r\n ShaderHelper.getLinearDepthTexture(this),\r\n this.refractUV,\r\n ShaderHelper.getInvProjectionMatrix(this),\r\n ShaderHelper.getCameraParams(this).xy\r\n );\r\n this.$if(\r\n pb.or(\r\n pb.greaterThanEqual(this.displacedPos.w, 0.99999),\r\n pb.greaterThan(this.displacedPos.z, this.viewPos.z)\r\n ),\r\n function () {\r\n this.refractUV = this.screenUV;\r\n }\r\n ).$else(function () {\r\n this.depth = pb.length(pb.sub(this.displacedPos.xyz, this.viewPos));\r\n });\r\n this.$l.refraction = pb.textureSampleLevel(\r\n ShaderHelper.getSceneColorTexture(this),\r\n this.refractUV,\r\n 0\r\n ).rgb;\r\n this.refraction = pb.mul(this.refraction, this.getAbsorption(this.depth));\r\n this.$l.fresnelTerm = this.fresnel(this.normal, pb.neg(this.eyeVecNorm));\r\n this.$l.finalColor = pb.mix(\r\n pb.mix(this.refraction, this.reflectance, this.fresnelTerm),\r\n pb.vec3(1),\r\n this.foamFactor\r\n );\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 this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightContrib = this.lightSpecular(\r\n this.lightDir,\r\n this.eyeVecNorm,\r\n this.normal,\r\n pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten)\r\n );\r\n if (shadow) {\r\n this.$l.shadow = pb.vec3(that.calculateShadow(this, this.worldPos, this.NoL));\r\n this.lightContrib = pb.mul(this.lightContrib, this.shadow);\r\n }\r\n this.finalColor = pb.add(this.finalColor, this.lightContrib);\r\n });\r\n if (that.needCalculateEnvLight()) {\r\n this.$l.irradiance = that.getEnvLightIrradiance(this, this.normal);\r\n this.$l.sss = pb.mul(this.getScattering(this.depth), this.irradiance, 1 / Math.PI);\r\n this.finalColor = pb.add(this.finalColor, this.sss);\r\n }\r\n this.$return(this.finalColor);\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 if (waveGenerator && this._waveVersion !== waveGenerator.version) {\r\n waveGenerator.applyWaterBindGroup(bindGroup);\r\n this._waveVersion = 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 bindGroup.setValue('region', this._region);\r\n if (this.needFragmentColor(ctx)) {\r\n bindGroup.setValue('displace', this._displace / ctx.renderWidth);\r\n bindGroup.setValue('depthMulti', this._depthMulti);\r\n bindGroup.setValue('refractionStrength', this._refractionStrength);\r\n bindGroup.setValue('ssrParams', this._ssrParams);\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 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":["WaterMaterial","applyMaterialMixins","MeshMaterial","mixinLight","_absorptionGrad","Interpolator","Float32Array","_scatterGrad","_defaultScatterRampTexture","DWeakRef","_defaultAbsorptionRampTexture","_waveUpdateState","WeakMap","_region","_displace","_depthMulti","_refractionStrength","_scatterRampTexture","_absorptionRampTexture","_waveGenerator","_waveVersion","_clipmapInfo","_clipmapGridInfo","_ssrParams","Vector4","DRef","cullMode","onDispose","dispose","region","val","equalsTo","set","uniformChanged","waveGenerator","get","optionChanged","scatterRampTexture","tex","_getScatterRampTexture","getDevice","absorptionRampTexture","_getAbsorptionRampTexture","depthMulti","displace","refractionStrength","needSceneColor","needSceneDepth","_createHash","getHash","setClipmapInfo","rotation","scale","offsetX","offsetY","setXYZW","setClipmapGridInfo","gridScale","gridOffsetX","gridOffsetY","x","y","z","supportInstancing","supportLighting","vertexShader","scope","pb","$builder","setupUniforms","$inputs","position","vec3","attrib","clipmapInfo","vec4","clipmapGridInfo","uniform","$l","s","sin","c","cos","scale2","mul","clipmapMatrix","mat4","neg","sub","w","clipmapPos","xy","clipmapWorldPos","ShaderHelper","getWorldMatrix","xyz","worldNormal","worldPos","calcVertexPositionAndNormal","$outputs","setClipSpacePosition","getViewProjectionMatrix","resolveMotionVector","fragmentShader","needFragmentColor","float","ssrParams","scatterRampTex","tex2D","absorptionRampTex","discardable","or","any","lessThan","xz","greaterThan","zw","$if","discard","normal","calcFragmentNormalAndFoam","outColor","waterShading","drawContext","materialFlags","MaterialVaryingFlags","SCENE_STORE_ROUGHNESS","SCENE_STORE_NORMAL","outRoughness","outputFragmentColor","foamFactor","that","func","textureSampleLevel","vec2","depth","rgb","$return","clamp","pow","dot","eyeVec","roughness","f0","f90","L","lightDir","V","eyeVecNorm","halfVec","normalize","add","NoH","NoL","specular","VoH","NoV","F","fresnelSchlick","alphaRoughness","D","distributionGGX","VIS","visGGX","lightColor","screenUV","div","$builtins","fragCoord","getRenderSize","dist","length","getCameraPosition","normalScale","displacedTexCoord","wPos","samplePositionFromDepth","getLinearDepthTexture","getInvViewProjectionMatrix","getCameraParams","viewPos","getViewMatrix","incidentVec","reflectVecW","reflect","reflectance","hitInfo","reflectVec","getHiZDepthTexture","screenSpaceRayTracing_HiZ","getProjectionMatrix","getInvProjectionMatrix","int","getHiZDepthTextureMipLevelCount","getHiZDepthTextureSize","screenSpaceRayTracing_Linear2D","getLinearDepthTextureSize","refl","max","mix","sampleBakedSkyPreExposed","getSceneColorTexture","refractUV","displacedPos","greaterThanEqual","$else","refraction","getAbsorption","fresnelTerm","fresnel","finalColor","forEachLight","type","posRange","dirCutoff","colorIntensity","extra","shadow","lightAtten","calculateLightAttenuation","calculateLightDirection","lightContrib","lightSpecular","a","calculateShadow","needCalculateEnvLight","irradiance","getEnvLightIrradiance","sss","getScattering","Math","PI","applyUniforms","bindGroup","ctx","needUpdate","pass","version","applyWaterBindGroup","applyUniformValues","setValue","renderWidth","setTexture","device","fetchSampler","update","frameId","elapsed","updateFrameId","_getRampTexture","grad","width","height","texture","createTexture2D","mipmapping","numTexels","data","Uint8Array","tmpcolor","Vector3","i","interpolate"],"mappings":";;;;;;;;;;AAoBO,MAAMA,aAAsBC,SAAAA,mBAAAA,CAAoBC,YAAcC,EAAAA,UAAAA,CAAAA,CAAAA;AACnE,IAAA,OAAwBC,kBAAkB,IAAIC,YAAAA,CAC5C,QACA,EAAA,MAAA,EACA,IAAIC,YAAa,CAAA;AAAC,QAAA,CAAA;AAAG,QAAA,KAAA;AAAO,QAAA,KAAA;AAAO,QAAA,KAAA;AAAO,QAAA;AAAE,KAAA,CAAA,EAC5C,IAAIA,YAAa,CAAA;AAAC,QAAA,CAAA;AAAG,QAAA,CAAA;AAAG,QAAA,CAAA;AAAG,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA,CAAA;AAAG,QAAA,IAAA;AAAM,QAAA,IAAA;A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;AAE9D;YACA,IAAI,CAACc,sBAAsB,CAACc,GAAG,CAAChC,aAAcU,CAAAA,6BAA6B,CAACyB,GAAG,EAAA,CAAA;AACjF;AACA,QAAA,OAAO,IAAI,CAACjB,sBAAsB,CAACiB,GAAG,EAAA;AACxC;AACF;;;;"}
|
|
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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