- Home /
Extrapolating float values from Perlin noise?
I've been looking about on the script reference for a good noise function and Perlin noise seems to be what I need. I'm trying to pseudo-randomly generate planet-like meshes at runtime using a sphere mesh like so:
using UnityEngine;
using System.Collections;
public class PerlinTerrain : MonoBehaviour
{
private Vector3[] vertices;
void Start ()
{
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
{
vertices[i] = vertices[i] * Random.Range(0.9f, 1.1f);
}
mesh.vertices = vertices;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
}
}
That code does what it's supposed to, although instead of using Random.Range, I'd like for vertices[i] to be multiplied by a value that's extrapolated from a Perlin noise function. How might I go about doing this? I've been looking around for sufficient documentation for so long that I actually went to the second page of Google.
"for so long that I actually went to the second page of Google" --- you're kidding, that's an exhaustive search as of today?
Answer by fherbst · Sep 08, 2013 at 11:21 PM
Maybe you have a different Google, this was in the top five: 3d perlin noise function on GPU Gems