WaterRW

November 2, 2025 ยท View on GitHub

WaterRW is 2D interactive water system for Unity.

image

๐Ÿ“œ Table of Contents

๐Ÿ”ฅ Installation

Requirements

  • Unity 2022.3 or later
  • Compute shader compatible platform
  • Universal Render Pipeline enabled
    • 2D Renderer is also required to enable reflection and refraction.

Install via UPM git dependency

Add git URL from Package Manager:

https://github.com/ruccho/WaterRW.git?path=/Packages/com.ruccho.water-rw

๐Ÿ‘‰ Quick Start

1. Import Prefabs and Materials

  • Import Prefabs & Samples from Samples page in Package Manager.

2. Place a prefab

  • Place Prefab/Water-RW (Compute).prefab to the scene.

3. Enable reflection and refraction (optional)

โ˜‘๏ธ Material Settings Guide

WaterRW uses the shader Water-RW/With Compute.

PropertyType
TintColor Tint color.
Pixel SnapFloat Same as one in Sprites-Default shader.
Normal ATexture2DNormal map A. Use tiling properties to scale a map.
Normal A IntensityFloat Amount of distortion of normal map A.
Normal A SpeedVector Scroll speed of normal map A. Only X and Y works.
Normal BTexture2DSame as normal A.
Normal B IntensityFloat Same as normal A.
Normal B SpeedVector Same as normal A.
Background BlendFloat Rate of reflection blend.
TransparencyFloat Dark reflection areas goes transparent.
MultiplierColor Color multiplier.
AddendColor Color addend.
Wave Size in Viewport SpaceFloat Horizontal size of near-surface distortion.
Wave Distance in Viewport SpaceFloat Vertical size of near-surface distortion.
Wave Frequency by PositionFloat Frequency of sin curve used for near-surface distortion by vertical position.
Wave Frequency by TimeFloat Frequency of sin curve used for near-surface distortion by vertical time.
Surface ColorColor Color of surface line.
Surface Width in PixelColor Width of surface line in pixels.
Fade Distance in Viewport SpaceFloat Vertical size of fade to avoid display reflection areas out of Camera Sorting Layer Texture.
Smooth Buffer Edge in World SpaceFloat Size of smoothing area in world space at the edge of wave buffer.
Reflection IntensityFloatIntensity of reflection.
Enable LightingboolEnables Light2D integration (experimental).

๐Ÿ„ Enable Interactions

WaterRW supports rough interation with rigidbodies. (Colliders with complex shapes may not be handled correctly!)

In inspector of WaterRWCompute script, select layers to interact with in Layers To Interact With property.

WaterRWCompute Settings

image

PropertyType
Mesh segments Per Unitfloat Numbers of mesh divisions per unit.
Update ModeFixedUpdate / UpdateTiming to calculate wave. Use FixedUpdate to work interactions correctly.
Override Fixed Time StepboolDetermine whether to use custom timestep.
Fixed Time StepfloatCustom time step.
Cfloat The constant used in wave calculation. Increasing this will increase the speed of the waves.
Decayfloat Coefficient for damping waves.
Enable Interactionfloat Determine whether to use interaction.
Layers To Interact WithLayerMaskLayers to interact with.
Spatial Scalefloat Horizontal scale used in wave calculation.
Max Interaction Itemsfloat Max number of rigidbodies to interact with.
Wave Buffer Pixels Per Unitfloat Resolution of buffers used to wave calculation.
Scroll To Main Camerabool Track the range of the wave calculation to the position of the main camera.
Flow Velocityfloat Velocity of the flow.
Max Surface widthfloat Max width of the wave in world scale.

Avoid Divergence

Values of Fixed Time Step, C, Spatial Scale and Wave Buffer Pixels Per Unit may cause divergence.

To avoid divergence, keep: 0 โ‰ค (C * dt / dx) โ‰ค 1.

dt = time step (Fixed Time Step when Override Fixed Time Step is true, otherwise Time.deltaTime or Time.fixedDeltaTime is used)

dx = Spatial Scale / Wave Buffer Pixels Per Unit

Buffer Scrolling

Although the size of the buffer used for wave calculation is finite, interaction with the seemingly infinite surface of the water can be achieved by making the wave calculation range follow the camera position. If Scroll To Main Camera is true, it will automatically follow Camera.main. To set it manually, set the X coordinate to float WaterRWCompute.WavePosition.