mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 02:59:06 +00:00
Noise fix
This commit is contained in:
@@ -13,7 +13,7 @@ public class CellHeightNoise implements NoiseGenerator {
|
||||
}
|
||||
|
||||
private double filter(double noise) {
|
||||
return M.clip((noise / 2D) + 0.5D, 0D, 1D);
|
||||
return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
29
src/main/java/com/volmit/iris/noise/Research.java
Normal file
29
src/main/java/com/volmit/iris/noise/Research.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.object.NoiseStyle;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class Research {
|
||||
|
||||
public static void main(String[] args) {
|
||||
CNG cng = NoiseStyle.VIGOCTAVE_SIMPLEX.create(new RNG(RNG.r.nextLong()));
|
||||
|
||||
double max = -1;
|
||||
double min = 2;
|
||||
|
||||
for (int i = 0; i < 999999; i++) {
|
||||
double n = cng.noise(i, i * 2, i * 4);
|
||||
|
||||
if (n < min) {
|
||||
min = n;
|
||||
}
|
||||
|
||||
if (n > max) {
|
||||
max = n;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(min + " - " + max);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,11 @@ package com.volmit.iris.noise;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class SimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final SNG n;
|
||||
private final FastNoise n;
|
||||
private int octaves;
|
||||
|
||||
public SimplexNoise(long seed) {
|
||||
this.n = new SNG(new RNG(seed));
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
octaves = 1;
|
||||
}
|
||||
|
||||
@@ -18,26 +18,55 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.noise(x));
|
||||
return f(n.GetNoise((float) x, 0f));
|
||||
}
|
||||
|
||||
return f(n.noise(x, octaves, 1D, 1D, false));
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
v += n.GetNoise((float) (x * (f == 1 ? f++ : (f *= 2))), 0f) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.noise(x, z));
|
||||
return f(n.GetNoise((float) x, (float) z));
|
||||
}
|
||||
return f(n.noise(x, z, octaves, 1D, 1D, true));
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
f = f == 1 ? f + 1 : f * 2;
|
||||
v += n.GetNoise((float) (x * f), (float) (z * f)) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
if (octaves <= 1) {
|
||||
return f(n.noise(x, y, z));
|
||||
return f(n.GetNoise((float) x, (float) y, (float) z));
|
||||
}
|
||||
return f(n.noise(x, y, z, octaves, 1D, 1D, true));
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
f = f == 1 ? f + 1 : f * 2;
|
||||
v += n.GetNoise((float) (x * f), (float) (y * f), (float) (z * f)) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ public class VascularNoise implements NoiseGenerator {
|
||||
}
|
||||
|
||||
private double filter(double noise) {
|
||||
return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D);
|
||||
return M.clip((noise / 2D) + 0.5D, 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user