Reputation: 41
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:
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());
}
}
Upvotes: 0
Views: 1126
Reputation: 99
If you want to change resolution of the Perlin noise image, change height and with values in your for loops. In order to scale, you have to multiply first and/or second arguments of Perlin noise method by some variable that changes when you need to scale. Time value may be well suited for this. See code example below.
time += 0.01;
// Change height and width values to change resolution
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
double dx = (double) x / MainWindow.height;
double dy = (double) y / MainWindow.height;
// Perlin noise method call
// In order to scale, you have to multiply current values
// by time or other variable, which change would cause the zoom.
double noise = noise(dx * time, dy * time);
}
}
Upvotes: -2