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.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>, ISerializationCallbackReceiver
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
[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
[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
[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
public float causticsDirectionalShadowDimmer
Field Value
causticsIntensity
Sets the intensity of the under-water caustics.
Declaration
[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
[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
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
Specifies if the water surfaces supports local deformations.
Declaration
Field Value
Specified the offset of the deformation area in meters.
Declaration
[Tooltip("Specified the offset of the deformation area in meters.")]
public Vector2 deformationAreaOffset
Field Value
Specified the size of the deformation area in meters.
Declaration
[Tooltip("Specified the size of the deformation area in meters.")]
public Vector2 deformationAreaSize
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.WaterDeformationResolution 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
[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
[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
[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
foamAreaOffset
Specifies the offset of the foam area in meters.
Declaration
[Tooltip("Specifies the offset of the foam area in meters.")]
public Vector2 foamAreaOffset
Field Value
foamAreaSize
Specifies the size of the foam area in meters.
Declaration
[Tooltip("Specifies the size of the foam area in meters.")]
public Vector2 foamAreaSize
Field Value
foamColor
Declaration
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.WaterFoamResolution 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
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
[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
[Tooltip("")]
public float largeBand0FadeDistance
Field Value
largeBand0FadeMode
Declaration
public WaterSurface.FadeMode largeBand0FadeMode
Field Value
largeBand0FadeStart
Declaration
[Tooltip("")]
public float largeBand0FadeStart
Field Value
largeBand0FadeToggle
Declaration
[SerializeField]
[Obsolete("Use largeBand0FadeMode instead @from(2023.1)")]
public bool largeBand0FadeToggle
Field Value
largeBand0Multiplier
Declaration
public float largeBand0Multiplier
Field Value
largeBand1FadeDistance
Declaration
[Tooltip("")]
public float largeBand1FadeDistance
Field Value
largeBand1FadeMode
Declaration
[Tooltip("")]
public WaterSurface.FadeMode largeBand1FadeMode
Field Value
largeBand1FadeStart
Declaration
[Tooltip("")]
public float largeBand1FadeStart
Field Value
largeBand1FadeToggle
Declaration
[SerializeField]
[Obsolete("Use largeBand1FadeMode instead @from(2023.1)")]
public bool largeBand1FadeToggle
Field Value
largeBand1Multiplier
Declaration
[Tooltip("")]
public float largeBand1Multiplier
Field Value
largeChaos
Declaration
Field Value
largeCurrentMap
Declaration
public Texture largeCurrentMap
Field Value
largeCurrentMapInfluence
Declaration
public float largeCurrentMapInfluence
Field Value
largeCurrentRegionExtent
Declaration
public Vector2 largeCurrentRegionExtent
Field Value
largeCurrentRegionOffset
Declaration
public Vector2 largeCurrentRegionOffset
Field Value
largeCurrentSpeedValue
Declaration
public float largeCurrentSpeedValue
Field Value
largeOrientationValue
Declaration
public float largeOrientationValue
Field Value
largeWindSpeed
Declaration
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
maxRefractionDistance
Controls the maximum distance in meters used to clamp the underwater refraction depth. Higher value increases the distortion amount.
Declaration
[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
[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
[Tooltip("")]
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
[Tooltip("")]
public float ripplesChaos
Field Value
ripplesCurrentMap
Declaration
public Texture ripplesCurrentMap
Field Value
ripplesCurrentMapInfluence
Declaration
public float ripplesCurrentMapInfluence
Field Value
ripplesCurrentRegionExtent
Declaration
public Vector2 ripplesCurrentRegionExtent
Field Value
ripplesCurrentRegionOffset
Declaration
public Vector2 ripplesCurrentRegionOffset
Field Value
ripplesCurrentSpeedValue
Declaration
public float ripplesCurrentSpeedValue
Field Value
ripplesFadeDistance
Declaration
[Tooltip("")]
public float ripplesFadeDistance
Field Value
ripplesFadeMode
Declaration
[Tooltip("")]
public WaterSurface.FadeMode ripplesFadeMode
Field Value
ripplesFadeStart
Declaration
[Tooltip("")]
public float ripplesFadeStart
Field Value
ripplesFadeToggle
Declaration
[SerializeField]
[Obsolete("Use ripplesFadeMode instead @from(2023.1)")]
public bool ripplesFadeToggle
Field Value
ripplesMotionMode
Declaration
[Tooltip("")]
public WaterPropertyOverrideMode ripplesMotionMode
Field Value
ripplesOrientationValue
Declaration
[Tooltip("")]
public float ripplesOrientationValue
Field Value
ripplesWindSpeed
Declaration
[Tooltip("")]
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
simulationFoam
When enabled, the water surface will receive foam from the simulation on the crest of the waves.
Declaration
public bool simulationFoam
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
smoothnessFadeDistance
Declaration
public float smoothnessFadeDistance
Field Value
smoothnessFadeStart
Declaration
public float smoothnessFadeStart
Field Value
startSmoothness
Declaration
public float startSmoothness
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
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
[Tooltip("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.")]
public bool underWater
Field Value
underWaterAmbientProbeContribution
Sets the contribution of the ambient probe luminance when multiplied by the underwater scattering color.
Declaration
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
[Tooltip("Sets the color that is used to simulate the scattering when the camera is under-water.")]
[ColorUsage(false)]
public Color underWaterScatteringColor
Field Value
underWaterScatteringColorMode
Sets how the underwater scattering color is specified.
Declaration
[Tooltip("Sets how the underwater scattering color is specified.")]
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
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
[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
[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
[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
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.
|
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.
|
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.
|
Implements