fix niveaux

This commit is contained in:
MOISOIU Stefan-Mihai
2026-03-16 16:47:27 +01:00
parent 3dd0408323
commit 7639df7abd
3 changed files with 28 additions and 7 deletions

View File

@@ -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.