I am using a perlin noise function to generate data for a game I am making, but for some reason it keeps returning the exact same results for different inputs. I spent like 4 hours trying to debug this on my FBM function and couldn't figure it out so I tried Ken Perlin's improved noise function and the same thing happens.
Does anyone know why this is? What is a good way to fix it? The only thing I have been able to do is add a decimal value like .6473 to the x and y coordinates, which helped, but introduced other problems such as the values repeating themselves inside the arrays.
Here is some test code. I am trying to create two different 2D arrays filled with noise values. The x and y inputs are coordinates from my game. On the lines with '**' after them, if I don't increase those values, both arrays will be filled with all zeros. In the example, the coordinates (0.0, -768.0) and (-1024.0, -768.0) return the exact same noise values. In my game, 9 different coordinates return the same values.
The Perlin Noise function I am using for this test is here
public class TestPerlinMain
{
public static void main(String[] args)
{
int seed = 532434;
//create first noise array
double x = 0.0; //x-coordinate
double y = -768.0; //y-coordinate
float z = 10.0f;
double[][] test = new double[15][15];
System.out.println("Noise Array 1: ");
for(int i = 0; i < test.length; i++)
{
for(int j = 0; j < test[i].length; j++)
{
test[i][j] = ImprovedNoise.noise(x + (j * 64.0), y + (i * 64.0), 10.0);
x += .314f;//************
System.out.print(test[i][j] + " ");
}
y += .314f;//***********
}
System.out.println();
//create 2nd noise array
double x2 = -1024.0; //x coordinate
double y2 = -768.0; //y coordinate
float z2 = 10.0f;
System.out.println();
double[][] test2 = new double[15][15];
System.out.println("Noise Array 2: ");
for(int i = 0; i < test2.length; i++)
{
for(int j = 0; j < test2[i].length; j++)
{
test2[i][j] = ImprovedNoise.noise(x2 + (j * 64.0), y2 + (i * 64.0), 10.0);
x2 += .314f;//*************
System.out.print(test2[i][j] + " ");
}
y2 += .314f;//************
}
System.out.println();
}