Hello, I'm trying to make some low-poly water. So I have a plane and I put a script on it that I found online:
public class Water : MonoBehaviour
public float scale = 7.0f;
public float heightScale = 1.0f;
private Vector2 v2SampleStart = new Vector2(0f, 0f);
void Update ()
MeshFilter mf = GetComponent<MeshFilter>();
Vector3 vertices = mf.mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
vertices[i].y = heightScale * Mathf.PerlinNoise(Time.time + (vertices[i].x * scale), Time.time + (vertices[i].z * scale));
mf.mesh.vertices = vertices;
Ok, great. So it makes the plane wiggle and looks like water. However the changes that are made by this script do not cause the material to react to the lighting. Since the plane starts totally flat, and is uniformly lit with no shadows or specular on anything, once this script starts, the vertices move around but there's no shading at all. It's totally flat. I've confirmed the lighting/material works by exporting a plane from Cinema4D that has a little bit of displacement baked onto it, and this is affected by the lighting. However, even when I put the script on this one, the lighting doesn't change! Polygons that were lit/shadowed from the beginning retain their same exact color.
Am I missing something simple here?
plane with displacement from script:
plane with displacement baked into model:
Answer by shapirog
Mar 16 at 09:30 AM
Well I made some progress... I got it to update the shading with RecalculateNormals(); but it resets the smoothing to the default so it no longer looks flat shaded. Is there a way to have it update the normals but keep the flat-shaded look? Or would it be better to try a totally different approach to get the water to look low-poly/flat shaded?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
117 People are following this question.
How to see full Metallic shine in the shadow of directional light?
Lighting problems using tiled mesh terrain is creating edges between tiles
Create a custom quad mesh from script
Procedurally generated mesh having some faces that don't receive light
Why won't waterbasicdaytime load textures/materials