From b61a71b3b4d3aec69ab8bdaf2ce315228c75287c Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Sun, 26 Jan 2020 21:53:55 -0500 Subject: [PATCH] Noise updates --- .../java/ninja/bytecode/iris/Settings.java | 6 +- .../iris/generator/IrisGenerator.java | 17 ++++-- .../generator/layer/BiomeNoiseGenerator.java | 2 +- .../bytecode/iris/util/IrisInterpolation.java | 58 +++++++++---------- 4 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 3072e6e5c..1c8a4f08a 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -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; diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index 9e7178835..f08e66589 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -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()) diff --git a/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java b/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java index 295738ded..125617acd 100644 --- a/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java @@ -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 diff --git a/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java b/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java index a8ad5bc1c..dde503807 100644 --- a/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java +++ b/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java @@ -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