Class WaterSurface
Inherited Members
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Assembly: Unity.RenderPipelines.HighDefinition.Runtime.dll
Syntax
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class WaterSurface : MonoBehaviour, IVersionable<WaterSurface.Version>
Fields
absorptionDistance
Controls the approximative distance in meters that the camera can perceive through a water surface. This distance can vary widely depending on the intensity of the light the object receives.
Declaration
[Range(0.001, 100)]
[Tooltip("Controls the approximative distance in meters that the camera can perceive through a water surface. This distance can vary widely depending on the intensity of the light the object receives.")]
public float absorptionDistance
Field Value
absorptionDistanceMultiplier
Sets the multiplier for the Absorption Distance when the camera is underwater. A value of 2.0 means you will see twice as far underwater.
Declaration
[Min(0.001)]
[Tooltip("Sets the multiplier for the Absorption Distance when the camera is underwater. A value of 2.0 means you will see twice as far underwater.")]
public float absorptionDistanceMultiplier
Field Value
ambientScattering
Controls the intensity of the ambient scattering term. This can be adjusted for artistic purposes.
Declaration
[Range(0, 1)]
[Tooltip("Controls the intensity of the height based scattering. The higher the vertical displacement, the more the water receives scattering. This can be adjusted for artistic purposes.")]
public float ambientScattering
Field Value
caustics
When enabled, the water surface will render caustics.
Declaration
[Tooltip("When enabled, the water surface will render caustics.")]
public bool caustics
Field Value
causticsBand
Controls which band is used for the caustics evaluation.
Declaration
[Tooltip("Controls which band is used for the caustics evaluation.")]
public int causticsBand
Field Value
causticsDirectionalShadow
When enabled, the water caustics will take into account the directional light's shadow.
Declaration
public bool causticsDirectionalShadow
Field Value
causticsDirectionalShadowDimmer
Sets the water caustics dimmer value for the directional shadow.
Declaration
[Range(0, 1)]
public float causticsDirectionalShadowDimmer
Field Value
causticsIntensity
Sets the intensity of the under-water caustics.
Declaration
[Min(0)]
[Tooltip("Sets the intensity of the under-water caustics.")]
public float causticsIntensity
Field Value
causticsPlaneBlendDistance
Sets the vertical blending distance for the water caustics.
Declaration
[Min(0)]
[Tooltip("Sets the vertical blending distance for the water caustics.")]
public float causticsPlaneBlendDistance
Field Value
causticsResolution
Specifies the resolution at which the water caustics are rendered (simulation only).
Declaration
[Tooltip("Specifies the resolution at which the water caustics are rendered (simulation only).")]
public WaterSurface.WaterCausticsResolution causticsResolution
Field Value
causticsTilingFactor
Sets a tiling factor for the water caustics.
Declaration
[Min(0.001)]
public float causticsTilingFactor
Field Value
cpuEvaluateRipples
Specifies if the CPU simulation should evaluate the ripples as part of the simulation. Including ripples will allow a higher visual fidelity but the cost of the simulation will increase.
Declaration
public bool cpuEvaluateRipples
Field Value
currentDebugMultiplier
Sets a multiplier for the arrow density in the current debug mode.
Declaration
public float currentDebugMultiplier
Field Value
customMaterial
Sets a custom material that will be used to render the water surface. If set to None a default material is used.
Declaration
public Material customMaterial
Field Value
debugMode
Sets the debug mode for a given water surface.
Declaration
public WaterDebugMode debugMode
Field Value
decalLayerMask
Specifies the decal layers that affect the water surface.
Declaration
[SerializeField]
[Obsolete("Use renderingLayerMask instead @from(2023.1) (UnityUpgradable) -> renderingLayerMask")]
public RenderingLayerMask decalLayerMask
Field Value
decalRegionAnchor
Specifies the center of the decal region. When null, the region will follow the main camera.
Declaration
public Transform decalRegionAnchor
Field Value
decalRegionSize
Specifies the size of the decal region in meters.
Declaration
public Vector2 decalRegionSize
Field Value
Specifies if the water surfaces supports local deformations.
Declaration
Field Value
Specifies the resolution of the deformation texture used to represent the deformation area.
Declaration
[Tooltip("Specifies the resolution of the deformation texture used to represent the deformation area.")]
public WaterSurface.WaterDecalRegionResolution deformationRes
Field Value
directLightBodyScattering
Controls the intensity of the direct light scattering on the body of the waves. The effect is more perceivable at grazing angles.
Declaration
[Range(0, 1)]
[Tooltip("Controls the intensity of the direct light scattering on the body of the waves. The effect is more perceivable at grazing angles.")]
public float directLightBodyScattering
Field Value
directLightTipScattering
Controls the intensity of the direct light scattering on the tip of the waves. The effect is more perceivable at grazing angles.
Declaration
[Range(0, 1)]
[Tooltip("Controls the intensity of the direct light scattering on the tip of the waves. The effect is more perceivable at grazing angles.")]
public float directLightTipScattering
Field Value
displacementScattering
Controls the intensity of the displacement based scattering. The bigger horizontal displacement, the more the water receives scattering. This can be adjusted for artistic purposes.
Declaration
[Range(0, 1)]
[Tooltip("Controls the intensity of the displacement based scattering. The bigger horizontal displacement, the more the water receives scattering. This can be adjusted for artistic purposes.")]
public float displacementScattering
Field Value
endSmoothness
Declaration
public float endSmoothness
Field Value
foam
Specifies if the water surfaces support foam rendering.
Declaration
Field Value
foamColor
Declaration
Field Value
foamCurrentInfluence
Specifies the influence of current on foam.
Declaration
[Range(0, 1)]
public float foamCurrentInfluence
Field Value
foamPersistenceMultiplier
Specifies the foam persistence multiplier. A higher value will lead to the foam remaining visible longer.
Declaration
[Range(0, 1)]
public float foamPersistenceMultiplier
Field Value
foamResolution
Specifies the resolution of the foam texture.
Declaration
[Tooltip("Specifies the resolution of the foam texture.")]
public WaterSurface.WaterDecalRegionResolution foamResolution
Field Value
foamSmoothness
Controls the surface foam smoothness.
Declaration
[Range(0, 1)]
public float foamSmoothness
Field Value
foamTextureTiling
Set the per meter tiling for the foam texture.
Declaration
[Min(0)]
public float foamTextureTiling
Field Value
geometryType
Specifies the type of geometry used to render the water surface.
Declaration
public WaterGeometryType geometryType
Field Value
heightScattering
Controls the intensity of the height based scattering. The higher the vertical displacement, the more the water receives scattering. This can be adjusted for artistic purposes.
Declaration
[Range(0, 1)]
[Tooltip("Controls the intensity of the height based scattering. The higher the vertical displacement, the more the water receives scattering. This can be adjusted for artistic purposes.")]
public float heightScattering
Field Value
largeBand0FadeDistance
Declaration
public float largeBand0FadeDistance
Field Value
largeBand0FadeMode
Declaration
public WaterSurface.FadeMode largeBand0FadeMode
Field Value
largeBand0FadeStart
Declaration
public float largeBand0FadeStart
Field Value
largeBand0FadeToggle
Declaration
[SerializeField]
[Obsolete("Use largeBand0FadeMode instead @from(2023.1)")]
public bool largeBand0FadeToggle
Field Value
largeBand0Multiplier
Declaration
[Range(0, 1)]
public float largeBand0Multiplier
Field Value
largeBand1FadeDistance
Declaration
public float largeBand1FadeDistance
Field Value
largeBand1FadeMode
Declaration
public WaterSurface.FadeMode largeBand1FadeMode
Field Value
largeBand1FadeStart
Declaration
public float largeBand1FadeStart
Field Value
largeBand1FadeToggle
Declaration
[SerializeField]
[Obsolete("Use largeBand1FadeMode instead @from(2023.1)")]
public bool largeBand1FadeToggle
Field Value
largeBand1Multiplier
Declaration
[Range(0, 1)]
public float largeBand1Multiplier
Field Value
largeChaos
Declaration
[Range(0, 1)]
public float largeChaos
Field Value
largeCurrentMap
Declaration
public Texture largeCurrentMap
Field Value
largeCurrentMapInfluence
Declaration
[Range(0, 1)]
public float largeCurrentMapInfluence
Field Value
largeCurrentRegionExtent
Declaration
public Vector2 largeCurrentRegionExtent
Field Value
largeCurrentRegionOffset
Declaration
public Vector2 largeCurrentRegionOffset
Field Value
largeCurrentRes
Specifies the resolution of the texture used to represent the large current area.
Declaration
[Tooltip("Specifies the resolution of the texture used to represent the large current area.")]
public WaterSurface.WaterDecalRegionResolution largeCurrentRes
Field Value
largeCurrentSpeedValue
Declaration
public float largeCurrentSpeedValue
Field Value
largeOrientationValue
Declaration
public float largeOrientationValue
Field Value
largeWindSpeed
Declaration
[Range(0, 250)]
public float largeWindSpeed
Field Value
lightLayerMask
Specifies the light layers that affect the water surface.
Declaration
[SerializeField]
[Obsolete("Use renderingLayerMask instead @from(2023.1) (UnityUpgradable) -> renderingLayerMask")]
public RenderingLayerMask lightLayerMask
Field Value
maskRes
Specifies the resolution of the mask texture used to represent the mask area.
Declaration
[Tooltip("Specifies the resolution of the mask texture used to represent the mask area.")]
public WaterSurface.WaterDecalRegionResolution maskRes
Field Value
maxRefractionDistance
Controls the maximum distance in meters used to clamp the underwater refraction depth. Higher value increases the distortion amount.
Declaration
[Range(0, 3.5)]
[Tooltip("Controls the maximum distance in meters used to clamp the underwater refraction depth. Higher value increases the distortion amount.")]
public float maxRefractionDistance
Field Value
maxTessellationFactor
Sets the maximum tessellation factor for the water surface.
Declaration
[Range(0, 10)]
[Tooltip("Sets the maximum tessellation factor for the water surface.")]
public float maxTessellationFactor
Field Value
maximumHeightOverride
Specifies a maximum wave height that overrides the simulation to support scattering properly for deformers.
Declaration
[Min(0)]
[Tooltip("Specifies a maximum wave height that overrides the simulation to support scattering properly for deformers.")]
public float maximumHeightOverride
Field Value
meshRenderers
Sets the geometry to use when rendering in quad and custom geometry type mode. The vertical position of the vertices will be overridden to keep the surface of water leveled.
Declaration
public List<MeshRenderer> meshRenderers
Field Value
refractionColor
Sets the color that is used to simulate the under-water refraction.
Declaration
[Tooltip("Sets the color that is used to simulate the under-water refraction.")]
[ColorUsage(false)]
public Color refractionColor
Field Value
renderingLayerMask
Specifies the rendering layers that affect the water surface.
Declaration
[Tooltip("Specifies the rendering layers that affect the water surface.")]
public RenderingLayerMask renderingLayerMask
Field Value
repetitionSize
Declaration
[Range(250, 5000)]
public float repetitionSize
Field Value
ripples
When enabled, the water system allows you to simulate and render a ripples simulation for finer details.
Declaration
Field Value
ripplesChaos
Declaration
[Range(0, 1)]
public float ripplesChaos
Field Value
ripplesCurrentMap
Declaration
public Texture ripplesCurrentMap
Field Value
ripplesCurrentMapInfluence
Declaration
[Range(0, 1)]
public float ripplesCurrentMapInfluence
Field Value
ripplesCurrentRegionExtent
Declaration
public Vector2 ripplesCurrentRegionExtent
Field Value
ripplesCurrentRegionOffset
Declaration
public Vector2 ripplesCurrentRegionOffset
Field Value
ripplesCurrentRes
Specifies the resolution of the texture used to represent the ripples current area.
Declaration
[Tooltip("Specifies the resolution of the texture used to represent the ripples current area.")]
public WaterSurface.WaterDecalRegionResolution ripplesCurrentRes
Field Value
ripplesCurrentSpeedValue
Declaration
public float ripplesCurrentSpeedValue
Field Value
ripplesFadeDistance
Declaration
public float ripplesFadeDistance
Field Value
ripplesFadeMode
Declaration
public WaterSurface.FadeMode ripplesFadeMode
Field Value
ripplesFadeStart
Declaration
public float ripplesFadeStart
Field Value
ripplesFadeToggle
Declaration
[SerializeField]
[Obsolete("Use ripplesFadeMode instead @from(2023.1)")]
public bool ripplesFadeToggle
Field Value
ripplesMotionMode
Declaration
public WaterPropertyOverrideMode ripplesMotionMode
Field Value
ripplesOrientationValue
Declaration
public float ripplesOrientationValue
Field Value
ripplesWindSpeed
Declaration
[Range(0, 15)]
public float ripplesWindSpeed
Field Value
scatteringColor
Sets the color that is used to simulate the water light scattering.
Declaration
[Tooltip("Sets the color that is used to simulate the water light scattering.")]
[ColorUsage(false)]
public Color scatteringColor
Field Value
scriptInteractions
When enabled, the Water System allows you to make height requests from a C# script.
Declaration
[Tooltip("When enabled, the Water System allows you to make height requests from a C# script.")]
[FormerlySerializedAs("cpuSimulation")]
public bool scriptInteractions
Field Value
simulationFoamAmount
Controls the simulation foam amount. Higher values generate larger foam patches. Foam presence is highly dependent on the wind speed and choppiness values.
Declaration
[Range(0, 1)]
public float simulationFoamAmount
Field Value
simulationFoamMask
Set the texture used to attenuate or suppress the simulation foam.
Declaration
public Texture2D simulationFoamMask
Field Value
simulationFoamMaskExtent
Sets the extent of the foam mask in meters.
Declaration
public Vector2 simulationFoamMaskExtent
Field Value
simulationFoamMaskOffset
Sets the offset of the foam mask in meters.
Declaration
public Vector2 simulationFoamMaskOffset
Field Value
simulationFoamWindCurve
Controls the simulation foam amount depending on the wind speed.
Declaration
public AnimationCurve simulationFoamWindCurve
Field Value
simulationMask
True if this surface supports simulation mask decals.
Declaration
public bool simulationMask
Field Value
smoothnessFadeDistance
Declaration
public float smoothnessFadeDistance
Field Value
smoothnessFadeStart
Declaration
public float smoothnessFadeStart
Field Value
startSmoothness
Declaration
public float startSmoothness
Field Value
supportLargeCurrent
Specifies if the surface supports large current decals.
Declaration
public bool supportLargeCurrent
Field Value
supportRipplesCurrent
Specifies if the surface supports ripples current decals.
Declaration
public bool supportRipplesCurrent
Field Value
supportSimulationFoamMask
Set the texture used to attenuate or suppress the simulation foam.
Declaration
public bool supportSimulationFoamMask
Field Value
surfaceType
Specifies the nature of the water body that the water system needs to simulate.
Declaration
public WaterSurfaceType surfaceType
Field Value
tessellation
Use hardware tessellation when rendering the water surface
Declaration
[Tooltip("When enabled, HDRP activates tessellation for this Water Surface.\nThis improves the visual quality but may have a significant performance cost depending on the platform.")]
public bool tessellation
Field Value
tessellationFactorFadeRange
Sets the range at which the tessellation factor reaches zero.
Declaration
[Min(0)]
[Tooltip("Sets the range at which the tessellation factor reaches zero.")]
public float tessellationFactorFadeRange
Field Value
tessellationFactorFadeStart
Sets the distance at which the tessellation factor start to lower.
Declaration
[Min(0)]
[Tooltip(" Sets the distance at which the tessellation factor start to lower.")]
public float tessellationFactorFadeStart
Field Value
timeMultiplier
Sets the speed of the water simulation. This allows to slow down the waves' speed or to accelerate it.
Declaration
[Range(0, 10)]
public float timeMultiplier
Field Value
underWater
When enabled, HDRP will apply a fog and color shift to the final image when the camera is under the surface. This feature has a cost even when the camera is above the water surface.
Declaration
Field Value
underWaterAmbientProbeContribution
Sets the contribution of the ambient probe luminance when multiplied by the underwater scattering color.
Declaration
[Obsolete("Will be removed in the next version.")]
public float underWaterAmbientProbeContribution
Field Value
underWaterRefraction
Determines if water surface should refract light when looking at objects from underwater.
This simulates the correct behavior of water but may introduce visual artifacts as it relies on screen space refraction.
Declaration
public bool underWaterRefraction
Field Value
underWaterScatteringColor
Sets the color that is used to simulate the scattering when the camera is under-water.
Declaration
[ColorUsage(false)]
[Obsolete("Will be removed in the next version.")]
public Color underWaterScatteringColor
Field Value
underWaterScatteringColorMode
Sets how the underwater scattering color is specified.
Declaration
[Obsolete("Will be removed in the next version.")]
public WaterSurface.UnderWaterScatteringColorMode underWaterScatteringColorMode
Field Value
virtualPlaneDistance
Sets the distance at which the simulated caustics are projected. High values generate sharper caustics but can cause artifacts.
Declaration
[Min(0.001)]
public float virtualPlaneDistance
Field Value
volumeBounds
Sets a box collider that will be used to define the volume where the underwater effect is applied for non infinite surfaces.
Declaration
[Tooltip("Sets a box collider that will be used to define the volume where the underwater effect is applied for non infinite surfaces.")]
public BoxCollider volumeBounds
Field Value
volumeDepth
Sets maximum depth at which the underwater effect is evaluated for infinite surfaces.
Declaration
[Min(0)]
[Tooltip("Sets maximum depth at which the underwater effect is evaluated for infinite surfaces.")]
public float volumeDepth
Field Value
volumeHeight
Sets the maximum height at which the underwater effect is evaluated for infinite surfaces. This allows to cover the underwater scenario when deformers are higher than waves or ripples.
Declaration
[Min(0)]
[Tooltip("Sets the maximum height at which the underwater effect is evaluated for infinite surfaces. This allows to cover the underwater scenario when deformers are higher than waves or ripples.")]
public float volumeHeight
Field Value
volumePrority
Sets a priority value that is used to define which surface should be considered for underwater rendering in the case of multiple overlapping surfaces.
Declaration
[Min(0)]
[Tooltip("Sets a priority value that is used to define which surface should be considered for underwater rendering in the case of multiple overlapping surfaces.")]
public int volumePrority
Field Value
waterCurrentDebugMode
Sets the water current debug mode for a given water surface.
Declaration
public WaterCurrentDebugMode waterCurrentDebugMode
Field Value
waterFoamDebugMode
Sets the water foam debug mode for a given water surface.
Declaration
public WaterFoamDebugMode waterFoamDebugMode
Field Value
waterMask
Sets the texture used to attenuate or suppress the swell, agitation and ripples water frequencies.
Declaration
Field Value
waterMaskDebugMode
Sets the water mask debug mode for a given water surface.
Declaration
public WaterMaskDebugMode waterMaskDebugMode
Field Value
waterMaskExtent
Sets the extent of the water mask in meters.
Declaration
[Tooltip("Sets the extent of the water mask in meters.")]
public Vector2 waterMaskExtent
Field Value
waterMaskOffset
Sets the offset of the water mask in meters.
Declaration
[Tooltip("Sets the offset of the water mask in meters.")]
public Vector2 waterMaskOffset
Field Value
waterMaskRemap
Sets the remapped range of the water mask.
Declaration
[Tooltip("Sets the remapped range of the water mask.")]
public Vector2 waterMaskRemap
Field Value
Properties
simulationStart
Used to sync different water surfaces simulation time, for example across network.
Declaration
public DateTime simulationStart { get; set; }
Property Value
simulationTime
Current simulation time in seconds.
Declaration
public float simulationTime { get; set; }
Property Value
Methods
FillWaterSearchData(ref WaterSimSearchData)
Function that fills a WaterSimSearchData with the data of the current water surface.
Declaration
public bool FillWaterSearchData(ref WaterSimSearchData wsd)
Parameters
Returns
Type |
Description |
bool |
A boolean that defines if the function was able to fill the search data.
|
GetCausticsBuffer(out float)
Function that returns the caustics buffer for the water surface. If the feature is disabled or the resource is not available the function returns null.
Declaration
public Texture GetCausticsBuffer(out float regionSize)
Parameters
Type |
Name |
Description |
float |
regionSize |
Output parameter that returns the size of the caustics region.
|
Returns
Type |
Description |
Texture |
A monochrome texture that holds the caustics simulation of the water surface.
|
GetDecalRegion(out float2, out float2)
Function that returns the decal region center and size.
Declaration
public void GetDecalRegion(out float2 center, out float2 size)
Parameters
Type |
Name |
Description |
float2 |
center |
Region center, based on the anchor gameObject.
|
float2 |
size |
Region size.
|
Function that returns the deformation buffer for the water surface. If the feature is disabled or the resource is not available the function returns null.
Declaration
public Texture GetDeformationBuffer()
Returns
Type |
Description |
Texture |
A single channgel texture that holds the surface deformation of the water surface.
|
GetFoamBuffer(out Vector2)
Function that returns the foam buffer for the water surface. If the feature is disabled or the resource is not available the function returns null.
Declaration
public Texture GetFoamBuffer(out Vector2 foamArea)
Parameters
Type |
Name |
Description |
Vector2 |
foamArea |
Output parameter that returns the size of the foam region.
|
Returns
Type |
Description |
Texture |
An RG texture that holds the surface foam (red channel) and deep foam (green channel) of the water surface.
|
See Also
GetSimulationMaskBuffer()
Function that returns the simulation mask buffer for the water surface.
If the mask decals are disabled in the global settings or the feature is disabled by the water surface, the function returns null.
Declaration
public Texture GetSimulationMaskBuffer()
Returns
Type |
Description |
Texture |
A texture that holds the simulation mask for each band in the RGB channels and the simulation foam mask in the alpha channel.
|
See Also
ProjectPointOnWaterSurface(WaterSearchParameters, out WaterSearchResult)
Function that attempts to evaluate the projection of a given world space position onto the water surface. This requires the HDRP asset and the water surface to have script interactions enabled.
Declaration
public bool ProjectPointOnWaterSurface(WaterSearchParameters wsp, out WaterSearchResult wsr)
Parameters
Type |
Name |
Description |
WaterSearchParameters |
wsp |
The water simulation search parameters that defines the location we are targeting and additional parameters.
|
WaterSearchResult |
wsr |
The water simulation search result that contains the result position, error, etc.
|
Returns
Type |
Description |
bool |
A boolean that defines if the function was able to execute the evaluation.
|
SetGlobalTextures()
Function that globally binds the textures and constant buffer for use by external systems such as VFX Graph
As the binding is done globally, only one surface can be bound during a frame
Declaration
public bool SetGlobalTextures()
Returns
Type |
Description |
bool |
A boolean that indicates if the function was able to bind GlobalTextures.
|
Implements