2. Configuration¶
Some quick start pointers for changing the ocean look and behaviour:
Ocean surface appearance: The active ocean material is displayed below the OceanRenderer component. The material parameters are described in section Material Parameters. Turn off unnecessary features to maximize performance.
Animated waves / ocean shape: Configured on the ShapeGerstnerBatched script by providing an Ocean Wave Spectrum asset. This asset has an equalizer-style interface for tweaking different scales of waves, and also has some parametric wave spectra from the literature for comparison. See section Wave Conditions.
Shallow water: Any ocean seabed geometry needs set up to register it with Crest. See section Shorelines and Shallows.
Ocean foam: Configured on the OceanRenderer script by providing a Sim Settings Foam asset.
Underwater: If the camera needs to go underwater, the underwater effect must be configured. See section Underwater for instructions.
Dynamic wave simulation: Simulates dynamic effects like object-water interaction. Configured on the OceanRenderer script by providing a Sim Settings Wave asset, described in section Simulation Settings.
A big strength of Crest is that you can add whatever contributions you like into the system. You could add your own shape or deposit foam onto the surface where desired. Inputs are generally tagged with the Register scripts and examples can be found in the example content scenes.
All settings can be changed at run-time and live authored. When tweaking ocean shape it can be useful to freeze time (from script, set Time.timeScale to 0) to clearly see the effect of each octave of waves.
Tip
By default, the update speed is intentionally throttled by Unity to save power when in edit mode. To enable real-time update, enable Animated Materials in the Scene View toggles:
See the Unity Documentation for more information.
2.1. Material Parameters¶
2.1.1. Normals¶
2.1.2. Scattering¶
2.1.3. Subsurface Scattering¶
2.1.4. Shallow Scattering¶
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).
2.1.5. Reflection Environment¶
Deprecated
The Refractive Index of Air property will be removed in a future version.
2.1.6. Add Directional Light¶
2.1.7. Procedural Skybox¶
2.1.8. Foam¶
2.1.9. Foam 3D Lighting¶
2.1.10. Foam Bubbles¶
2.1.11. Transparency¶
2.1.12. Caustics¶
2.1.13. Underwater¶
2.1.14. Flow¶
2.2. Lighting¶
2.2.1. General¶
Sponsor
Sponsoring us will help increase our development bandwidth which could work towards improving this feature.
Crest BIRP does not support additional lights due to bugs in the pipeline and performance concerns. Please see #382 and #383 for more details.
TODO
This section is a work in progress.
As other shaders would, the ocean will get its lighting from the primary directional light (AKA sun). 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.
Sponsor
Sponsoring us will help increase our development bandwidth which could work towards improving this feature.
Crest URP currently does not support additional lights.
TODO
This section is a work in progress.
2.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.
Enable Screen Space Refection and the Transparent sub-option in the Frame Settings.
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:
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.
2.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.
2.3. 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.
2.4. 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.