Unity includes several water Prefabs (including the necessary Shaders, scripts and art Assets) within the Standard Assets packages. Separate daylight and nighttime water Prefabs are provided.
Note that the water reflections described in this document do not work in VR.
Setting up water
Place one of the existing water Prefabs into your Scene. Make sure you have the Standard Assets installed:
Simple Daylight Simple Water and Nighttime Simple Water in Standard Assets > Water.
Fancier water - Daylight Water and Nighttime Water in Pro Standard Assets > Water (this needs some Assets from Standard Assets > Water as well). Water mode (Simple, Reflective, Refractive) can be set in the Inspector.
The Prefab uses an oval-shaped Mesh for the water. If you need to use a different Mesh, change it in the Mesh Filter of the water GameObject:
Creating water from scratch (Advanced)
Simple water requires attaching a script to a plane-like mesh and using the water shader:
Have mesh for the water. This should be a flat mesh, oriented horizontally. UV coordinates are not required. The water GameObject should use the Water Layer, which you can set in the Inspector.
Attach the WaterSimple script (from Standard Assets/Water/Sources) to the GameObject.
Use the FX/Water (simple) Shader in the Material, or tweak one of the provided water Materials (Daylight Simple Water or Nighttime Simple Water).
Reflective/refractive water requires similar steps to set up from scratch:
Create a Mesh for the water. This should be a flat Mesh, oriented horizontally. UV coordinates are not required. The water GameObject should use the water Layer, which you can set in the Inspector.
Attach the Water script (from Pro Standard Assets/Water/Sources) to the GameObject (Water rendering mode can be set in the Inspector: Simple, Reflective or Refractive.)
Use the FX/Water Shader in the Material, or tweak one of the provided water Materials (Daylight Water or Nighttime Water).
Properties in water Materials
These properties are used in the Reflective and Refractive water Shaders. Most of them are used in the Simple water Shader as well.
Property:
Function:
Wave scale
Scaling of waves normal map. The smaller the value, the larger water waves.
Reflection/refraction distort
How much reflection/refraction is distorted by the waves normal map.
Refraction color
Additional tint for refraction.
Environment reflection/refraction
Render textures for real-time reflection and refraction.
Normalmap
Defines the shape of the waves. The final waves are produced by combining these two normal maps, each scrolling at different direction, scale and speed. The second normal map is half as large as the first one.
Wave speed
Scrolling speed for first normal map (1st and 2nd numbers) and the second normal map (3rd and 4th numbers).
Fresnel
A texture with alpha channel controlling the Fresnel effect - how much reflection vs. refraction is visible, based on viewing angle.
The rest of the properties are not used by the Reflective and Refractive Shaders, but need to be set up in case the user’s video card does not support it and must fallback to the simpler shader:
Property:
Function:
Reflective color/cube and fresnel
A texture that defines water color (RGB) and Fresnel effect (A) based on viewing angle.
Horizon color
The color of the water at horizon. `this is only used in the Simple water Shader.
Fallback texture
Define the fallback Texture used to represent the water on really old video cards, if none of the better looking Shaders can run.
Did you find this page useful? Please give it a rating:
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!