Use ping-pong noise for erosion

This commit is contained in:
dfsek
2020-10-18 01:52:54 -07:00
parent 2741a761a0
commit c3d5b55dcc
3 changed files with 5 additions and 8 deletions

View File

@@ -8,11 +8,11 @@ import org.polydev.gaea.math.FastNoiseLite;
public class ErosionNoise {
private final double thresh;
private final FastNoiseLite noise;
public ErosionNoise(float freq1, double thresh, int octaves, long seed) {
public ErosionNoise(float freq1, double thresh, long seed) {
FastNoiseLite main = new FastNoiseLite((int) (seed+1));
main.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
main.setFractalType(FastNoiseLite.FractalType.FBm);
main.setFractalOctaves(octaves);
main.setFractalType(FastNoiseLite.FractalType.PingPong);
main.setFractalOctaves(1);
main.setFrequency(freq1);
this.thresh = thresh;
this.noise = main;
@@ -25,7 +25,6 @@ public class ErosionNoise {
* @return Whether location is eroded
*/
boolean isEroded(int x, int z) {
double abs = Math.pow(noise.getNoise(x, z), 2);
return abs < thresh;
return (noise.getNoise(x, z)+1)/2 <= thresh;
}
}

View File

@@ -27,7 +27,7 @@ public class TerraBiomeGrid extends BiomeGrid {
}
this.zone = zone;
if(c.erosionEnable) {
erode = new ErosionNoise(c.erosionFreq, c.erosionThresh, c.erosionOctaves, w.getSeed());
erode = new ErosionNoise(c.erosionFreq, c.erosionThresh, w.getSeed());
this.erosionGrid = erosion;
}
}

View File

@@ -60,7 +60,6 @@ public class ConfigPack extends YamlConfiguration {
public final float erosionFreq;
public final double erosionThresh;
public final int erosionOctaves;
public final boolean erosionEnable;
public final String erosionName;
@@ -108,7 +107,6 @@ public class ConfigPack extends YamlConfiguration {
erosionEnable = getBoolean("erode.enable", false);
erosionFreq = (float) getDouble("erode.frequency", 0.01);
erosionThresh = getDouble("erode.threshold", 0.04);
erosionOctaves = getInt("erosion.octaves", 4);
octaves = getInt("noise.octaves", 4);
frequency = (float) getDouble("noise.frequency", 1f/96);