mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-30 05:40:34 +00:00
Use ping-pong noise for erosion
This commit is contained in:
@@ -8,11 +8,11 @@ import org.polydev.gaea.math.FastNoiseLite;
|
|||||||
public class ErosionNoise {
|
public class ErosionNoise {
|
||||||
private final double thresh;
|
private final double thresh;
|
||||||
private final FastNoiseLite noise;
|
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));
|
FastNoiseLite main = new FastNoiseLite((int) (seed+1));
|
||||||
main.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
main.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||||
main.setFractalType(FastNoiseLite.FractalType.FBm);
|
main.setFractalType(FastNoiseLite.FractalType.PingPong);
|
||||||
main.setFractalOctaves(octaves);
|
main.setFractalOctaves(1);
|
||||||
main.setFrequency(freq1);
|
main.setFrequency(freq1);
|
||||||
this.thresh = thresh;
|
this.thresh = thresh;
|
||||||
this.noise = main;
|
this.noise = main;
|
||||||
@@ -25,7 +25,6 @@ public class ErosionNoise {
|
|||||||
* @return Whether location is eroded
|
* @return Whether location is eroded
|
||||||
*/
|
*/
|
||||||
boolean isEroded(int x, int z) {
|
boolean isEroded(int x, int z) {
|
||||||
double abs = Math.pow(noise.getNoise(x, z), 2);
|
return (noise.getNoise(x, z)+1)/2 <= thresh;
|
||||||
return abs < thresh;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class TerraBiomeGrid extends BiomeGrid {
|
|||||||
}
|
}
|
||||||
this.zone = zone;
|
this.zone = zone;
|
||||||
if(c.erosionEnable) {
|
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;
|
this.erosionGrid = erosion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public class ConfigPack extends YamlConfiguration {
|
|||||||
|
|
||||||
public final float erosionFreq;
|
public final float erosionFreq;
|
||||||
public final double erosionThresh;
|
public final double erosionThresh;
|
||||||
public final int erosionOctaves;
|
|
||||||
public final boolean erosionEnable;
|
public final boolean erosionEnable;
|
||||||
public final String erosionName;
|
public final String erosionName;
|
||||||
|
|
||||||
@@ -108,7 +107,6 @@ public class ConfigPack extends YamlConfiguration {
|
|||||||
erosionEnable = getBoolean("erode.enable", false);
|
erosionEnable = getBoolean("erode.enable", false);
|
||||||
erosionFreq = (float) getDouble("erode.frequency", 0.01);
|
erosionFreq = (float) getDouble("erode.frequency", 0.01);
|
||||||
erosionThresh = getDouble("erode.threshold", 0.04);
|
erosionThresh = getDouble("erode.threshold", 0.04);
|
||||||
erosionOctaves = getInt("erosion.octaves", 4);
|
|
||||||
|
|
||||||
octaves = getInt("noise.octaves", 4);
|
octaves = getInt("noise.octaves", 4);
|
||||||
frequency = (float) getDouble("noise.frequency", 1f/96);
|
frequency = (float) getDouble("noise.frequency", 1f/96);
|
||||||
|
|||||||
Reference in New Issue
Block a user