I got a perlin noise algorithm and an opensimplex noise algorithm that returns a double based on the X and Y values given. I'm designing software and I would like to know how to:
- Scale the perlin noise with a 0-1 double value
- Allow building the perlin at different resolutions (i.e. 1024, 2048) but still maintain scale, but add additional detail.
- Allow user to change world size, which also affects the scale
My current code for this:
double scale = ((((Double) parameters.get(SCALE).getValue() * 10) + 0.25) * ProjectSettings.WORLD_SIZE) / ((double) resolution / 1000);
double x = 0;
double y = 0;
OpenSimplexNoise noise = new OpenSimplexNoise((Long) parameters.get(SEED).getValue());
for(int n = 0; n < resolution; n++) {
x += scale;
for(int m = 0; m < resolution; m++) {
y += scale;
values[n][m] = noise.generateOpenSimplexNoise(x, y, (Double) parameters.get(PERSISTENCE).getValue(), (Integer) parameters.get(OCTAVES).getValue());
}
}