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:
using UnityEngine;
using System.Collections;
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<em>.y = heightScale * Mathf.PerlinNoise(Time.time + (vertices<em>.x * scale), Time.time + (vertices_.z * scale));_</em></em>
}
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?
Thanks!
plane with displacement from script:
[90045-screen-shot-2017-03-16-at-045458.png|90045]
plane with displacement baked into model:
[90046-screen-shot-2017-03-16-at-045509.png*|90046]*
*
*