Noise updates

This commit is contained in:
Daniel Mills 2020-01-26 21:53:55 -05:00
parent 1c7a7f6edf
commit b61a71b3b4
4 changed files with 44 additions and 39 deletions

View File

@ -25,13 +25,13 @@ public class Settings
public static class GeneratorSettings
{
public InterpolationMode interpolationMode = InterpolationMode.BILINEAR;
public int interpolationRadius = 64;
public int blockSmoothing = 1;
public int interpolationRadius = 6;
public double objectDensity = 1D;
public double horizontalZoom = 2;
public double heightFracture = 155;
public double landScale = 0.75;
public double landChance = 0.65;
public double landScale = 0.5;
public double landChance = 0.56;
public double roughness = 1.55;
public double biomeEdgeFuzzScale = 1;
public double biomeEdgeScrambleScale = 0.3;

View File

@ -32,6 +32,7 @@ import ninja.bytecode.iris.util.ChunkPlan;
import ninja.bytecode.iris.util.InterpolationMode;
import ninja.bytecode.iris.util.IrisInterpolation;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.NoiseProvider;
import ninja.bytecode.iris.util.ObjectMode;
import ninja.bytecode.iris.util.SChunkVector;
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
@ -198,29 +199,33 @@ public class IrisGenerator extends ParallaxWorldGenerator
return (int) Math.round(M.clip(getANoise((int) x, (int) z, plan, biome), 0D, 1D) * 253);
}
public double getInterpolation(int x, int z, ChunkPlan plan)
public double getInterpolation(int x, int z, double opacity, ChunkPlan plan)
{
PrecisionStopwatch s = getMetrics().start();
NoiseProvider n = (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan);
double d = 0;
double rad = Iris.settings.gen.interpolationRadius;
InterpolationMode m = Iris.settings.gen.interpolationMode;
if(m.equals(InterpolationMode.BILINEAR))
{
d = IrisInterpolation.getBilinearNoise(x, z, Iris.settings.gen.interpolationRadius, (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
d = IrisInterpolation.getBilinearNoise(x, z, rad, n);
}
else if(m.equals(InterpolationMode.BICUBIC))
{
d = IrisInterpolation.getBicubicNoise(x, z, Iris.settings.gen.interpolationRadius, (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
d = IrisInterpolation.getBicubicNoise(x, z, rad, n);
}
else if(m.equals(InterpolationMode.HERMITE_BICUBIC))
{
d = IrisInterpolation.getHermiteNoise(x, z, Iris.settings.gen.interpolationRadius, (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
d = IrisInterpolation.getHermiteNoise(x, z, rad, n);
}
else
{
d = getBiomedHeight((int) Math.round(x), (int) Math.round(z), plan);
d = n.noise(x, z);
}
getMetrics().stop("interpolation:ms:x256:/biome:.", s);
@ -230,7 +235,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
public double getANoise(int x, int z, ChunkPlan plan, IrisBiome biome)
{
double hv = getInterpolation(x, z, plan);
double hv = getInterpolation((int) x, (int) z, 1D, plan);
hv += glLNoise.generateLayer(hv * Iris.settings.gen.roughness * 215, (double) x * Iris.settings.gen.roughness * 0.82, (double) z * Iris.settings.gen.roughness * 0.82) * (1.6918 * (hv * 2.35));
if(biome.hasCliffs())

View File

@ -15,7 +15,7 @@ public class BiomeNoiseGenerator
this.biome = biome;
//@builder
gen = new CNG(rng.nextParallelRNG(31289 - biome.getName().length() * biome.getRealBiome().ordinal()), 1D, 1)
.scale(0.0075 * biome.getGenScale())
.scale(0.0025 * biome.getGenScale())
.fractureWith(new CNG(rng.nextParallelRNG(2922 * biome.getName().length() - biome.getRealBiome().ordinal()), 1D, 1)
.scale(0.0075 * biome.getGenSwirlScale()), 20D * biome.getGenSwirl());
//@done

View File

@ -112,14 +112,14 @@ public class IrisInterpolation
return cubic(cubic(p00, p01, p02, p03, muy), cubic(p10, p11, p12, p13, muy), cubic(p20, p21, p22, p23, muy), cubic(p30, p31, p32, p33, muy), mux);
}
public static double getBilinearNoise(int x, int z, int rad, NoiseProvider n)
public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n)
{
int fx = x >> rad;
int fz = z >> rad;
int x1 = (fx << rad);
int z1 = (fz << rad);
int x2 = ((fx + 1) << rad);
int z2 = ((fz + 1) << rad);
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
double px = M.rangeScale(0, 1, x1, x2, x);
double pz = M.rangeScale(0, 1, z1, z2, z);
//@builder
@ -132,18 +132,18 @@ public class IrisInterpolation
//@done
}
public static double getBicubicNoise(int x, int z, int rad, NoiseProvider n)
public static double getBicubicNoise(int x, int z, double rad, NoiseProvider n)
{
int fx = x >> rad;
int fz = z >> rad;
int x0 = ((fx - 1) << rad);
int z0 = ((fz - 1) << rad);
int x1 = (fx << rad);
int z1 = (fz << rad);
int x2 = ((fx + 1) << rad);
int z2 = ((fz + 1) << rad);
int x3 = ((fx + 2) << rad);
int z3 = ((fz + 2) << rad);
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = M.rangeScale(0, 1, x1, x2, x);
double pz = M.rangeScale(0, 1, z1, z2, z);
//@builder
@ -168,18 +168,18 @@ public class IrisInterpolation
//@done
}
public static double getHermiteNoise(int x, int z, int rad, NoiseProvider n)
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n)
{
int fx = x >> rad;
int fz = z >> rad;
int x0 = ((fx - 1) << rad);
int z0 = ((fz - 1) << rad);
int x1 = (fx << rad);
int z1 = (fz << rad);
int x2 = ((fx + 1) << rad);
int z2 = ((fz + 1) << rad);
int x3 = ((fx + 2) << rad);
int z3 = ((fz + 2) << rad);
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = M.rangeScale(0, 1, x1, x2, x);
double pz = M.rangeScale(0, 1, z1, z2, z);
//@builder