3. Water Appearance#

3.1. Material Parameters#

3.1.1. Normals#

Overall Normal Strength Strength of the final surface normal (includes both wave normal and normal map)
Use Normal Map Whether to add normal detail from a texture. Can be used to add visual detail to the water surface BIRP URP
Normal Map Normal map and caustics distortion texture (should be set to Normals type in the properties)
Normal Map Scale Scale of normal map texture
Normal Map Strength Strength of normal map influence

3.1.2. Scattering#

Scatter Colour Base Base colour when looking straight down into water.
Scatter Colour Grazing Base colour when looking into water at shallow/grazing angle. BIRP URP
Enable Shadowing Changes colour in shadow. Requires ‘Create Shadow Data’ enabled on OceanRenderer script. BIRP URP
Scatter Colour Shadow Base colour in shadow. Requires ‘Create Shadow Data’ enabled on OceanRenderer script.

3.1.3. Subsurface Scattering#

Enable Whether to to emulate light scattering through the water volume. BIRP URP
SSS Tint Colour tint for primary light contribution.
SSS Intensity Base Amount of primary light contribution that always comes in.
SSS Intensity Sun Primary light contribution in direction of light to emulate light passing through waves.
SSS Sun Falloff Falloff for primary light scattering to affect directionality.

3.1.4. Shallow Scattering#

Deprecated

Shallow Scattering will be removed in a future version. A properly tweaked Depth Fog Density achieves better results at lower cost. Consider copying over the value from our materials.

The water colour can be varied in shallow water (this requires a depth cache created so that the system knows which areas are shallow, see section Shorelines and Shallows).

Enable Enable light scattering in shallow water. BIRP URP
Scatter Colour Shallow Scatter colour used for shallow water.
Scatter Colour Depth Max Maximum water depth that is considered ‘shallow’, in metres. Water that is deeper than this depth is not affected by shallow colour.
Scatter Colour Depth Falloff Falloff of shallow scattering, which gives control over the appearance of the transition from shallow to deep.
Scatter Colour Shallow Shadow Shallow water colour in shadow (see comment on Shadowing param above). BIRP URP

3.1.5. Reflection Environment#

Specular Strength of specular lighting response.
Occlusion Strength of reflection. HDRP
Smoothness Smoothness of surface. HDRP URP
Vary Smoothness Over Distance Helps to spread out specular highlight in mid-to-background. From a theory point of view, models transfer of normal detail to microfacets in BRDF. URP
Smoothness Far Material smoothness at far distance from camera. HDRP URP
Smoothness Far Distance Definition of far distance. HDRP URP
Smoothness Falloff How smoothness varies between near and far distance. HDRP URP
Roughness Controls blurriness of reflection BIRP
Softness Acts as mip bias to smooth/blur reflection. URP
Light Intensity Multiplier Main light intensity multiplier. URP
Fresnel Power Controls harshness of Fresnel behaviour. BIRP URP
Refractive Index of Air Index of refraction of air. Can be increased to almost 1.333 to increase visibility up through water surface. BIRP URP

Deprecated

The Refractive Index of Air property will be removed in a future version.

Refractive Index of Water Index of refraction of water. Typically left at 1.333.
Planar Reflections Dynamically rendered ‘reflection plane’ style reflections. Requires OceanPlanarReflection script added to main camera. BIRP URP
Planar Reflections Distortion How much the water normal affects the planar reflection. BIRP URP
Override Reflection Cubemap Whether to use an overridden reflection cubemap (provided in the next property). BIRP
Reflection Cubemap Override Custom environment map to reflect. BIRP

3.1.6. Add Directional Light#

Enable Add specular highlights from the the primary light. BIRP
Boost Specular highlight intensity. BIRP
Falloff Falloff of the specular highlights from source to camera. BIRP
Vary Falloff Over Distance Helps to spread out specular highlight in mid-to-background. BIRP
Far Distance Definition of far distance. BIRP
Falloff At Far Distance Same as “Falloff” except only up to “Far Distance”. BIRP

3.1.7. Procedural Skybox#

Enable Enable a simple procedural skybox. Not suitable for realistic reflections, but can be useful to give control over reflection colour - especially in stylized/non realistic applications. BIRP URP
Base Base sky colour. BIRP URP
Towards Sun Colour in sun direction. BIRP URP
Directionality Direction fall off. BIRP URP
Away From Sun Colour away from sun direction. BIRP URP

3.1.8. Foam#

Enable Enable foam layer on ocean surface.
Foam Foam texture.
Foam Scale Foam texture scale.
Foam Feather Controls how gradual the transition is from full foam to no foam.
Foam Tint Colour tint for whitecaps / foam on water surface. BIRP URP
Light Scale Scale intensity of lighting. BIRP URP
Shoreline Foam Min Depth Proximity to sea floor where foam starts to get generated. BIRP URP
Foam Albedo Intensity Scale intensity of diffuse lighting. HDRP
Foam Emissive Intensity Scale intensity of emitted light. HDRP
Foam Smoothness Smoothness of foam material. HDRP

3.1.9. Foam 3D Lighting#

Enable Generates normals for the foam based on foam values/texture and use it for foam lighting. BIRP URP
Foam Normal Strength Strength of the generated normals.
Specular Fall-Off Acts like a gloss parameter for specular response. BIRP URP
Specular Boost Strength of specular response. BIRP URP

3.1.10. Foam Bubbles#

Foam Bubbles Color Colour tint bubble foam underneath water surface.
Foam Bubbles Parallax Parallax for underwater bubbles to give feeling of volume.
Foam Bubbles Coverage How much underwater bubble foam is generated.

3.1.11. Transparency#

Enable Whether light can pass through the water surface. BIRP URP
Refraction Strength How strongly light is refracted when passing through water surface.
Depth Fog Density Scattering coefficient within water volume, per channel.

3.1.12. Caustics#

Enable Approximate rays being focused/defocused on underwater surfaces.
Caustics Caustics texture.
Caustics Scale Caustics texture scale.
Caustics Texture Grey Point The ‘mid’ value of the caustics texture, around which the caustic texture values are scaled.
Caustics Strength Scaling / intensity.
Caustics Focal Depth The depth at which the caustics are in focus.
Caustics Depth Of Field The range of depths over which the caustics are in focus.
Caustics Distortion Texture Texture to distort caustics. HDRP
Caustics Distortion Strength How much the caustics texture is distorted.
Caustics Distortion Scale The scale of the distortion pattern used to distort the caustics.

3.1.13. Underwater#

Enable Whether the underwater effect is being used. This enables code that shades the surface correctly from underneath. BIRP URP
Cull Mode Ordinarily set this to Back to cull back faces, but set to Off to make sure both sides of the surface draw if the underwater effect is being used.

3.1.14. Flow#

Example

Flow is demonstrated in the whirlpool example scene.

Enable Flow is horizontal motion in water. ‘Create Flow Sim’ must be enabled on the OceanRenderer to generate flow data.

3.2. Lighting#

3.2.1. General#

As other shaders would, the ocean will get most its lighting from the primary directional light (AKA sun).

Crest does not support additional lights due to bugs in the pipeline and performance concerns. Please see #382 and #383 for more details.

Like other mesh renderers, this can be masked by setting the Rendering Layer Mask property on the Ocean Renderer. Please see the HDRP documentation on light layers for more information on setup and usage.

But some lighting will come from the light set as the Primary Light on the Ocean Renderer. This includes the sub-surface scattering colour.

Lighting can also be overriden with the Indirect Lighting Controller. Please see the HDRP documentation on volume overrides for more information on setup and usage.

For the ocean to have lighting completely separate from everything else, you would need to do all of the above.

Additional lights are supported unless using Forward+.

See Water Tile Prefab for advanced configuration.

3.2.2. Reflections#

Reflections contribute hugely to the appearance of the ocean. The look of the ocean will dramatically changed based on the reflection environment.

The Index of Refraction setting controls how much reflection contributes for different view angles.

The base reflection comes from a one of these sources:

  • Unity’s specular cubemap. This is the default and is the same as what is applied to glossy objects in the scene. It will support reflection probes, as long as the probe extents cover the ocean tiles, which enables real-time update of the reflection environment (see Unity documentation for more details).

  • Override reflection cubemap. If desired a cubemap can be provided to use for the reflections. For best results supply a HDR cubemap.

  • Procedural skybox. Developed for stylized games, this is a simple approximation of sky colours that will give soft results.

This base reflection can then be overridden by dynamic planar reflections. This can be used to augment the reflection with 3D objects such as boat or terrain. This can be enabled by applying the Ocean Planar Reflections script to the active camera and configuring which layers get reflected (don’t include the Water layer). This renders every frame by default but can be configured to render less frequently. This only renders one view but also only captures a limited field of view of reflections, and the reflection directions are scaled down to help keep them in this limited view, which can give a different appearance. Furthermore ‘planar’ means the surface is approximated by a plane which is not the case for wavey ocean, so the effect can break down. This method is good for capturing local objects like boats and etcetera.

A good strategy for debugging the use of Unity’s specular cubemap is to put another reflective/glossy object in the scene near the surface, and verify that it is lit and reflects the scene properly. Crest tries to use the same inputs for lighting/reflections, so if it works for a test object it should work for the water surface as well.

Crest makes full use of the flexible lighting options in HDRP (it is lit the same as a shadergraph shader would be).

Planar Reflection Probes

HDRP comes with a Planar Reflection Probe feature which enables dynamic reflection of the environment at run-time, with a corresponding cost. See Unity’s documentation on Planar Reflection Probes. At time of writing we used the following steps:

  • Create new GameObject

  • Set the height of the GameObject to the sea level.

  • Add the component from the Unity Editor menu using Component/Rendering/Planar Reflection Probe

  • Set the extents of the probe to be large enough to cover everything that needs to be reflected. We recommend starting large (1000m or more as a starting point).

  • Ensure water is not included in the reflection by deselecting Water on the Culling Mask field

  • Check the documentation linked above for details on individual parameters

HDRP’s planar reflection probe is very sensitive to surface normals and often ‘leaks’ reflections, for example showing the reflection of a boat on the water above the boat. If you see these issues we recommend reducing the Overall Normal Strength parameter on the ocean material.

The planar reflection probe assumes the reflecting surface is a flat plane. This is not the case for for a wavey water surface and this can also produce ‘leaky’ reflections. In such cases it can help to lower the reflection probe below sea level slightly.

Screen-Space Reflections

HDRP has a separate setting for transparents to receive SSR and it is not enabled by default. It is important that you understand the basics of HDRP before proceeding.

  1. Enable Screen Space Refection and the Transparent sub-option in the Frame Settings.

  2. Add and configure the SSR Volume Override

    • Please learn how to use the Volume Framework before proceeding as covering this is beyond the scope of our documentation:

      Fig. 3.1 Adding Volumes to HDRP (Tutorial)#

  3. Enable Receives Screen-Space Reflections on the ocean material.

The base reflection comes from a one of these sources:

  • Unity’s specular cubemap. This is the default and is the same as what is applied to glossy objects in the scene. It will support reflection probes, as long as the probe extents cover the ocean tiles, which enables real-time update of the reflection environment (see Unity documentation for more details).

  • Procedural skybox. Developed for stylized games, this is a simple approximation of sky colours that will give soft results.

This base reflection can then be overridden by dynamic planar reflections. This can be used to augment the reflection with 3D objects such as boat or terrain. This can be enabled by applying the Ocean Planar Reflections script to the active camera and configuring which layers get reflected (don’t include the Water layer). This renders every frame by default but can be configured to render less frequently. This only renders one view but also only captures a limited field of view of reflections, and the reflection directions are scaled down to help keep them in this limited view, which can give a different appearance. Furthermore ‘planar’ means the surface is approximated by a plane which is not the case for wavey ocean, so the effect can break down. This method is good for capturing local objects like boats and etcetera.

A good strategy for debugging the use of Unity’s specular cubemap is to put another reflective/glossy object in the scene near the surface, and verify that it is lit and reflects the scene properly. Crest tries to use the same inputs for lighting/reflections, so if it works for a test object it should work for the water surface as well.

See Water Tile Prefab for advanced configuration.

3.2.3. Refractions#

Refractions sample from the camera’s colour texture. Anything rendered in the transparent pass or higher will not be included in refractions.

See Transparent Object In Front Of Ocean Surface for issues with Crest and other refractive materials.

3.2.4. Water Tile Prefab#

Crest uses Mesh Renderers to render chunks of water throughout the scene. Mesh Renderers have many settings for configuring how a mesh responds to different lighting components like probes.

The Water Tile Prefab allows you to provide a pre-configured Mesh Renderer to override Crest’s defaults. Some settings cannot be overriden as they make no sense or require support from Crest.

To use this feature, create a prefab with a Mesh Renderer. The only other requirement is to not have a Water Chunk Renderer present in the prefab.

Settings which cannot be overriden are: - Receive Shadows - Motion Vectors

Other settings may not have any effect depending on the level of support with the render pipeline.

3.3. Foam#

3.3.1. Overview#

Crest simulates foam getting generated by choppy water (pinched) wave crests) and in shallow water to approximate foam from splashes at shoreline. Each update (default is 30 updates per second), the foam values are reduced to model gradual dissipation of foam over time.

To turn on this feature, enable the Create Foam Sim option on the OceanRenderer script, and ensure the Enable option is ticked in the Foam group on the ocean material.

To configure the foam sim, create a Foam Sim Settings asset by right clicking the a folder in the Project window and selecting Create/Crest/Foam Sim Settings, and assigning it to the OceanRenderer component in your scene.

3.3.2. User Inputs#

Foam supports Spline Mode and Renderer Mode.

Crest supports inputing any foam into the system, which can be helpful for fine tuning where foam is placed. To place foam, add some geometry into the world at the area where foam should be added. Then assign the RegisterFoamInput script which will tag it for rendering into the shape, and apply a material with a shader of type Crest/Inputs/Foam/…. See the DepositFoamTex object in the whirlpool.unity scene for an example.

The process for adding inputs is demonstrated in this Fig. 4.1.

The following input shaders are provided under Crest/Inputs/Foam:

  • Add From Texture adds foam values read from a user provided texture. Can be useful for placing ‘blobs’ of foam as desired, or can be moved around at runtime to paint foam into the sim.

  • Add From Vert Colours can be applied to geometry and uses the red channel of vertex colours to add foam to the sim. Similar in purpose to Add From Texture, but can be authored in a modelling workflow instead of requiring at texture.

  • Override Foam sets the foam to the provided value. Useful for removing foam from unwanted areas.

3.3.3. Simulation Settings#

3.3.3.1. General Settings#

  • Foam Fade Rate - How quickly foam dissipates. Low values mean foam remains on surface for longer. This setting should be balanced with the generation strength parameters below.

3.3.3.2. Wave foam / whitecaps#

Crest detects where waves are ‘pinched’ and deposits foam to approximate whitecaps.

  • Wave Foam Strength - Scales intensity of foam generated from waves. This setting should be balanced with the Foam Fade Rate setting.

  • Wave Foam Coverage - How much of the waves generate foam. Higher values will lower the threshold for foam generation, giving a larger area.

3.3.3.3. Shoreline foam#

If water depth input is provided to the system (see Sea Floor Depth section below), the foam sim can automatically generate foam when water is very shallow, which can approximate accumulation of foam at shorelines.

  • Shoreline Foam Max Depth - Foam will be generated in water shallower than this depth. Controls how wide the band of foam at the shoreline will be. Note that this is not a distance to shoreline, but a threshold on water depth, so the width of the foam band can vary based on terrain slope. To address this limitation we allow foam to be manually added from geometry or from a texture, see the next section.

  • Shoreline Foam Strength - Scales intensity of foam generated in shallow water. This setting should be balanced with the Foam Fade Rate setting.

3.3.3.4. Developer Settings#

These settings should generally be left unchanged unless one is experiencing issues.

  • Simulation Frequency - Frequency to run the foam sim, in updates per second. Lower frequencies can be more efficient but may lead to visible jitter. Default is 30 updates per second.

3.4. Shadows#

The shadow data consists of two channels. One is for normal shadows (hard shadow term) as would be used to block specular reflection of the light. The other is a much softer shadowing value (soft shadow term) that can approximately variation in light scattering in the water volume.

This data is captured from the shadow maps Unity renders before the transparent pass. These shadow maps are always rendered in front of the viewer. The Shadow LOD Data then reads these shadow maps and copies shadow information into its LOD textures.

To turn on this feature, enable the Create Shadow Data option on the OceanRenderer script, and ensure the Shadowing option is ticked on the ocean material.

To turn on this feature, enable the Create Shadow Data option on the OceanRenderer script.

Specular (direct) lighting on the ocean surface is not shadowed by this data. It is shadowed by the pipeline. But we still use the data to shadow anything not covered by the pipeline like caustic shadows.

To create this setup from scratch, the steps are the following.

  1. On the HDRP asset (either the asset provided with Crest Assets/Crest/CrestExampleHDRPAsset, or the one used in your project), ensure that Custom Pass is enabled.

  2. Shadow maps must be enabled in the frame settings for the camera.

  3. Enable shadowing in Crest. Enable Create Shadow Data on the OceanRenderer script.

  4. On the same script, assign a Primary Light for the shadows. This light needs to have shadows enabled, if not an error will be reported accordingly.

  5. If desired the shadow sim can be configured by assigning a Shadow Sim Settings asset (Create/Crest/Shadow Sim Settings).

To turn on this feature, enable the Create Shadow Data option on the OceanRenderer script, and ensure the Shadowing option is ticked on the ocean material.

To create this setup from scratch, the steps are the following.

  1. In the shadow settings of the URP asset, ensure that shadow cascades are enabled. Crest requires cascades to be enabled to obtain shadow information.

  2. Enable shadowing in Crest. Enable Create Shadow Data on the OceanRenderer script.

  3. On the same script, assign a Primary Light for the shadows. This light needs to have shadows enabled, if not an error will be reported accordingly.

  4. If desired the shadow sim can be configured by assigning a Shadow Sim Settings asset (Create/Crest/Shadow Sim Settings).

  5. Enable Shadowing on the ocean material to compile in the necessary shader code

The shadow sim can be configured by assigning a Shadow Sim Settings asset to the OceanRenderer script in your scene (Create/Crest/Shadow Sim Settings). In particular, the soft shadows are very soft by default, and may not appear for small/thin shadow casters. This can be configured using the Jitter Diameter Soft setting.

There will be times when the shadow jitter settings will cause shadows or light to leak. An example of this is when trying to create a dark room during daylight. At the edges of the room the jittering will cause the ocean on the inside of the room (shadowed) to sample outside of the room (not shadowed) resulting in light at the edges. Reducing the Jitter Diameter Soft setting can solve this, but we have also provided a Register Shadow Input component which can override the shadow data. This component bypasses jittering and gives you full control.

Shadows only supports the Renderer Mode.

3.5. Custom Albedo#

3.5.1. Overview#

The Albedo feature allows a colour layer to be composited on top of the water surface. This is useful for projecting colour onto the surface.

This is somewhat similar to decals, except the colour only affects the water.

Note

HDRP has a Decal Projector feature that works with the water, and the effect is more configurable and may be preferred over this feature. When using this feature be sure to enable Affects Transparent.

URP 2022 has a decal system but it does not support transparent surfaces like water.

There is a Render Alpha On Surface component which is an alternative. It behaves similar to a decal projector, but has several issues like z-order issues.

3.5.2. User Inputs#

Note

Inputs only execute the first shader pass (pass zero). It is recommended to use unlit shader templates or unlit Shader Graph (URP only) if not using one of ours. Shaders provided by Unity generally will not work as their primary pass is not zero - even for unlit shaders.

Albedo only supports the Renderer Mode.

Any geometry or particle system can add colour to the water. It will be projected from a top down perspective onto the water surface.

To tag GameObjects to render onto the water, attach the RegisterAlbedoInput component.

3.6. Orthographic Projection#

Crest supports orthographic projection out-of-the-box, but it might require some configuration to get a desired appearance.

Crest uses the camera’s position for the LOD system which can be awkward for orthographic which uses the size property on the camera. Use the Viewpoint property on the Ocean Renderer to override the camera’s position.

Underwater effects do not currently support orthographic projection.

3.7. Ocean Construction Parameters#

There are a small number of parameters that control the construction of the ocean shape and geometry:

  • Lod Data Resolution - the resolution of the various ocean LOD data including displacement textures, foam data, dynamic wave sims, etc. Sets the ‘detail’ present in the ocean - larger values give more detail at increased run-time expense.

  • Geometry Down Sample Factor - geometry density - a value of 2 will generate one vert per 2x2 LOD data texels. A value of 1 means a vert is generated for every LOD data texel. Larger values give lower fidelity surface shape with higher performance.

  • Lod Count - the number of levels of detail / scales of ocean geometry to generate. The horizontal range of the ocean surface doubles for each added LOD, while GPU processing time increases linearly. It can be useful to select the ocean in the scene view while running in editor to inspect where LODs are present.

  • Max Scale - the ocean is scaled horizontally with viewer height, to keep the meshing suitable for elevated viewpoints. This sets the maximum the ocean will be scaled if set to a positive value.

  • Min Scale - this clamps the scale from below, to prevent the ocean scaling down to 0 when the camera approaches the sea level. Low values give lots of detail, but will limit the horizontal extents of the ocean detail. Increasing this value can be a great performance saving for mobile as it will reduce draw calls.

3.8. Advanced Ocean Parameters#

These parameters are found on the Ocean Renderer under the Advanced heading.

  • Surface Self-Intersection Mode - How Crest should handle self-intersections of the ocean surface caused by choppy waves which can cause a flipped underwater effect. When not using the portals/volumes, this fix is only applied when within 2 metres of the ocean surface. Automatic will disable the fix if portals/volumes are used and is the recommended setting.

  • Underwater Cull Limit - Proportion of visibility below which ocean will be culled underwater. The larger the number, the closer to the camera the ocean tiles will be culled.