New Noise System

This commit is contained in:
Dan Macbook 2020-08-11 16:27:48 -04:00
parent 5d096092b9
commit ce0249f28e
13 changed files with 679 additions and 562 deletions

View File

@ -112,14 +112,12 @@ public class IrisDataManager
IrisNoiseGenerator n = new IrisNoiseGenerator();
n.setSeed(1000);
IrisNoiseGenerator nf = new IrisNoiseGenerator();
nf.setIrisBased(false);
nf.setOctaves(3);
nf.setOpacity(16);
nf.setZoom(24);
nf.setSeed(44);
n.getFracture().add(nf);
IrisNoiseGenerator nf2 = new IrisNoiseGenerator();
nf2.setIrisBased(false);
nf2.setOctaves(8);
nf2.setOpacity(24);
nf2.setZoom(64);

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,30 @@
package com.volmit.iris.noise;
import java.util.List;
import com.volmit.iris.util.IrisInterpolation;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.NoiseInjector;
import com.volmit.iris.util.RNG;
public class CNG
{
public class CNG {
public static long hits = 0;
public static long creates = 0;
public static final NoiseInjector ADD = (s, v) -> new double[] {s + v, 1};
public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[] {s - v < 0 ? 0 : s - v, -1};
public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[] {v - s < 0 ? 0 : s - v, -1};
public static final NoiseInjector MULTIPLY = (s, v) -> new double[] {s * v, 0};
public static final NoiseInjector MAX = (s, v) -> new double[] {Math.max(s, v), 0};
public static final NoiseInjector MIN = (s, v) -> new double[] {Math.min(s, v), 0};
public static final NoiseInjector SRC_MOD = (s, v) -> new double[] {s % v, 0};
public static final NoiseInjector SRC_POW = (s, v) -> new double[] {Math.pow(s, v), 0};
public static final NoiseInjector DST_MOD = (s, v) -> new double[] {v % s, 0};
public static final NoiseInjector DST_POW = (s, v) -> new double[] {Math.pow(v, s), 0};
private double freq;
private double amp;
public static final NoiseInjector ADD = (s, v) -> new double[] { s + v, 1 };
public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[] { s - v < 0 ? 0 : s - v, -1 };
public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[] { v - s < 0 ? 0 : s - v, -1 };
public static final NoiseInjector MULTIPLY = (s, v) -> new double[] { s * v, 0 };
public static final NoiseInjector MAX = (s, v) -> new double[] { Math.max(s, v), 0 };
public static final NoiseInjector MIN = (s, v) -> new double[] { Math.min(s, v), 0 };
public static final NoiseInjector SRC_MOD = (s, v) -> new double[] { s % v, 0 };
public static final NoiseInjector SRC_POW = (s, v) -> new double[] { Math.pow(s, v), 0 };
public static final NoiseInjector DST_MOD = (s, v) -> new double[] { v % s, 0 };
public static final NoiseInjector DST_POW = (s, v) -> new double[] { Math.pow(v, s), 0 };
private double scale;
private double fscale;
private KList<CNG> children;
private CNG fracture;
private SNG generator;
private NoiseGenerator generator;
private final double opacity;
private NoiseInjector injector;
private RNG rng;
@ -35,51 +34,52 @@ public class CNG
private double down;
private double power;
public static CNG signature(RNG rng)
{
//@builder
return new CNG(rng.nextParallelRNG(17), 1D, 3)
.scale(0.012)
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 2)
.scale(0.018)
.child(new CNG(rng.nextParallelRNG(19), 1, 2)
.scale(0.1))
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 2)
.scale(0.15), 24), 44).down(0.3).patch(2.5);
//@done
public static CNG signature(RNG rng) {
return signature(rng, NoiseType.SIMPLEX);
}
public CNG(RNG random)
{
public static CNG signature(RNG rng, NoiseType t) {
// @builder
return new CNG(rng.nextParallelRNG(17), t, 1D, 3).scale(0.012)
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 2).scale(0.018)
.child(new CNG(rng.nextParallelRNG(19), 1, 2).scale(0.1))
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 2).scale(0.15), 24), 44)
.down(0.3).patch(2.5);
// @done
}
public CNG(RNG random) {
this(random, 1);
}
public CNG(RNG random, int octaves)
{
public CNG(RNG random, int octaves) {
this(random, 1D, octaves);
}
public CNG(RNG random, double opacity, int octaves)
{
creates += octaves;
public CNG(RNG random, double opacity, int octaves) {
this(random, NoiseType.SIMPLEX, opacity, octaves);
}
public CNG(RNG random, NoiseType t, double opacity, int octaves) {
creates++;
this.oct = octaves;
this.rng = random;
power = 1;
freq = 1;
amp = 1;
scale = 1;
patch = 1;
fscale = 1;
fracture = null;
generator = new SNG(random);
generator = t.create(random.nextParallelRNG(33).lmax());
this.opacity = opacity;
this.injector = ADD;
if (generator instanceof OctaveNoise) {
((OctaveNoise) generator).setOctaves(octaves);
}
}
public CNG child(CNG c)
{
if(children == null)
{
public CNG child(CNG c) {
if (children == null) {
children = new KList<>();
}
@ -88,69 +88,71 @@ public class CNG
}
@Deprecated
public RNG nextRNG()
{
public RNG nextRNG() {
return getRNG().nextRNG();
}
public RNG getRNG()
{
public RNG getRNG() {
return rng;
}
public CNG fractureWith(CNG c, double scale)
{
public CNG fractureWith(CNG c, double scale) {
fracture = c;
fscale = scale;
return this;
}
public CNG scale(double c)
{
public CNG scale(double c) {
scale = c;
return this;
}
public CNG freq(double c)
{
freq = c;
return this;
}
public CNG amp(double c)
{
amp = c;
return this;
}
public CNG patch(double c)
{
public CNG patch(double c) {
patch = c;
return this;
}
public CNG up(double c)
{
public CNG up(double c) {
up = c;
return this;
}
public CNG down(double c)
{
public CNG down(double c) {
down = c;
return this;
}
public CNG injectWith(NoiseInjector i)
{
public CNG injectWith(NoiseInjector i) {
injector = i;
return this;
}
public int fit(int min, int max, double... dim)
{
if(min == max)
{
public <T> T fit(T[] v, double... dim) {
if (v.length == 0) {
return null;
}
if (v.length == 1) {
return v[0];
}
return v[fit(0, v.length - 1, dim)];
}
public <T> T fit(List<T> v, double... dim) {
if (v.size() == 0) {
return null;
}
if (v.size() == 1) {
return v.get(0);
}
return v.get(fit(0, v.size() - 1, dim));
}
public int fit(int min, int max, double... dim) {
if (min == max) {
return min;
}
@ -159,10 +161,8 @@ public class CNG
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
}
public int fitDouble(double min, double max, double... dim)
{
if(min == max)
{
public int fitDouble(double min, double max, double... dim) {
if (min == max) {
return (int) Math.round(min);
}
@ -171,10 +171,8 @@ public class CNG
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
}
public double fitDoubleD(double min, double max, double... dim)
{
if(min == max)
{
public double fitDoubleD(double min, double max, double... dim) {
if (min == max) {
return min;
}
@ -183,10 +181,8 @@ public class CNG
return IrisInterpolation.lerp(min, max, noise);
}
public int fitDoubleExponent(double min, double max, double exponent, double... dim)
{
if(min == max)
{
public int fitDoubleExponent(double min, double max, double exponent, double... dim) {
if (min == max) {
return (int) Math.round(min);
}
@ -195,23 +191,20 @@ public class CNG
return (int) Math.round(IrisInterpolation.lerp(min, max, exponent == 1 ? noise : Math.pow(noise, exponent)));
}
public double noise(double... dim)
{
public double noise(double... dim) {
double f = fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D;
double x = dim.length > 0 ? dim[0] + f : 0D;
double y = dim.length > 1 ? dim[1] - f : 0D;
double z = dim.length > 2 ? dim[2] + f : 0D;
double n = ((generator.noise(x * scale, y * scale, z * scale, oct, freq, amp, true) / 2D) + 0.5D) * opacity;
double n = generator.noise(x * scale, y * scale, z * scale) * opacity;
n = power != 1D ? Math.pow(n, power) : n;
double m = 1;
hits += oct;
if(children == null)
{
if (children == null) {
return (n - down + up) * patch;
}
for(CNG i : children)
{
for (CNG i : children) {
double[] r = injector.combine(n, i.noise(dim));
n = r[0];
m += r[1];
@ -220,9 +213,13 @@ public class CNG
return ((n / m) - down + up) * patch;
}
public CNG pow(double power)
{
public CNG pow(double power) {
this.power = power;
return this;
}
public CNG oct(int octaves) {
oct = octaves;
return this;
}
}

View File

@ -0,0 +1,9 @@
package com.volmit.iris.noise;
import com.volmit.iris.util.RNG;
@FunctionalInterface
public interface CNGFactory
{
CNG create(RNG seed);
}

View File

@ -0,0 +1,6 @@
package com.volmit.iris.noise;
public interface OctaveNoise
{
public void setOctaves(int o);
}

View File

@ -1,24 +1,79 @@
package com.volmit.iris.noise;
public class SimplexNoise implements NoiseGenerator {
public class SimplexNoise implements NoiseGenerator, OctaveNoise {
private final OpenSimplex n;
private int octaves;
public SimplexNoise(long seed) {
this.n = new OpenSimplex(seed);
octaves = 1;
}
@Override
public double noise(double x) {
return (n.noise2(x, 0) / 2D) + 0.5D;
if (octaves <= 1) {
return (n.noise2_XBeforeY(x, 0) / 2D) + 0.5D;
}
double result = 0;
double amp = 1;
double freq = 1;
double max = 0;
for (int i = 0; i < octaves; i++) {
result += ((n.noise2_XBeforeY(x * freq, 0) * amp) / 2D) + 0.5D;
max += amp;
freq *= 2;
amp *= 2;
}
return result / max;
}
@Override
public double noise(double x, double z) {
return (n.noise2(x, z) / 2D) + 0.5D;
if (octaves <= 1) {
return (n.noise2(x, z) / 2D) + 0.5D;
}
double result = 0;
double amp = 1;
double freq = 1;
double max = 0;
for (int i = 0; i < octaves; i++) {
result += ((n.noise2(x * freq, z * freq) * amp) / 2D) + 0.5D;
max += amp;
freq *= 2;
amp *= 2;
}
return result / max;
}
@Override
public double noise(double x, double y, double z) {
return (n.noise3_XZBeforeY(x, y, z) / 2D) + 0.5D;
if (octaves <= 1) {
return (n.noise3_XZBeforeY(x, y, z) / 2D) + 0.5D;
}
double result = 0;
double amp = 1;
double freq = 1;
double max = 0;
for (int i = 0; i < octaves; i++) {
result += ((n.noise3_XZBeforeY(x * freq, y * freq, z * freq) * amp) / 2D) + 0.5D;
max += amp;
freq *= 2;
amp *= 2;
}
return result / max;
}
@Override
public void setOctaves(int o) {
octaves = o;
}
}

View File

@ -1,12 +0,0 @@
package com.volmit.iris.object;
import com.volmit.iris.util.DontObfuscate;
public enum Dispersion
{
@DontObfuscate
SCATTER,
@DontObfuscate
WISPY;
}

View File

@ -41,7 +41,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
@DontObfuscate
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
private Dispersion biomeDispersion = Dispersion.SCATTER;
private NoiseStyle biomeStyle = NoiseStyle.SIMPLEX;
@MinNumber(0.0001)
@DontObfuscate
@ -156,7 +156,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
{
return biomeGenerator.aquire(() ->
{
return CNG.signature(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
return biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()));
});
}
@ -187,7 +187,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
for(int i = 0; i < layers.size(); i++)
{
CNG hgen = getLayerHeightGenerators(random).get(i);
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getTerrainZoom(), wz / layers.get(i).getTerrainZoom());
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
if(d < 0)
{
@ -203,7 +203,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
try
{
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getTerrainZoom(), j, (wz - j) / layers.get(i).getTerrainZoom()));
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom()));
}
catch(Throwable e)
@ -234,7 +234,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
for(int i = 0; i < layers.size(); i++)
{
CNG hgen = getLayerHeightGenerators(random).get(i);
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getTerrainZoom(), wz / layers.get(i).getTerrainZoom());
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
if(d < 0)
{
@ -245,7 +245,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
{
try
{
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getTerrainZoom(), j, (wz - j) / layers.get(i).getTerrainZoom()));
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom()));
}
catch(Throwable e)
@ -298,7 +298,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
for(int i = 0; i < seaLayers.size(); i++)
{
CNG hgen = getLayerSeaHeightGenerators(random).get(i);
int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(), wx / seaLayers.get(i).getTerrainZoom(), wz / seaLayers.get(i).getTerrainZoom());
int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(), wx / seaLayers.get(i).getZoom(), wz / seaLayers.get(i).getZoom());
if(d < 0)
{
@ -314,7 +314,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
try
{
data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / seaLayers.get(i).getTerrainZoom(), j, (wz - j) / seaLayers.get(i).getTerrainZoom()));
data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / seaLayers.get(i).getZoom(), j, (wz - j) / seaLayers.get(i).getZoom()));
}
catch(Throwable e)

View File

@ -23,15 +23,15 @@ public class IrisBiomeDecorator
{
@DontObfuscate
@Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience")
private Dispersion variance = Dispersion.SCATTER;
private NoiseStyle variance = NoiseStyle.STATIC;
@DontObfuscate
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
private Dispersion dispersion = Dispersion.SCATTER;
private NoiseStyle dispersion = NoiseStyle.STATIC;
@DontObfuscate
@Desc("If this decorator has a height more than 1 this changes how it picks the height between your maxes. Scatter = random, Wispy = wavy heights")
private Dispersion verticalVariance = Dispersion.SCATTER;
private NoiseStyle heightVariance = NoiseStyle.STATIC;
@DontObfuscate
@Desc("Tells iris where this decoration is a part of. I.e. SHORE_LINE or SEA_SURFACE")
@ -51,9 +51,14 @@ public class IrisBiomeDecorator
@MinNumber(0.0001)
@DontObfuscate
@Desc("The zoom is for zooming in or out wispy dispersions. Makes patches bigger the higher this zoom value is/")
@Desc("The zoom is for zooming in or out wispy dispersions. Makes patches bigger the higher this zoom value is")
private double zoom = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("The zoom is for zooming in or out variance. Makes patches have more or less of one type.")
private double varianceZoom = 1;
@MinNumber(0.0001)
@DontObfuscate
@Desc("The vertical zoom is for wispy stack heights. Zooming this in makes stack heights more slowly change over a distance")
@ -73,6 +78,7 @@ public class IrisBiomeDecorator
private KList<String> palette = new KList<String>().qadd("GRASS");
private transient KMap<Long, CNG> layerGenerators;
private transient KMap<Long, CNG> layerVarianceGenerators;
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
@ -83,14 +89,14 @@ public class IrisBiomeDecorator
return stackMin;
}
return getGenerator(rng).fit(stackMin, stackMax, x * (verticalVariance.equals(Dispersion.SCATTER) ? 1000D : 1D), z * (verticalVariance.equals(Dispersion.SCATTER) ? 1000D : 1D));
return getHeightGenerator(rng).fit(stackMin, stackMax, x ,z);
}
public CNG getHeightGenerator(RNG rng)
{
return heightGenerator.aquire(() ->
{
return CNG.signature(rng.nextParallelRNG(getBlockData().size() + stackMax + stackMin)).scale(1D / verticalZoom);
return heightVariance.create(rng.nextParallelRNG(getBlockData().size() + stackMax + stackMin)).scale(1D / verticalZoom);
});
}
@ -105,12 +111,29 @@ public class IrisBiomeDecorator
if(!layerGenerators.containsKey(key))
{
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG((int) (getBlockData().size() + key))).scale(1D / zoom));
layerGenerators.put(key, dispersion.create(rng.nextParallelRNG((int) (getBlockData().size() + key))).scale(1D / zoom));
}
return layerGenerators.get(key);
}
public CNG getVarianceGenerator(RNG rng)
{
long key = rng.nextParallelRNG(4).nextLong();
if(layerVarianceGenerators == null)
{
layerGenerators = new KMap<>();
}
if(!layerVarianceGenerators.containsKey(key))
{
layerVarianceGenerators.put(key, variance.create(rng.nextParallelRNG((int) (getBlockData().size() + key))).scale(1D / varianceZoom));
}
return layerVarianceGenerators.get(key);
}
public KList<String> add(String b)
{
palette.add(b);
@ -134,9 +157,8 @@ public class IrisBiomeDecorator
return null;
}
RNG nrng = dispersion.equals(Dispersion.SCATTER) ? rng.nextParallelRNG((int) (z - (int) ((x + 34856) * (int) (x + z + (int) (28835521 + (getChance() * 1000) + getStackMin() + getStackMax() + (getZoom() * 556)))))) : null;
double xx = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-1000000, 1000000) + z : x;
double zz = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-1000000, 1000000) - x : z;
double xx = x;
double zz = z;
xx /= getZoom();
zz /= getZoom();
@ -147,7 +169,7 @@ public class IrisBiomeDecorator
return getBlockData().get(0);
}
return getBlockData().get(getGenerator(rng.nextParallelRNG(44)).fit(0, getBlockData().size() - 1, xx, zz));
return getVarianceGenerator(rng.nextParallelRNG(44)).fit(getBlockData(), xx, zz);
}
return null;

View File

@ -21,8 +21,8 @@ import lombok.Data;
public class IrisBiomePaletteLayer
{
@DontObfuscate
@Desc("The dispersion of materials from the palette")
private Dispersion dispersion = Dispersion.SCATTER;
@Desc("The style of noise")
private NoiseStyle style = NoiseStyle.STATIC;
@MinNumber(0)
@MaxNumber(256)
@ -39,7 +39,7 @@ public class IrisBiomePaletteLayer
@MinNumber(0.0001)
@DontObfuscate
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
private double terrainZoom = 5;
private double zoom = 5;
@Required
@ArrayType(min = 1, type = String.class)
@ -68,35 +68,15 @@ public class IrisBiomePaletteLayer
return getBlockData().get(0);
}
if(dispersion.equals(Dispersion.SCATTER))
{
return getBlockData().get(getLayerGenerator(rng).fit(0, 30000000, x, y, z) % getBlockData().size());
}
else
{
return getBlockData().get(getLayerGenerator(rng).fit(0, getBlockData().size() - 1, x, y, z));
}
return getLayerGenerator(rng).fit(getBlockData(), x, y, z);
}
public CNG getLayerGenerator(RNG rng)
{
return layerGenerator.aquire(() ->
{
CNG layerGenerator = new CNG(rng);
RNG rngx = rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size());
switch(dispersion)
{
case SCATTER:
layerGenerator = CNG.signature(rngx).freq(1000000);
break;
case WISPY:
layerGenerator = CNG.signature(rngx);
break;
}
return layerGenerator;
return style.create(rngx);
});
}

View File

@ -29,8 +29,7 @@ import lombok.EqualsAndHashCode;
@Desc("Represents a dimension")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisDimension extends IrisRegistrant
{
public class IrisDimension extends IrisRegistrant {
public static final BlockData STONE = Material.STONE.createBlockData();
public static final BlockData WATER = Material.WATER.createBlockData();
@ -238,8 +237,12 @@ public class IrisDimension extends IrisRegistrant
private KList<IrisDepositGenerator> deposits = new KList<>();
@DontObfuscate
@Desc("The dispersion of materials for the rock palette")
private Dispersion rockDispersion = Dispersion.SCATTER;
@Desc("The noise style for rock types")
private NoiseStyle rockStyle = NoiseStyle.STATIC;
@DontObfuscate
@Desc("The noise style for fluid types")
private NoiseStyle fluidStyle = NoiseStyle.STATIC;
@MinNumber(0.0001)
@MaxNumber(512)
@ -274,33 +277,29 @@ public class IrisDimension extends IrisRegistrant
private transient AtomicCache<Double> rad = new AtomicCache<>();
private transient boolean inverted = false;
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g)
{
return cacheFilters.aquire(() ->
{
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g) {
return cacheFilters.aquire(() -> {
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
for(IrisPostProcessor i : getPostProcessors())
{
for (IrisPostProcessor i : getPostProcessors()) {
cacheFilters.add(g.createProcessor(i.getProcessor(), i.getPhase()));
}
g.setMinPhase(0);
g.setMaxPhase(0);
for(IrisPostBlockFilter i : cacheFilters)
{
for (IrisPostBlockFilter i : cacheFilters) {
g.setMinPhase(Math.min(g.getMinPhase(), i.getPhase()));
g.setMaxPhase(Math.max(g.getMaxPhase(), i.getPhase()));
}
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - " + g.getMaxPhase());
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - "
+ g.getMaxPhase());
return cacheFilters;
});
}
public static KList<IrisCompatabilityFilter> getDefaultCompatability()
{
public static KList<IrisCompatabilityFilter> getDefaultCompatability() {
KList<IrisCompatabilityFilter> filters = new KList<>();
// Below 1.16
@ -439,18 +438,15 @@ public class IrisDimension extends IrisRegistrant
return filters;
}
public CNG getCoordFracture(RNG rng, int signature)
{
return coordFracture.aquire(() ->
{
public CNG getCoordFracture(RNG rng, int signature) {
return coordFracture.aquire(() -> {
CNG coordFracture = CNG.signature(rng.nextParallelRNG(signature));
coordFracture.scale(0.012 / coordFractureZoom);
return coordFracture;
});
}
private KList<IrisPostProcessor> getDefaultPostProcessors()
{
private KList<IrisPostProcessor> getDefaultPostProcessors() {
KList<IrisPostProcessor> p = new KList<IrisPostProcessor>();
p.add(new IrisPostProcessor("wall-painter"));
@ -460,59 +456,32 @@ public class IrisDimension extends IrisRegistrant
return p;
}
public BlockData getRock(RNG rng, double x, double y, double z)
{
if(getRockData().isEmpty())
{
public BlockData getRock(RNG rng, double x, double y, double z) {
if (getRockData().isEmpty()) {
return STONE;
}
if(getRockData().size() == 1)
{
if (getRockData().size() == 1) {
return getRockData().get(0);
}
if(rockDispersion.equals(Dispersion.SCATTER))
{
return getRockData().get(getRockGenerator(rng).fit(0, 30000000, x, y, z) % getRockData().size());
}
else
{
return getRockData().get(getRockGenerator(rng).fit(0, getRockData().size() - 1, x, y, z));
}
return getRockGenerator(rng).fit(getRockData(), x, y, z);
}
public CNG getRockGenerator(RNG rng)
{
return rockLayerGenerator.aquire(() ->
{
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
CNG rockLayerGenerator = new CNG(rng);
switch(rockDispersion)
{
case SCATTER:
rockLayerGenerator = CNG.signature(rngx).freq(1000000);
break;
case WISPY:
rockLayerGenerator = CNG.signature(rngx);
break;
}
return rockLayerGenerator;
public CNG getRockGenerator(RNG rng) {
return rockLayerGenerator.aquire(() -> {
RNG rngx = rng.nextParallelRNG(
(int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
return rockStyle.create(rngx);
});
}
public KList<BlockData> getRockData()
{
return rockData.aquire(() ->
{
public KList<BlockData> getRockData() {
return rockData.aquire(() -> {
KList<BlockData> rockData = new KList<>();
for(String ix : rockPalette)
{
for (String ix : rockPalette) {
BlockData bx = B.getBlockData(ix);
if(bx != null)
{
if (bx != null) {
rockData.add(bx);
}
}
@ -521,59 +490,32 @@ public class IrisDimension extends IrisRegistrant
});
}
public BlockData getFluid(RNG rng, double x, double y, double z)
{
if(getFluidData().isEmpty())
{
public BlockData getFluid(RNG rng, double x, double y, double z) {
if (getFluidData().isEmpty()) {
return WATER;
}
if(getFluidData().size() == 1)
{
if (getFluidData().size() == 1) {
return getFluidData().get(0);
}
if(rockDispersion.equals(Dispersion.SCATTER))
{
return getFluidData().get(getFluidGenerator(rng).fit(0, 30000000, x, y, z) % getFluidData().size());
}
else
{
return getFluidData().get(getFluidGenerator(rng).fit(0, getFluidData().size() - 1, x, y, z));
}
return getFluidGenerator(rng).fit(getFluidData(), x, y, z);
}
public CNG getFluidGenerator(RNG rng)
{
return fluidLayerGenerator.aquire(() ->
{
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
CNG fluidLayerGenerator = new CNG(rng);
switch(rockDispersion)
{
case SCATTER:
fluidLayerGenerator = CNG.signature(rngx).freq(1000000);
break;
case WISPY:
fluidLayerGenerator = CNG.signature(rngx);
break;
}
return fluidLayerGenerator;
public CNG getFluidGenerator(RNG rng) {
return fluidLayerGenerator.aquire(() -> {
RNG rngx = rng.nextParallelRNG(getFluidData().size()
* (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
return fluidStyle.create(rngx);
});
}
public KList<BlockData> getFluidData()
{
return fluidData.aquire(() ->
{
public KList<BlockData> getFluidData() {
return fluidData.aquire(() -> {
KList<BlockData> fluidData = new KList<>();
for(String ix : fluidPalette)
{
for (String ix : fluidPalette) {
BlockData bx = B.getBlockData(ix);
if(bx != null)
{
if (bx != null) {
fluidData.add(bx);
}
}
@ -582,49 +524,40 @@ public class IrisDimension extends IrisRegistrant
});
}
public double getDimensionAngle()
{
public double getDimensionAngle() {
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
}
public double sinRotate()
{
public double sinRotate() {
return sinr.aquire(() -> Math.sin(getDimensionAngle()));
}
public double cosRotate()
{
public double cosRotate() {
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
}
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g)
{
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g) {
KList<IrisRegion> r = new KList<>();
for(String i : getRegions())
{
for (String i : getRegions()) {
r.add(g != null ? g.loadRegion(i) : Iris.globaldata.getRegionLoader().load(i));
}
return r;
}
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g)
{
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g) {
KList<IrisBiome> r = new KList<>();
for(IrisRegion i : getAllRegions(g))
{
for (IrisRegion i : getAllRegions(g)) {
r.addAll(i.getAllBiomes(g));
}
return r;
}
public ChunkPosition getParallaxSize(ContextualChunkGenerator g)
{
return parallaxSize.aquire(() ->
{
public ChunkPosition getParallaxSize(ContextualChunkGenerator g) {
return parallaxSize.aquire(() -> {
int x = 0;
int z = 0;
@ -632,50 +565,40 @@ public class IrisDimension extends IrisRegistrant
KList<IrisRegion> r = getAllRegions(g);
KList<IrisBiome> b = getAllBiomes(g);
for(IrisBiome i : b)
{
for(IrisObjectPlacement j : i.getObjects())
{
for (IrisBiome i : b) {
for (IrisObjectPlacement j : i.getObjects()) {
objects.addAll(j.getPlace());
}
}
for(String i : objects)
{
try
{
for (String i : objects) {
try {
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
x = bv.getBlockX() > x ? bv.getBlockX() : x;
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
}
catch(Throwable e)
{
catch (Throwable e) {
}
}
for(IrisDepositGenerator i : getDeposits())
{
for (IrisDepositGenerator i : getDeposits()) {
int max = i.getMaxDimension();
x = max > x ? max : x;
z = max > z ? max : z;
}
for(IrisRegion v : r)
{
for(IrisDepositGenerator i : v.getDeposits())
{
for (IrisRegion v : r) {
for (IrisDepositGenerator i : v.getDeposits()) {
int max = i.getMaxDimension();
x = max > x ? max : x;
z = max > z ? max : z;
}
}
for(IrisBiome v : b)
{
for(IrisDepositGenerator i : v.getDeposits())
{
for (IrisBiome v : b) {
for (IrisDepositGenerator i : v.getDeposits()) {
int max = i.getMaxDimension();
x = max > x ? max : x;
z = max > z ? max : z;
@ -691,12 +614,9 @@ public class IrisDimension extends IrisRegistrant
});
}
public BlockData resolve(String bd)
{
for(IrisCompatabilityFilter i : getCompatability())
{
if(i.getWhen().equalsIgnoreCase(bd))
{
public BlockData resolve(String bd) {
for (IrisCompatabilityFilter i : getCompatability()) {
if (i.getWhen().equalsIgnoreCase(bd)) {
return i.getReplace();
}
}

View File

@ -69,8 +69,8 @@ public class IrisNoiseGenerator
private boolean enabled = true;
@DontObfuscate
@Desc("If this generator uses the default iris swirly/wispy noise generator. Set to false for pure simplex.")
private boolean irisBased = true;
@Desc("The Noise Style")
private NoiseStyle style = NoiseStyle.IRIS;
@MinNumber(1)
@DontObfuscate
@ -97,7 +97,7 @@ public class IrisNoiseGenerator
protected CNG getGenerator(long superSeed)
{
return generator.aquire(() -> irisBased ? CNG.signature(new RNG(superSeed + 33955677 - seed)) : new CNG(new RNG(superSeed + 33955677 - seed), 1D, octaves));
return generator.aquire(() -> style.create(new RNG(superSeed + 33955677 - seed)).oct(octaves));
}
public double getMax()

View File

@ -0,0 +1,103 @@
package com.volmit.iris.object;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.noise.CNGFactory;
import com.volmit.iris.noise.NoiseType;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.RNG;
@Desc("Styles of noise")
@DontObfuscate
public enum NoiseStyle {
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
@DontObfuscate
STATIC(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1)),
@Desc("White Noise is like static. Useful for block scattering but not terrain. 4 Times finer.")
@DontObfuscate
STATIC_FINE(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1).scale(4)),
@Desc("White Noise is like static. Useful for block scattering but not terrain. 16 Times finer.")
@DontObfuscate
STATIC_ULTRA_FINE(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1).scale(16)),
@Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.")
@DontObfuscate
IRIS(rng -> CNG.signature(rng)),
@Desc("Basic, Smooth & Fast Simplex noise.")
@DontObfuscate
SIMPLEX(rng -> new CNG(rng, 1D, 1)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 2 octaves")
@DontObfuscate
BIOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 2)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 3 octaves")
@DontObfuscate
TRIOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 3)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 4 octaves")
@DontObfuscate
QUADOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 4)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 5 octaves")
@DontObfuscate
QUINTOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 5)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 6 octaves")
@DontObfuscate
SEXOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 6)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 7 octaves")
@DontObfuscate
SEPTOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 7)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 8 octaves")
@DontObfuscate
OCTOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 8)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 9 octaves")
@DontObfuscate
NONOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 9)),
@Desc("Basic, Smooth & Fast Simplex noise. Uses 10 octaves")
@DontObfuscate
VIGOCTAVE_SIMPLEX(rng -> new CNG(rng, 1D, 10)),
@Desc("Cellular noise creates the same noise level for cells, changes noise level on cell borders.")
@DontObfuscate
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.")
@DontObfuscate
CELLULAR_IRIS(rng -> CNG.signature(rng, NoiseType.CELLULAR)),
@Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell")
@DontObfuscate
PERTERB(rng -> new CNG(rng, NoiseType.CELLULAR_HEIGHT, 1D, 1)),
@Desc("Inverse of vascular, height gets to 1.0 as it approaches the center of a cell, using the iris style.")
@DontObfuscate
PERTERB_IRIS(rng -> CNG.signature(rng, NoiseType.CELLULAR_HEIGHT)),
@Desc("Vascular noise gets higher as the position nears a cell border.")
@DontObfuscate
VASCULAR(rng -> new CNG(rng, NoiseType.VASCULAR, 1D, 1)),
@Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.")
@DontObfuscate
VASCULAR_IRIS(rng -> CNG.signature(rng, NoiseType.VASCULAR)),
;
private CNGFactory f;
private NoiseStyle(CNGFactory f) {
this.f = f;
}
public CNG create(RNG seed) {
return f.create(seed);
}
}