Procedural Terrain Using Perlin Noise
•
Procedural Terrain:
public class ProceduralTerrain : MonoBehaviour {
public int size = 50;
public int resolution = 512;
public float refinement = 0.01f;
public float heightScale = 0.04f;
public float sampleModifier = 0f;
void Start() {
float[,] heightData = new float[resolution, resolution];
Terrain terrain = GetComponent<Terrain>();
for (int x = 0; x < resolution; x++){
for (int y = 0; y < resolution; y++){
float noise = Mathf.PerlinNoise(
sampleModifier + (x * refinement),
sampleModifier + (y * refinement));
heightData[x, y] = noise * heightScale;
}
}