fix niveaux
This commit is contained in:
@@ -109,11 +109,32 @@ public class NoiseGenerator {
|
||||
return value / initialSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Noise 1D avec nombre d'octaves controle.
|
||||
* 1 octave = lisse, utilise tout le range [-1, 1].
|
||||
* Plus d'octaves = plus de detail/jitter, mais converge vers 0.
|
||||
*/
|
||||
public double noise(double x, int octaves) {
|
||||
double value = 0.0;
|
||||
double size = default_size;
|
||||
double weightSum = 0;
|
||||
int count = 0;
|
||||
|
||||
while (size >= 1 && count < octaves) {
|
||||
value += smoothNoise((x / size), (x / size), (x / size)) * size;
|
||||
weightSum += size;
|
||||
size /= 2.0;
|
||||
count++;
|
||||
}
|
||||
|
||||
return value / weightSum;
|
||||
}
|
||||
|
||||
public double smoothNoise(double x, double y, double z) {
|
||||
// Offset each coordinate by the seed value
|
||||
x += this.seed;
|
||||
y += this.seed;
|
||||
x += this.seed;
|
||||
z += this.seed;
|
||||
|
||||
int X = (int) Math.floor(x) & 255; // FIND UNIT CUBE THAT
|
||||
int Y = (int) Math.floor(y) & 255; // CONTAINS POINT.
|
||||
|
||||
Reference in New Issue
Block a user