# Simplex noise algorithm always returns 0 noise at x = 0

This topic is 1057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am using a Simplex noise algorithm to generate noise, both in 1D and 2D. The problem is that for both dimensions the noise value is always 0 for x=0 (or for x=0, y=0 in the 2D case).

Can I modify the algorithm to give random values at 0 also?

Here is the code:

public static float Generate1D(float x, float? noiseFrequency = null)
{
if (noiseFrequency.HasValue)
{
x *= noiseFrequency.Value;
}

int i0 = FastFloor(x);
int i1 = i0 + 1;
float x0 = x - i0;
float x1 = x0 - 1.0f;

float n0, n1;

float t0 = 1.0f - x0 * x0;
t0 *= t0;
n0 = t0 * t0 * grad(SeedNumbers[i0 & 0xff], x0);

float t1 = 1.0f - x1 * x1;
t1 *= t1;
n1 = t1 * t1 * grad(SeedNumbers[i1 & 0xff], x1);
// The maximum value of this noise is 8*(3/4)^4 = 2.53125
// A factor of 0.395 scales to fit exactly within [-1,1]
float result = 0.395f * (n0 + n1);

return result;
}

Edited by captain_crunch

##### Share on other sites

Did not know about lattice points before. They are certainly not useful in my application, but at least I have a workaround.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634150
• Total Posts
3015801
×