diff --git a/core/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java b/core/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java index 324268874..7e6fa2472 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java +++ b/core/src/main/java/com/volmit/iris/engine/object/NoiseStyle.java @@ -446,6 +446,12 @@ public enum NoiseStyle { @Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.") VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)), + + @Desc("Perplex noise = Perlin x Simplex, multiplied together.") + PERPLEX(rng -> new CNG(rng, NoiseType.PERPLEX, 1D, 1)), + + @Desc("Perplex noise with Iris wispy swirls.") + PERPLEX_IRIS(rng -> CNG.signature(rng, NoiseType.PERPLEX)), ; private final CNGFactory f; diff --git a/core/src/main/java/com/volmit/iris/util/noise/NoiseType.java b/core/src/main/java/com/volmit/iris/util/noise/NoiseType.java index 20f89ca8b..10382e778 100644 --- a/core/src/main/java/com/volmit/iris/util/noise/NoiseType.java +++ b/core/src/main/java/com/volmit/iris/util/noise/NoiseType.java @@ -28,6 +28,7 @@ public enum NoiseType { WHITE_HERMITE((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.HERMITE)), SIMPLEX(SimplexNoise::new), PERLIN(seed -> new PerlinNoise(seed).hermite()), + PERPLEX(PerplexNoise::new), FRACTAL_BILLOW_SIMPLEX(FractalBillowSimplexNoise::new), FRACTAL_BILLOW_PERLIN(FractalBillowPerlinNoise::new), FRACTAL_FBM_SIMPLEX(FractalFBMSimplexNoise::new), diff --git a/core/src/main/java/com/volmit/iris/util/noise/PerplexNoise.java b/core/src/main/java/com/volmit/iris/util/noise/PerplexNoise.java new file mode 100644 index 000000000..9fe63be62 --- /dev/null +++ b/core/src/main/java/com/volmit/iris/util/noise/PerplexNoise.java @@ -0,0 +1,52 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2022 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.noise; + +import com.volmit.iris.util.math.RNG; + +/** + * Perplex noise blends Perlin and Simplex noise by multiplying their outputs together. + * Both components are normalized to [0,1] so the product stays in [0,1]. + */ +public class PerplexNoise implements NoiseGenerator { + private final NoiseGenerator perlin; + private final SimplexNoise simplex; + + public PerplexNoise(long seed) { + PerlinNoise p = new PerlinNoise(new RNG(seed).lmax()); + p.hermite(); + this.perlin = p; + this.simplex = new SimplexNoise(new RNG(seed).lmax()); + } + + @Override + public double noise(double x) { + return perlin.noise(x) * simplex.noise(x); + } + + @Override + public double noise(double x, double z) { + return perlin.noise(x, z) * simplex.noise(x, z); + } + + @Override + public double noise(double x, double y, double z) { + return perlin.noise(x, y, z) * simplex.noise(x, y, z); + } +}