- Home /

# 3D Perlin Noise mesh even in all axes

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:

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[i];
// 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[i] = vertex;
}
mesh.vertices = vertices;
if (recalculateNormals)
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
```

Which calls this Ridged Multi-fractal 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[i];
}
return result;
}
```

Does anyone know where I'm going wrong?

Thank you!

**Answer** by robertbu
·
Feb 12, 2014 at 02:35 PM

In a quick read, I suspect lines 20 - 22 in the first script. I think you want to replace them with something like:

```
vertex *= fractalNoise;
```

Or if you want a scale value of 0 to equal unchanged:

```
vertex *= (1.0f + fractalNoise);
```

### Your answer

### Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

### Follow this Question

### Related Questions

how do i procedurally generated perlin noise infinitely c# 0 Answers

How to create a terrain in a sphere with Perlin Noise 0 Answers

How to use Perlin Noise for waves 0 Answers

Always same result from Mathf.PerlinNoise() 2 Answers

Unity Perlin Noise Bug? 3 Answers