More noise generators

This commit is contained in:
Daniel Mills 2021-07-25 11:31:39 -04:00
parent 1b85417ae6
commit 14e16c874e
8 changed files with 1264 additions and 18 deletions

View File

@ -49,7 +49,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
static JComboBox<String> combo;
@SuppressWarnings("CanBeFinal")
RollingSequence r = new RollingSequence(290);
RollingSequence r = new RollingSequence(20);
@SuppressWarnings("CanBeFinal")
boolean colorMode = true;
double scale = 1;
@ -190,7 +190,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
int finalAccuracy = accuracy;
e.queue(() -> {
for (int z = 0; z < h/finalAccuracy; z++) {
double n = generator != null ? generator.apply(((xx*finalAccuracy) * ascale) + oxp, ((z*finalAccuracy) * ascale) + ozp) : cng.noise(((xx*finalAccuracy) * ascale) + oxp, tz, ((z*finalAccuracy) * ascale) + ozp);
double n = generator != null ? generator.apply(((xx*finalAccuracy) * ascale) + oxp, ((z*finalAccuracy) * ascale) + ozp) : cng.noise(((xx*finalAccuracy) * ascale) + oxp, ((z*finalAccuracy) * ascale) + ozp);
n = n > 1 ? 1 : n < 0 ? 0 : n;
try
@ -208,7 +208,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
});
}
e.complete();
e.complete(1000);
gg.drawImage(img, 0, 0, getParent().getWidth()*accuracy, getParent().getHeight()*accuracy, (img, infoflags, x, y, width, height) -> true);
}

View File

@ -162,12 +162,13 @@ public class IrisEngine extends BlockPopulator implements Engine {
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) {
try {
PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor b = burst().burst(16);
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
// This is a very weird optimization, but it works
// Basically we precache multicore the biome stream which effectivley
// makes the biome stream, interpolation & noise engine run in parallel without mca
BurstExecutor b = burst().burst(16);
for(int i = 0; i < vblocks.getWidth(); i++)
{
int finalI = i;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.noise;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.engine.interpolation.InterpolationMethod;
import com.volmit.iris.engine.interpolation.IrisInterpolation;
import com.volmit.iris.util.function.NoiseProvider;
public class InterpolatedNoise implements NoiseGenerator {
private final InterpolationMethod method;
private final NoiseProvider p;
public InterpolatedNoise(long seed, NoiseType type, InterpolationMethod method) {
this.method = method;
NoiseGenerator g = type.create(seed);
p = g::noise;
}
@Override
public double noise(double x) {
return noise(x, 0);
}
@Override
public double noise(double x, double z) {
return IrisInterpolation.getNoise(method, (int)x, (int)z, 32, p);
}
@Override
public double noise(double x, double y, double z) {
if(z == 0)
{
return noise(x, y);
}
return IrisInterpolation.getNoise(method, (int)x, (int)z, 32, p);
}
}

View File

@ -18,8 +18,13 @@
package com.volmit.iris.engine.noise;
import com.volmit.iris.engine.interpolation.InterpolationMethod;
public enum NoiseType {
WHITE(WhiteNoise::new),
WHITE_BILINEAR((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.BILINEAR)),
WHITE_BICUBIC((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.BICUBIC)),
WHITE_HERMITE((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.HERMITE)),
SIMPLEX(SimplexNoise::new),
PERLIN(seed -> new PerlinNoise(seed).hermite()),
FRACTAL_BILLOW_SIMPLEX(FractalBillowSimplexNoise::new),
@ -28,10 +33,41 @@ public enum NoiseType {
FRACTAL_RIGID_MULTI_SIMPLEX(FractalRigidMultiSimplexNoise::new),
FLAT(FlatNoise::new),
CELLULAR(CellularNoise::new),
CELLULAR_BILINEAR((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR)),
CELLULAR_BILINEAR_STARCAST_3((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_3)),
CELLULAR_BILINEAR_STARCAST_6((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_6)),
CELLULAR_BILINEAR_STARCAST_9((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_9)),
CELLULAR_BILINEAR_STARCAST_12((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_12)),
CELLULAR_BICUBIC((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BICUBIC)),
CELLULAR_HERMITE((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE)),
CELLULAR_STARCAST_3((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_3)),
CELLULAR_STARCAST_6((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_6)),
CELLULAR_STARCAST_9((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_9)),
CELLULAR_STARCAST_12((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_12)),
CELLULAR_HERMITE_STARCAST_3((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_3)),
CELLULAR_HERMITE_STARCAST_6((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_6)),
CELLULAR_HERMITE_STARCAST_9((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_9)),
CELLULAR_HERMITE_STARCAST_12((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_12)),
GLOB(GlobNoise::new),
CUBIC(CubicNoise::new),
FRACTAL_CUBIC(FractalCubicNoise::new),
CELLULAR_HEIGHT(CellHeightNoise::new),
CLOVER(CloverNoise::new),
CLOVER_BILINEAR((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR)),
CLOVER_BILINEAR_STARCAST_3((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_3)),
CLOVER_BILINEAR_STARCAST_6((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_6)),
CLOVER_BILINEAR_STARCAST_9((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_9)),
CLOVER_BILINEAR_STARCAST_12((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_12)),
CLOVER_BICUBIC((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BICUBIC)),
CLOVER_HERMITE((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE)),
CLOVER_STARCAST_3((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_3)),
CLOVER_STARCAST_6((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_6)),
CLOVER_STARCAST_9((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_9)),
CLOVER_STARCAST_12((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_12)),
CLOVER_HERMITE_STARCAST_3((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_3)),
CLOVER_HERMITE_STARCAST_6((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_6)),
CLOVER_HERMITE_STARCAST_9((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_9)),
CLOVER_HERMITE_STARCAST_12((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_12)),
VASCULAR(VascularNoise::new);
private final NoiseFactory f;

View File

@ -31,15 +31,129 @@ public enum NoiseStyle {
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
STATIC(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1)),
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
STATIC_BILINEAR(rng -> new CNG(rng, NoiseType.WHITE_BILINEAR, 1D, 1)),
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
STATIC_BICUBIC(rng -> new CNG(rng, NoiseType.WHITE_BICUBIC, 1D, 1)),
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
STATIC_HERMITE(rng -> new CNG(rng, NoiseType.WHITE_HERMITE, 1D, 1)),
@Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.")
IRIS(rng -> CNG.signature(rng).scale(1)),
@Desc("Clover Noise")
CLOVER(rng -> new CNG(rng, NoiseType.CLOVER, 1D, 1).scale(0.06).bake()),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_STARCAST_3(rng -> new CNG(rng, NoiseType.CLOVER_STARCAST_3, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_STARCAST_6(rng -> new CNG(rng, NoiseType.CLOVER_STARCAST_6, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_STARCAST_9(rng -> new CNG(rng, NoiseType.CLOVER_STARCAST_9, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_STARCAST_12(rng -> new CNG(rng, NoiseType.CLOVER_STARCAST_12, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_BILINEAR_STARCAST_3(rng -> new CNG(rng, NoiseType.CLOVER_BILINEAR_STARCAST_3, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_BILINEAR_STARCAST_6(rng -> new CNG(rng, NoiseType.CLOVER_BILINEAR_STARCAST_6, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_BILINEAR_STARCAST_9(rng -> new CNG(rng, NoiseType.CLOVER_BILINEAR_STARCAST_9, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_BILINEAR_STARCAST_12(rng -> new CNG(rng, NoiseType.CLOVER_BILINEAR_STARCAST_12, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_HERMITE_STARCAST_3(rng -> new CNG(rng, NoiseType.CLOVER_HERMITE_STARCAST_3, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_HERMITE_STARCAST_6(rng -> new CNG(rng, NoiseType.CLOVER_HERMITE_STARCAST_6, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_HERMITE_STARCAST_9(rng -> new CNG(rng, NoiseType.CLOVER_HERMITE_STARCAST_9, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_HERMITE_STARCAST_12(rng -> new CNG(rng, NoiseType.CLOVER_HERMITE_STARCAST_12, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_BILINEAR(rng -> new CNG(rng, NoiseType.CLOVER_BILINEAR, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_BICUBIC(rng -> new CNG(rng, NoiseType.CLOVER_BICUBIC, 1D, 1)),
@Desc("CLOVER noise creates the same noise level for cells, changes noise level on cell borders.")
CLOVER_HERMITE(rng -> new CNG(rng, NoiseType.CLOVER_HERMITE, 1D, 1)),
@Desc("Vascular noise gets higher as the position nears a cell border.")
VASCULAR(rng -> new CNG(rng, NoiseType.VASCULAR, 1D, 1)),
@Desc("It always returns 0.5")
FLAT(rng -> new CNG(rng, NoiseType.FLAT, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR(rng -> new CNG(rng, NoiseType.CELLULAR, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_STARCAST_3(rng -> new CNG(rng, NoiseType.CELLULAR_STARCAST_3, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_STARCAST_6(rng -> new CNG(rng, NoiseType.CELLULAR_STARCAST_6, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_STARCAST_9(rng -> new CNG(rng, NoiseType.CELLULAR_STARCAST_9, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_STARCAST_12(rng -> new CNG(rng, NoiseType.CELLULAR_STARCAST_12, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_BILINEAR_STARCAST_3(rng -> new CNG(rng, NoiseType.CELLULAR_BILINEAR_STARCAST_3, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_BILINEAR_STARCAST_6(rng -> new CNG(rng, NoiseType.CELLULAR_BILINEAR_STARCAST_6, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_BILINEAR_STARCAST_9(rng -> new CNG(rng, NoiseType.CELLULAR_BILINEAR_STARCAST_9, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_BILINEAR_STARCAST_12(rng -> new CNG(rng, NoiseType.CELLULAR_BILINEAR_STARCAST_12, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_HERMITE_STARCAST_3(rng -> new CNG(rng, NoiseType.CELLULAR_HERMITE_STARCAST_3, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_HERMITE_STARCAST_6(rng -> new CNG(rng, NoiseType.CELLULAR_HERMITE_STARCAST_6, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_HERMITE_STARCAST_9(rng -> new CNG(rng, NoiseType.CELLULAR_HERMITE_STARCAST_9, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_HERMITE_STARCAST_12(rng -> new CNG(rng, NoiseType.CELLULAR_HERMITE_STARCAST_12, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_BILINEAR(rng -> new CNG(rng, NoiseType.CELLULAR_BILINEAR, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_BICUBIC(rng -> new CNG(rng, NoiseType.CELLULAR_BICUBIC, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR_HERMITE(rng -> new CNG(rng, NoiseType.CELLULAR_HERMITE, 1D, 1)),
@Desc("Classic German Engineering")
NOWHERE(rng -> CNG.signaturePerlin(rng).scale(0.776).bake()),
@Desc("Classic German Engineering")
@Desc("Classic German Engineering")
NOWHERE_CELLULAR(rng -> CNG.signaturePerlin(rng, NoiseType.CELLULAR).scale(1).bake()),
@Desc("Classic German Engineering")
NOWHERE_CLOVER(rng -> CNG.signaturePerlin(rng, NoiseType.CLOVER).scale(1).bake()),
@Desc("Classic German Engineering")
NOWHERE_SIMPLEX(rng -> CNG.signaturePerlin(rng, NoiseType.SIMPLEX).scale(1).bake()),
@ -295,9 +409,6 @@ public enum NoiseStyle {
@Desc("Cubic Noise")
CUBIC_IRIS_THICK(rng -> CNG.signatureThick(rng, NoiseType.CUBIC).scale(256)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
CELLULAR(rng -> new CNG(rng, NoiseType.CELLULAR, 1D, 1)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders. Cells are distorted using Iris styled wispy noise.")
CELLULAR_IRIS(rng -> CNG.signature(rng, NoiseType.CELLULAR)),
@ -325,12 +436,6 @@ public enum NoiseStyle {
@Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell, using the iris style.")
CELLULAR_HEIGHT_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.CELLULAR_HEIGHT)),
@Desc("Vascular noise gets higher as the position nears a cell border.")
VASCULAR(rng -> new CNG(rng, NoiseType.VASCULAR, 1D, 1)),
@Desc("It always returns 0.5")
FLAT(rng -> new CNG(rng, NoiseType.FLAT, 1D, 1)),
@Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.")
VASCULAR_IRIS(rng -> CNG.signature(rng, NoiseType.VASCULAR)),

View File

@ -21,9 +21,7 @@ package com.volmit.iris.engine.parallel;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.*;
@SuppressWarnings("ALL")
public class BurstExecutor {
@ -81,4 +79,26 @@ public class BurstExecutor {
}
}
}
public boolean complete(long maxDur) {
synchronized (futures) {
if (futures.isEmpty()) {
return true;
}
try {
try {
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(maxDur, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
return false;
}
futures.clear();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
Iris.reportError(e);
}
}
return false;
}
}