Documentation

ShoreLine

Mobile-ready stylized water for Unity URP: depth colour, shore waves, foam, caustics, refraction and Gerstner waves, an ocean to the horizon, three quality tiers and CPU height queries.

  • Version 1.0.0
  • Unity 6000.0+
  • Platforms Android, iOS, Desktop
  • Updated Nov 19, 2026
ShoreLine

Overview

ShoreLine is a hand-written URP water shader built for phones first: water that changes colour with depth, foam where it meets the shore and objects, shore waves rolling up the beach, Gerstner waves, caustics, refraction and reflections. It comes with an ocean that reaches the horizon, three quality tiers tuned on real devices, and CPU height queries that match the waves on screen.

Every feature is a per-material toggle compiled as a shader keyword, so features you switch off cost nothing and are stripped from your builds. A demo island shows everything, with touch controls for trying it on a phone.

Requirements

ItemVersionNotes
Unity6000.0+Tested on 6000.0, 6000.3 and 6000.6
Universal Render Pipeline17.0+A Universal Renderer, Forward or Forward+. Render Graph.
com.unity.inputsystemanyOptional Only the demo's camera reads input; it works with the Input System or the legacy Input Manager

Tested on Android with OpenGL ES 3 and Vulkan. The shader also compiles for Direct3D 11 and Metal (checked by the package's tests). Perspective and orthographic cameras are both supported.

Quick start

  1. Import the package Everything lands in Assets/HardArtcore/ShoreLine.
  2. Try the demo Open Demo/ShoreLine_Demo.unity and press Play. If the scene's water looks flat and plain, follow the next step first.
  3. Add the renderer feature Select any water material. If your URP renderer is missing the ShoreLine Feature, the inspector says so: click Fix: add ShoreLine Feature. It is safe to click twice; it never adds a second copy.
  4. Make a water mesh Tools › HardArtcore › ShoreLine › Create Water Mesh. Waves move the vertices, so the water needs a subdivided grid, not Unity's plane.
  5. Add the water Create a GameObject with a Mesh Filter (your new mesh), a Mesh Renderer and Add Component › HardArtcore › ShoreLine › Water Surface. Assign a material from Materials/Presets.
Tip

Put something under the water: the depth colour, foam and shore waves all come from the distance between the water surface and the ground below it.

The demo scene

Demo/ShoreLine_Demo.unity is a sandy island in an ocean that reaches the horizon: a sloped beach with shore waves, rocks with foam lines, a shallow lagoon with caustics, and a stone pier with one pool per preset.

ControlTouchMouse
OrbitDrag with one fingerLeft drag
ZoomPinchScroll wheel
PanDrag with two fingersRight or middle drag
Hide the UIHide UI, then tap the top-right corner to bring it backH

The Quality buttons swap the ocean between three materials, one per tier, the same way you would in a game. The Views buttons fly to the Island, Beach, Lagoon, Pools and Open Sea. Phones start on Medium, desktops on High. The demo's two scripts, DemoCameraController and DemoUI, are demo-only: delete the Demo folder when you don't need it.

Renderer setup

The ShoreLine Feature on your URP renderer asks URP for the camera depth texture (every depth effect needs it) and, while a water material uses Refraction, for the opaque texture. It also draws the Surface Effects buffer when something draws into it.

Buffer Resolution
Texels per side of the Surface Effects buffer, 64–2048. Default 512.
Buffer World Size
Meters the buffer covers, centred where the camera looks. Default 64.
Request Opaque Texture
Lets the feature request the opaque texture for Refraction. It only does so while an active Water Surface uses Refraction. Turn off if none of your water refracts.

Without the feature (or on a camera without a depth texture) the water never turns black or pink: depth effects read as deep water, and Refraction falls back to plain transparency. The material inspector shows a warning with a one-click fix for every active renderer that is missing the feature, and a clear message if the project isn't using URP.

Making water

Water meshes

Tools › HardArtcore › ShoreLine › Create Water Mesh saves a mesh asset:

Size
Width of the grid in meters.
Resolution
Quads per side, 1–512. More quads give smoother waves but cost more vertices; the window shows the vertex count.
Ocean Ring
Adds a low-detail ring around the grid that reaches to the horizon. Use it with Ocean Mode.
Outer Size
Total width including the ring, in meters.

The ring shares the grid's border vertices, so the mesh never cracks between the two. Waves are computed in world space, so you can scale and place several water objects freely.

Water Surface

Put a Water Surface on every water object. It keeps the renderer bounds large enough for the waves (so water at the screen edges is never culled), answers height queries, and runs Ocean Mode.

Ocean Mode
Moves the water with the camera, snapped to the grid spacing so the waves don't slide. Needs a mesh with an ocean ring.
Follow Camera
The camera Ocean Mode follows. Empty = Camera.main.

Presets

MaterialTierLook
Water_TropicalHighTurquoise shallows, deep blue, caustics
Water_LakeMediumGreen-blue, two gentle waves
Water_SwampMediumMurky olive, still, pale foam
Water_PoolHighClear pool blue, still, caustics, no shore waves or surface foam
Water_ToonMediumSaturated blues, crisp wide foam lines
Water_Default_Low / _Medium / _HigheachThe tropical look at each tier

The textures (normal map, foam noise and caustics) are generated by HardArtcore and tile seamlessly.

Material settings

The inspector groups the settings by feature; a feature's toggle shows or hides its settings. Every setting has a tooltip. The header links back to this documentation.

Colour

Shallow Color / Deep Color
Colour, and opacity in alpha, of shallow and deep water.
Horizon Color
Colour seen at grazing angles; alpha sets how strongly it is mixed in.
Depth Distance
Water depth in meters at which the Deep Color is fully reached.
Horizon Power
Higher keeps the horizon colour close to the horizon.
Edge Fade
Fades the water out where it meets objects, over this many meters of depth. 0 = off.

Waves

Waves
Gerstner waves that move the mesh. Needs a subdivided mesh.
Wave A–D
X, Y = direction on the XZ plane. Z = steepness 0–1. W = wavelength in meters. When the steepness of all waves adds up to more than 1, they are scaled down together so the surface never folds over.
Wave Count
How many of the waves A–D are used. Fewer waves are cheaper.
Wave Speed
Multiplier on the natural speed (longer waves travel faster).
Wave Fade Start / End
Distance from the camera (m) where waves start flattening, and where they are flat. In Ocean Mode keep the end inside the fine inner grid; the Water Surface inspector warns when it isn't.
Shallow Water Damping / Damping Depth
See Shallow Water Damping.

Normals and lighting

Normal Map / Strength / Tiling / Speed
Small ripples: two scrolling copies of the normal map, blended. Tiling is in repeats per meter.
Specular Color / Smoothness
The sun glint. Black = no glint; higher smoothness = a smaller, sharper glint.
Environment Reflections / Reflection Strength
Reflects the sky and reflection probes at grazing angles. Off: the horizon colour only, which is much cheaper on older GPUs.
Receive Shadows
Shadows from objects fall onto the water.

Foam and shore waves

Foam Noise / Foam Color / Tiling / Speed
The noise that breaks up all foam, its colour (alpha = strength), repeats per meter and scroll speed.
Intersection Foam
A foam line where objects and the shore touch the water. Width: water depth (m) over which it fades out. Softness: how soft its edge is.
Surface Foam
Foam patches on open water. Amount everywhere, plus Crest foam on wave tops.
Shore Waves
Foam bands rolling toward the shore: Band Count, Band Speed, Band Width and Range (the water depth where they start). They follow the water depth, so keep them off on flat floors such as pools.

Refraction and caustics

Refraction / Strength
Distorts what is seen through the water. Objects in front of the water never bleed into it.
Caustics
Animated light patterns on the ground under the water: texture, Strength, Tiling, Speed, and Max Depth (m) where they fade out.

Shallow Water Damping

Waves are the same height everywhere, but in shallow water that looks wrong: on a flat beach the waterline follows the straight wave crests instead of the shore. With Shallow Water Damping the water's vertex shader reads the depth under every vertex from the camera depth texture and lowers the waves smoothly, from full height at Damping Depth (2 m by default) down to none at the shoreline.

  • Vertices buried just under the ground (within 2 m) count as shallow, so the triangles along the shore calm down too.
  • Objects far in front of the water, like a mast or a hill between the camera and the sea, are ignored, so they never flatten the water behind them.
  • Off-screen vertices use the nearest edge pixel, so the damping stays continuous at the screen edges.
  • It is on in every preset and costs no measurable time (measured on a OnePlus 3T with OpenGL ES 3).
Buoyancy

The CPU can't see the depth texture, so SampleHeight(position) returns undamped waves. For objects in shallow water, pass the depth: SampleHeight(position, waterDepth) applies exactly the same damping (Scripting).

Ocean Mode

  1. Make an ocean mesh Create Water Mesh with Ocean Ring on. The demo uses Size 120, Resolution 160 (0.75 m quads) and Outer Size 4000.
  2. Turn on Ocean Mode on its Water Surface, and set Follow Camera if it isn't Camera.main.
  3. Fit the wave fade Set Wave Fade End inside the fine grid: less than half its size minus half a quad (59.6 m for the demo mesh). The long ring quads can't carry wave shapes. The Water Surface inspector warns when the fade reaches past the grid.

The water follows the camera in play mode, snapped to the quad size, and because waves and textures use world coordinates the movement is invisible. Fog is computed per pixel, so it stays correct on the kilometre-long ring triangles.

Quality tiers

A tier is a set of features. WaterQuality.Apply sets one on a material: it switches the costly features and caps the wave count, but never touches artistic choices (waves on or off, intersection foam, shore waves, damping). The cap only lowers the count: a 4-wave material set to Low keeps 2 waves when you switch it back to High, so set the count again (or undo) if you want them back:

Waves maxRefractionCausticsSurface foamReflectionsReceived shadows
Low2offoffoffoffoff
Medium3onoffononoff
High4ononononon

Tiers are chosen per material in the Editor, and features no material uses are stripped from builds. To change quality at runtime, swap between materials of different tiers, as the demo's Quality buttons do. Don't switch feature keywords at runtime: a build may not contain that variant.

Performance

Measured with the water covering about 85% of the screen, at native resolution, with a 60 fps cap:

DeviceAPILowMediumHigh
Pixel 7 Pro (3120×1440)Vulkan60 fps60 fps60 fps
OnePlus 3T, 2016 (1920×1080)OpenGL ES 356 fps sustained; ~46 once the phone is hot37 fps34 fps

On older phones the biggest single cost is Environment Reflections; Low turns them off. The water's cost scales with the screen area it covers, so a Render Scale below 1 in your URP asset helps a lot on old GPUs.

Scripting

Everything is in the HardArtcore.ShoreLine namespace.

Buoyancy.cs
using HardArtcore.ShoreLine;
using UnityEngine;

public class Buoyancy : MonoBehaviour
{
    public WaterSurface water;
    // Seabed and terrain layers only: not this object's layer, not the water's.
    public LayerMask groundMask;

    void FixedUpdate()
    {
        // The same Gerstner waves the shader draws, at this XZ position.
        float waterY = water.SampleHeight(transform.position);

        // With Shallow Water Damping, pass the depth under the point: from the water's rest height
        // (not the wave height) down to the ground, like the shader measures it.
        if (Physics.Raycast(transform.position + Vector3.up * 50f, Vector3.down, out var hit, 200f,
                            groundMask, QueryTriggerInteraction.Ignore))
            waterY = water.SampleHeight(transform.position, water.transform.position.y - hit.point.y);

        var p = transform.position;
        transform.position = new Vector3(p.x, waterY, p.z);
    }
}
SampleHeight(Vector3 position)
World height of the water above position (its Y is ignored). Includes the horizontal motion of the waves. Ignores the distance fade, damping and Surface Effects (those are GPU only). Exact for mixed waves; when all the steepness points one way at the maximum, the crest is a sharp point and the result can be a few centimeters off there.
SampleHeight(Vector3 position, float waterDepth)
The same, with Shallow Water Damping applied for water waterDepth meters deep, when the material uses it. Measure the depth from the water's rest height. The shader reads it from the camera depth texture, so over steep slopes or under overhangs a vertical raycast can differ slightly.
WaterSurface.Active
Every enabled Water Surface.
RefreshWaveCache()
Call after changing the water material's waves from code at runtime; inspector edits are picked up automatically.
OceanMode, FollowCamera
The inspector fields, settable from code.
WaterSurface.ShaderTime
The clock the shader animates with (Time.time in play mode). Use it for your own wave math.
GerstnerWaves
The CPU wave math: Offset, SampleHeight, MaxAmplitude and ShallowWaterDamping, matching the shader exactly.
WaterQuality.Apply(material, tier)
Applies a tier to a material, in the Editor or on material copies.
WaterMeshBuilder.BuildGrid / BuildOcean
The meshes the Create Water Mesh window makes, from code.

Surface Effects

Surface Effects let scripts draw into the water: ripples, wakes, rain, foam trails. A top-down buffer around the camera holds a height offset, a normal tilt and foam, and the water shader adds them on top of its waves. It costs nothing until something draws into it.

Wake.cs
using HardArtcore.ShoreLine;
using UnityEngine;
using UnityEngine.Rendering;

[ExecuteAlways]
public class Wake : WaterEffectSource
{
    public Mesh quad;
    public Material wakeMaterial;   // a shader built on HAW_SurfaceEffectsSource.hlsl
    readonly MaterialPropertyBlock props = new MaterialPropertyBlock();

    public override void Draw(RasterCommandBuffer cmd, in SurfaceEffectsContext context)
    {
        if (!context.WorldRect.Contains(new Vector2(transform.position.x, transform.position.z))) return;
        cmd.DrawMesh(quad, transform.localToWorldMatrix, wakeMaterial, 0, 0, props);
    }
}
Contract

Source shaders include Shaders/Includes/HAW_SurfaceEffectsSource.hlsl, place vertices with HAW_WorldToEffectsClip, use Blend One One with BlendOp Add, Max, and output (height m, -dh/dx, -dh/dz, foam 0..1): RGB is summed across sources, alpha takes the maximum. Pass per-draw values with a MaterialPropertyBlock. If you override OnEnable or OnDisable, call the base methods, or the source never registers.

SurfaceEffectsContext gives the camera, the buffer's WorldRect (skip draws outside it), TexelSize and Resolution. On a device that can't blend into half-float render targets the effects switch off with one warning in the log, and the water keeps working.

Your own water shaders

The shader's logic lives in include files under Shaders/Includes that take their inputs as parameters, so your own shaders can reuse them: HAW_Depth (depth reconstruction for perspective and orthographic cameras, and the vertex-stage water depth), HAW_Waves (Gerstner offset, normal and damping), HAW_Foam, HAW_Lighting, HAW_Refraction, HAW_Caustics and HAW_SurfaceEffects. HAW_Version.hlsl defines HAW_CORE_VERSION.

The package also maintains the scripting defines HAW_SHORELINE and HAW_SHORELINE_1_0, so your assemblies can check for it with defineConstraints. They are removed again if you delete the package folder.

Architecture

AssemblyContents
HardArtcore.ShoreLineWaterSurface, GerstnerWaves, WaterMeshBuilder, WaterQuality, ShoreLineFeature, Surface Effects
HardArtcore.ShoreLine.EditorMaterial inspector, renderer setup check, Create Water Mesh window, Water Surface inspector, scripting defines
Assets/HardArtcore/ShoreLine/
├── Documentation.html          this documentation
├── Runtime/                    WaterSurface, GerstnerWaves, WaterMeshBuilder, WaterQuality
│   └── Effects/                ShoreLineFeature, WaterEffects, WaterEffectSource
├── Editor/                     inspectors, setup check, Create Water Mesh window
├── Shaders/                    ShoreLine.shader
│   └── Includes/               HAW_*.hlsl, reusable in your own shaders
├── Materials/Presets/          the presets and the Low/Medium/High defaults
├── Textures/                   normal map, foam noise, caustics
└── Demo/                       demo scene, its materials, meshes and two scripts (deletable)

Troubleshooting

The water is one flat colour, with no foam
The renderer is missing the ShoreLine Feature, or the camera has no depth texture. Select the water material and click the Fix button.
Waves don't move the surface
The mesh has too few vertices. Make one with Create Water Mesh.
Water disappears at the screen edges
Add a Water Surface: it grows the renderer bounds to fit the waves.
Waves look broken far away in Ocean Mode
Wave Fade End is past the fine grid; the Water Surface inspector shows the largest value that fits.
Floating objects bob in shallow water
Use SampleHeight(position, waterDepth) so buoyancy gets the same damping as the visible water.
Shore waves pulse across a pool
Shore waves follow the water depth; on a flat floor every point has the same depth. Turn them off for pools (as the Pool preset does).
A feature looks missing in a build
Features switched on from code at runtime may have been stripped. Use a material that has the feature on.

Third-party notices

None: the package contains no third-party code, fonts, textures or models.

Release notes

1.0.0

  • First release: depth colour, intersection and surface foam, shore waves, Gerstner waves with Shallow Water Damping, refraction, caustics, reflections and received shadows; Ocean Mode; three quality tiers; CPU height queries; Surface Effects; five presets and a touch demo.

Need help?

Questions, bug reports or feature requests: I usually reply within a day.

support@hardartcore.com

Last updated November 19, 2026.