Question by
DevedGames · Mar 11, 2017 at 09:25 PM ·
sphereplanetnoise
Perlin Noise is Really Sharp
Hey my noised CubeSphere is really edgy after noising it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshDeform : MonoBehaviour {
public float scale = 1f;
private Vector3[] baseVertices;
public bool recalculateNormals;
public void Start(){
Mesh mesh = GetComponent<MeshFilter>().mesh;
if (baseVertices == null)
baseVertices = mesh.vertices;
var vertices = new Vector3[baseVertices.Length];
for (var i=0;i<vertices.Length;i++)
{
var vertex = baseVertices[i];
vertex.x += (Mathf.PerlinNoise(vertex.x, vertex.y) + Mathf.PerlinNoise(vertex.y, vertex.z) + Mathf.PerlinNoise(vertex.z, vertex.x)) * scale;
vertex.y += (Mathf.PerlinNoise(vertex.x, vertex.y) + Mathf.PerlinNoise(vertex.y, vertex.z) + Mathf.PerlinNoise(vertex.z, vertex.x)) * scale;
vertex.z += (Mathf.PerlinNoise(vertex.x, vertex.y) + Mathf.PerlinNoise(vertex.y, vertex.z) + Mathf.PerlinNoise(vertex.z, vertex.x)) * scale;
vertices[i] = vertex;
}
mesh.vertices = vertices;
if (recalculateNormals)
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
}
maybe someone can tell me what i did wrong, would be very nice :D
Comment
Answer by DevedGames · Mar 12, 2017 at 04:51 PM
and i want it look like a planetary surface
unbenannt.png
(247.6 kB)