So I’ve been working on a project that creates a sea of cubes by layering different perlin noises. The cubes find their position on the perlin noise “texture” and their height is set to a value between -1 and +1. That value is determined by the color of the perlin noise. How would I apply this to a planes mesh; where the vertices of the mesh act like the cubes do? Here is my code ( which you’re welcome to try out ) Hopefully it’s not too long.

```
var cubeAmountX : int = 50;
var cubeAmountZ : int = 50;
var seed : int = 0.0;
var seed2 : int = 0.0;
var cube : GameObject;
var colorSetsScale : boolean;
var heightSetsScale : boolean;
var sizeDivider : float = 2.0;
var animateColor : boolean;
var roundHeightToInt : boolean;
var noiseScale : float = 6.5;
var noiseScale2 : float = 6.5;
var cubeHeight : float = 3;
var cubeHeight2 : float = 3;
var animateSpeed : float = 0.5;
var animateSpeed2 : float = 1.0;
private var finalHeight : float;
function Start ()
{
for (var spawnPositionX = 0; spawnPositionX < cubeAmountX; spawnPositionX++)
{
for (var spawnPositionZ = 0; spawnPositionZ < cubeAmountZ; spawnPositionZ++)
{
var makeCube = Instantiate(cube, Vector3(spawnPositionX,0,spawnPositionZ), Quaternion.identity);
makeCube.transform.parent = this.transform;
}
}
for (var child : Transform in this.transform)
{
if (noiseScale <= 0.001)
{
noiseScale = 0.0011;
}
var height = Mathf.PerlinNoise(child.transform.position.x/noiseScale + (seed * 10), child.transform.position.z/noiseScale + (seed * 10));
var height2 = Mathf.PerlinNoise(child.transform.position.x/noiseScale2 + (seed2 * -10), child.transform.position.z/noiseScale2 + (seed2 * -10));
height *= cubeHeight;
height2 *= cubeHeight2;
finalHeight = height + height2;
if (animateColor)
{
child.renderer.material.color = Color(finalHeight,finalHeight,finalHeight,finalHeight);
}
if (colorSetsScale)
{
if (sizeDivider <= 0.0)
{
sizeDivider = 0.001;
}
child.transform.localScale = Vector3 (finalHeight,finalHeight,finalHeight);
}
}
}
function Update ()
{
for (var child : Transform in this.transform)
{
var height = Mathf.PerlinNoise(child.transform.position.x/noiseScale, child.transform.position.z/noiseScale);
var height2 = Mathf.PerlinNoise(child.transform.position.x/noiseScale2 + (seed2 * -10), child.transform.position.z/noiseScale2 + (seed2 * -10));
height *= cubeHeight;
height2 *= cubeHeight2;
var finalHeight = height + height2;
if (animateColor)
{
child.renderer.material.color = Color(finalHeight,finalHeight,finalHeight,finalHeight);
}
}
for (var child : Transform in this.transform)
{
height = Mathf.PerlinNoise(Time.time * animateSpeed + (child.transform.position.x/noiseScale) + (seed * 10), Time.time * animateSpeed + (child.transform.position.z/noiseScale) + (seed * 10));
height2 = Mathf.PerlinNoise(Time.time * animateSpeed2 + child.transform.position.x/noiseScale2 + (seed2 * -10),Time.time * animateSpeed2 + child.transform.position.z/noiseScale2 + (seed2 * -10));
height *= cubeHeight;
height2 *= cubeHeight2;
finalHeight = height + height2;
if (!roundHeightToInt)
{
child.transform.position.y = finalHeight + transform.position.y;
}
else if (roundHeightToInt)
{
child.transform.position.y = Mathf.RoundToInt(finalHeight * cubeHeight + transform.position.y);
}
if (animateColor)
{
child.renderer.material.color = Color(finalHeight,finalHeight,finalHeight,finalHeight);
}
if (colorSetsScale)
{
if (sizeDivider <= 0.0)
{
sizeDivider = 1;
}
child.transform.localScale = Vector3 (finalHeight,finalHeight,finalHeight);
heightSetsScale = false;
}
if (heightSetsScale)
{
if (sizeDivider <= 0.0)
{
sizeDivider = 1;
}
var cubeHeight : float = child.transform.localPosition.y;
child.transform.localScale = Vector3 (cubeHeight/sizeDivider, cubeHeight/sizeDivider, cubeHeight/sizeDivider);
colorSetsScale = false;
}
if (!heightSetsScale && !colorSetsScale)
{
child.transform.localScale = Vector3 (1,1,1);
}
}
}
```