Perlin Noise Spherical Terrain

So, I’m trying to figure out my own way of doing Procedural Planetary terrain a bit of a time. I can spherify a cube just fine, but when I try to implement some Perlin Noise, it usually ends up as a spike ball and shrinks. Here is my code:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PerlinHeightSingle: MonoBehaviour {
	public float radius = 20;
	public int size = 10;
	public GameObject cube;
	public float scale = 6.5f;
	public float power = 3;
	private Vector2 v2SampleStart = new Vector2(0, 0);

	void Start(){

			Mesh mesh = transform.GetComponent<MeshFilter>().mesh;
			Vector3[] vertices = mesh.vertices;
			
			for(int i = 0; i < vertices.Length; i++){
				vertices <em>= vertices_.normalized * radius;_</em>

* }*

* mesh.vertices = vertices;*
* mesh.RecalculateNormals();*
* mesh.RecalculateBounds();*

* SetHeights();*
* }*

* void Update(){*
* if(Input.GetKeyUp(KeyCode.Space)){*
* v2SampleStart = new Vector2(Random.Range(0, 100), Random.Range(0, 100));*
* SetHeights();*
* }*
* }*

* void SetHeights(){*
* Mesh mesh = transform.GetComponent().mesh;*
* Vector3[] vertices = mesh.vertices;*
* for (int i = 0; i < vertices.Length; i++) {*
float xCoord = v2SampleStart.x + vertices_.x * scale;
float yCoord = v2SampleStart.y + vertices.z * scale;
vertices = vertices * Mathf.PerlinNoise (xCoord, yCoord);
* }
mesh.vertices = vertices;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
}
}*_

I created something like this a while back. Take a look, the source is available. link text

here is some relevant code too

using UnityEngine;
using System.Collections;
using LibNoise.Unity;
using LibNoise.Unity.Generator;
using LibNoise.Unity.Operator;

public class Normalize : MonoBehaviour {


	private Mesh gameMesh;
	Vector3[] vertices;
	Vector3[] verticesN;
	public float radius = 1f;
	public RidgedMultifractal noise = new RidgedMultifractal();
	public float frequency = 10f;
	public float noisemod = 1f;
	private MeshCollider meshCollider;


	void Start () {
		gameMesh = GetComponent<MeshFilter>().mesh;
		meshCollider = GetComponent<MeshCollider>();
		Vector3[] vertices = gameMesh.vertices;
		Vector3[] verticesN = gameMesh.vertices;
		noise.Frequency = frequency;
		
		
		for (int i = 0; i < vertices.Length; i++) 
		{
			verticesN <em>= (vertices<em>.normalized * (radius + (float)noise.GetValue(verticesN_.normalized)*noisemod));_</em></em>

* }*
* gameMesh.vertices = verticesN;*
* gameMesh.RecalculateNormals();*
* gameMesh.RecalculateBounds();*
* meshCollider.sharedMesh = gameMesh;*
* }*

First of all, Unity’s Mathf.PerlinNoise function is honestly not that useful, as you have no access to any of the parameters, setting the seed, etc…

In regards to your issue, my first check would be on the xCoord and yCoord values. Generally speaking, noise functions don’t play well with whole numbers, and do much better with decimals. As a test add something random like 0.0654f to each of those, and see if it does the trick, or at least improves it a bit. If so, then the next step would be to create your own noise functions so that you have finer grain control on what’s going on.