Hello! I’m using 3D Perlin Noise to generate a planet and I’m having an issue.
Problem is that the planet’s vertices aren’t moving outwards evenly, they seem to be moving sort of where all three axes meet.
Here’s an image:
[22070screen+shot+20140212+at+14.10.40.png22070]
The images on the left and right are either end, basically where x,y and z are all even, and the middle one shows how it looks stretched and isn’t working evenly all round the mesh.
Here’s the function I’m using:
void GenerateMesh()
{
perlin = new Perlin();
fractal = new FractalNoise(h, lacunarity, octaves, perlin);
Mesh mesh = GetComponent<MeshFilter>().mesh;
baseVertices = mesh.vertices;
Vector3[] vertices = new Vector3[baseVertices.Length];
for(int i=0;i<vertices.Length;i++)
{
Vector3 vertex = baseVertices*;*

// Normalise the cube to make a quadsphere*

vertex = vertex.normalized ;*

float fractalNoise = fractal.RidgedMultifractal3 (vertex.x, vertex.y, vertex.z, offset, gain);*
_ fractalNoise = fractalNoise * scale;_

vertex.x += fractalNoise;*

vertex.y += fractalNoise;*

vertex.z += fractalNoise;*
_ vertices = vertex;_
* }*
* mesh.vertices = vertices;*
* if (recalculateNormals)*
* mesh.RecalculateNormals(); *
* mesh.RecalculateBounds();*
* }*
Which calls this Ridged Multifractal function which I modified from the Unity Procedural Demos program to work for 3D. This might be what I’ve done wrong, I’m not sure.
* public float RidgedMultifractal3 (float x, float y, float z, float offset, float gain)*
* {*
* float weight, signal, result;*
* int i;*
* signal = Mathf.Abs (m_Noise.Noise (x, y, z));
_ signal = offset  signal;_
_ signal = signal;_
_ result = signal;_
* weight = 1.0F;*
* for (i=1;i<m_IntOctaves;i++)
_ {*_
x *= m_Lacunarity;
y *= m_Lacunarity;
z *= m_Lacunarity;
_ weight = signal * gain;_
* weight = Mathf.Clamp01 (weight);*
* signal = Mathf.Abs (m_Noise.Noise (x, y, z));
_ signal = offset  signal;_
_ signal = signal;
signal = weight;_
result += signal * m_Exponent;
_ }*_
* return result;*
* }*
Does anyone know where I’m going wrong?
Thank you!