mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
New Noise System
This commit is contained in:
parent
5d096092b9
commit
ce0249f28e
@ -112,14 +112,12 @@ public class IrisDataManager
|
|||||||
IrisNoiseGenerator n = new IrisNoiseGenerator();
|
IrisNoiseGenerator n = new IrisNoiseGenerator();
|
||||||
n.setSeed(1000);
|
n.setSeed(1000);
|
||||||
IrisNoiseGenerator nf = new IrisNoiseGenerator();
|
IrisNoiseGenerator nf = new IrisNoiseGenerator();
|
||||||
nf.setIrisBased(false);
|
|
||||||
nf.setOctaves(3);
|
nf.setOctaves(3);
|
||||||
nf.setOpacity(16);
|
nf.setOpacity(16);
|
||||||
nf.setZoom(24);
|
nf.setZoom(24);
|
||||||
nf.setSeed(44);
|
nf.setSeed(44);
|
||||||
n.getFracture().add(nf);
|
n.getFracture().add(nf);
|
||||||
IrisNoiseGenerator nf2 = new IrisNoiseGenerator();
|
IrisNoiseGenerator nf2 = new IrisNoiseGenerator();
|
||||||
nf2.setIrisBased(false);
|
|
||||||
nf2.setOctaves(8);
|
nf2.setOctaves(8);
|
||||||
nf2.setOpacity(24);
|
nf2.setOpacity(24);
|
||||||
nf2.setZoom(64);
|
nf2.setZoom(64);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,30 @@
|
|||||||
package com.volmit.iris.noise;
|
package com.volmit.iris.noise;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.volmit.iris.util.IrisInterpolation;
|
import com.volmit.iris.util.IrisInterpolation;
|
||||||
import com.volmit.iris.util.KList;
|
import com.volmit.iris.util.KList;
|
||||||
import com.volmit.iris.util.NoiseInjector;
|
import com.volmit.iris.util.NoiseInjector;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
public class CNG
|
public class CNG {
|
||||||
{
|
|
||||||
public static long hits = 0;
|
public static long hits = 0;
|
||||||
public static long creates = 0;
|
public static long creates = 0;
|
||||||
public static final NoiseInjector ADD = (s, v) -> new double[] {s + v, 1};
|
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 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 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 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 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 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_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 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_MOD = (s, v) -> new double[] { v % s, 0 };
|
||||||
public static final NoiseInjector DST_POW = (s, v) -> new double[] {Math.pow(v, s), 0};
|
public static final NoiseInjector DST_POW = (s, v) -> new double[] { Math.pow(v, s), 0 };
|
||||||
private double freq;
|
|
||||||
private double amp;
|
|
||||||
private double scale;
|
private double scale;
|
||||||
private double fscale;
|
private double fscale;
|
||||||
private KList<CNG> children;
|
private KList<CNG> children;
|
||||||
private CNG fracture;
|
private CNG fracture;
|
||||||
private SNG generator;
|
private NoiseGenerator generator;
|
||||||
private final double opacity;
|
private final double opacity;
|
||||||
private NoiseInjector injector;
|
private NoiseInjector injector;
|
||||||
private RNG rng;
|
private RNG rng;
|
||||||
@ -35,51 +34,52 @@ public class CNG
|
|||||||
private double down;
|
private double down;
|
||||||
private double power;
|
private double power;
|
||||||
|
|
||||||
public static CNG signature(RNG rng)
|
public static CNG signature(RNG rng) {
|
||||||
{
|
return signature(rng, NoiseType.SIMPLEX);
|
||||||
//@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 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);
|
this(random, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG(RNG random, int octaves)
|
public CNG(RNG random, int octaves) {
|
||||||
{
|
|
||||||
this(random, 1D, octaves);
|
this(random, 1D, octaves);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG(RNG random, double opacity, int octaves)
|
public CNG(RNG random, double opacity, int octaves) {
|
||||||
{
|
this(random, NoiseType.SIMPLEX, opacity, octaves);
|
||||||
creates += octaves;
|
}
|
||||||
|
|
||||||
|
public CNG(RNG random, NoiseType t, double opacity, int octaves) {
|
||||||
|
creates++;
|
||||||
this.oct = octaves;
|
this.oct = octaves;
|
||||||
this.rng = random;
|
this.rng = random;
|
||||||
power = 1;
|
power = 1;
|
||||||
freq = 1;
|
|
||||||
amp = 1;
|
|
||||||
scale = 1;
|
scale = 1;
|
||||||
patch = 1;
|
patch = 1;
|
||||||
fscale = 1;
|
fscale = 1;
|
||||||
fracture = null;
|
fracture = null;
|
||||||
generator = new SNG(random);
|
generator = t.create(random.nextParallelRNG(33).lmax());
|
||||||
this.opacity = opacity;
|
this.opacity = opacity;
|
||||||
this.injector = ADD;
|
this.injector = ADD;
|
||||||
|
|
||||||
|
if (generator instanceof OctaveNoise) {
|
||||||
|
((OctaveNoise) generator).setOctaves(octaves);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG child(CNG c)
|
public CNG child(CNG c) {
|
||||||
{
|
if (children == null) {
|
||||||
if(children == null)
|
|
||||||
{
|
|
||||||
children = new KList<>();
|
children = new KList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,69 +88,71 @@ public class CNG
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public RNG nextRNG()
|
public RNG nextRNG() {
|
||||||
{
|
|
||||||
return getRNG().nextRNG();
|
return getRNG().nextRNG();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RNG getRNG()
|
public RNG getRNG() {
|
||||||
{
|
|
||||||
return rng;
|
return rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG fractureWith(CNG c, double scale)
|
public CNG fractureWith(CNG c, double scale) {
|
||||||
{
|
|
||||||
fracture = c;
|
fracture = c;
|
||||||
fscale = scale;
|
fscale = scale;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG scale(double c)
|
public CNG scale(double c) {
|
||||||
{
|
|
||||||
scale = c;
|
scale = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG freq(double c)
|
public CNG patch(double c) {
|
||||||
{
|
|
||||||
freq = c;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CNG amp(double c)
|
|
||||||
{
|
|
||||||
amp = c;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CNG patch(double c)
|
|
||||||
{
|
|
||||||
patch = c;
|
patch = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG up(double c)
|
public CNG up(double c) {
|
||||||
{
|
|
||||||
up = c;
|
up = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG down(double c)
|
public CNG down(double c) {
|
||||||
{
|
|
||||||
down = c;
|
down = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG injectWith(NoiseInjector i)
|
public CNG injectWith(NoiseInjector i) {
|
||||||
{
|
|
||||||
injector = i;
|
injector = i;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fit(int min, int max, double... dim)
|
public <T> T fit(T[] v, double... dim) {
|
||||||
{
|
if (v.length == 0) {
|
||||||
if(min == max)
|
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;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,10 +161,8 @@ public class CNG
|
|||||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fitDouble(double min, double max, double... dim)
|
public int fitDouble(double min, double max, double... dim) {
|
||||||
{
|
if (min == max) {
|
||||||
if(min == max)
|
|
||||||
{
|
|
||||||
return (int) Math.round(min);
|
return (int) Math.round(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,10 +171,8 @@ public class CNG
|
|||||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fitDoubleD(double min, double max, double... dim)
|
public double fitDoubleD(double min, double max, double... dim) {
|
||||||
{
|
if (min == max) {
|
||||||
if(min == max)
|
|
||||||
{
|
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,10 +181,8 @@ public class CNG
|
|||||||
return IrisInterpolation.lerp(min, max, noise);
|
return IrisInterpolation.lerp(min, max, noise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fitDoubleExponent(double min, double max, double exponent, double... dim)
|
public int fitDoubleExponent(double min, double max, double exponent, double... dim) {
|
||||||
{
|
if (min == max) {
|
||||||
if(min == max)
|
|
||||||
{
|
|
||||||
return (int) Math.round(min);
|
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)));
|
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 f = fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D;
|
||||||
double x = dim.length > 0 ? dim[0] + f : 0D;
|
double x = dim.length > 0 ? dim[0] + f : 0D;
|
||||||
double y = dim.length > 1 ? dim[1] - f : 0D;
|
double y = dim.length > 1 ? dim[1] - f : 0D;
|
||||||
double z = dim.length > 2 ? dim[2] + 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;
|
n = power != 1D ? Math.pow(n, power) : n;
|
||||||
double m = 1;
|
double m = 1;
|
||||||
hits += oct;
|
hits += oct;
|
||||||
if(children == null)
|
if (children == null) {
|
||||||
{
|
|
||||||
return (n - down + up) * patch;
|
return (n - down + up) * patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(CNG i : children)
|
for (CNG i : children) {
|
||||||
{
|
|
||||||
double[] r = injector.combine(n, i.noise(dim));
|
double[] r = injector.combine(n, i.noise(dim));
|
||||||
n = r[0];
|
n = r[0];
|
||||||
m += r[1];
|
m += r[1];
|
||||||
@ -220,9 +213,13 @@ public class CNG
|
|||||||
return ((n / m) - down + up) * patch;
|
return ((n / m) - down + up) * patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG pow(double power)
|
public CNG pow(double power) {
|
||||||
{
|
|
||||||
this.power = power;
|
this.power = power;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CNG oct(int octaves) {
|
||||||
|
oct = octaves;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
9
src/main/java/com/volmit/iris/noise/CNGFactory.java
Normal file
9
src/main/java/com/volmit/iris/noise/CNGFactory.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package com.volmit.iris.noise;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface CNGFactory
|
||||||
|
{
|
||||||
|
CNG create(RNG seed);
|
||||||
|
}
|
6
src/main/java/com/volmit/iris/noise/OctaveNoise.java
Normal file
6
src/main/java/com/volmit/iris/noise/OctaveNoise.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package com.volmit.iris.noise;
|
||||||
|
|
||||||
|
public interface OctaveNoise
|
||||||
|
{
|
||||||
|
public void setOctaves(int o);
|
||||||
|
}
|
@ -1,24 +1,79 @@
|
|||||||
package com.volmit.iris.noise;
|
package com.volmit.iris.noise;
|
||||||
|
|
||||||
public class SimplexNoise implements NoiseGenerator {
|
public class SimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||||
private final OpenSimplex n;
|
private final OpenSimplex n;
|
||||||
|
private int octaves;
|
||||||
|
|
||||||
public SimplexNoise(long seed) {
|
public SimplexNoise(long seed) {
|
||||||
this.n = new OpenSimplex(seed);
|
this.n = new OpenSimplex(seed);
|
||||||
|
octaves = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double noise(double x) {
|
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
|
@Override
|
||||||
public double noise(double x, double z) {
|
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
|
@Override
|
||||||
public double noise(double x, double y, double z) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package com.volmit.iris.object;
|
|
||||||
|
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
|
||||||
|
|
||||||
public enum Dispersion
|
|
||||||
{
|
|
||||||
@DontObfuscate
|
|
||||||
SCATTER,
|
|
||||||
|
|
||||||
@DontObfuscate
|
|
||||||
WISPY;
|
|
||||||
}
|
|
@ -41,7 +41,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
@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)
|
@MinNumber(0.0001)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -156,7 +156,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
{
|
{
|
||||||
return biomeGenerator.aquire(() ->
|
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++)
|
for(int i = 0; i < layers.size(); i++)
|
||||||
{
|
{
|
||||||
CNG hgen = getLayerHeightGenerators(random).get(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)
|
if(d < 0)
|
||||||
{
|
{
|
||||||
@ -203,7 +203,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
|
|
||||||
try
|
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)
|
catch(Throwable e)
|
||||||
@ -234,7 +234,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
for(int i = 0; i < layers.size(); i++)
|
for(int i = 0; i < layers.size(); i++)
|
||||||
{
|
{
|
||||||
CNG hgen = getLayerHeightGenerators(random).get(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)
|
if(d < 0)
|
||||||
{
|
{
|
||||||
@ -245,7 +245,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
{
|
{
|
||||||
try
|
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)
|
catch(Throwable e)
|
||||||
@ -298,7 +298,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
for(int i = 0; i < seaLayers.size(); i++)
|
for(int i = 0; i < seaLayers.size(); i++)
|
||||||
{
|
{
|
||||||
CNG hgen = getLayerSeaHeightGenerators(random).get(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)
|
if(d < 0)
|
||||||
{
|
{
|
||||||
@ -314,7 +314,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
|
|
||||||
try
|
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)
|
catch(Throwable e)
|
||||||
|
@ -23,15 +23,15 @@ public class IrisBiomeDecorator
|
|||||||
{
|
{
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience")
|
@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
|
@DontObfuscate
|
||||||
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
|
@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
|
@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")
|
@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
|
@DontObfuscate
|
||||||
@Desc("Tells iris where this decoration is a part of. I.e. SHORE_LINE or SEA_SURFACE")
|
@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)
|
@MinNumber(0.0001)
|
||||||
@DontObfuscate
|
@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;
|
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)
|
@MinNumber(0.0001)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The vertical zoom is for wispy stack heights. Zooming this in makes stack heights more slowly change over a distance")
|
@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 KList<String> palette = new KList<String>().qadd("GRASS");
|
||||||
|
|
||||||
private transient KMap<Long, CNG> layerGenerators;
|
private transient KMap<Long, CNG> layerGenerators;
|
||||||
|
private transient KMap<Long, CNG> layerVarianceGenerators;
|
||||||
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
||||||
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
||||||
|
|
||||||
@ -83,14 +89,14 @@ public class IrisBiomeDecorator
|
|||||||
return stackMin;
|
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)
|
public CNG getHeightGenerator(RNG rng)
|
||||||
{
|
{
|
||||||
return heightGenerator.aquire(() ->
|
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))
|
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);
|
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)
|
public KList<String> add(String b)
|
||||||
{
|
{
|
||||||
palette.add(b);
|
palette.add(b);
|
||||||
@ -134,9 +157,8 @@ public class IrisBiomeDecorator
|
|||||||
return null;
|
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 = x;
|
||||||
double xx = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-1000000, 1000000) + z : x;
|
double zz = z;
|
||||||
double zz = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-1000000, 1000000) - x : z;
|
|
||||||
xx /= getZoom();
|
xx /= getZoom();
|
||||||
zz /= getZoom();
|
zz /= getZoom();
|
||||||
|
|
||||||
@ -147,7 +169,7 @@ public class IrisBiomeDecorator
|
|||||||
return getBlockData().get(0);
|
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;
|
return null;
|
||||||
|
@ -21,8 +21,8 @@ import lombok.Data;
|
|||||||
public class IrisBiomePaletteLayer
|
public class IrisBiomePaletteLayer
|
||||||
{
|
{
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The dispersion of materials from the palette")
|
@Desc("The style of noise")
|
||||||
private Dispersion dispersion = Dispersion.SCATTER;
|
private NoiseStyle style = NoiseStyle.STATIC;
|
||||||
|
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@MaxNumber(256)
|
@MaxNumber(256)
|
||||||
@ -39,7 +39,7 @@ public class IrisBiomePaletteLayer
|
|||||||
@MinNumber(0.0001)
|
@MinNumber(0.0001)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
|
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
|
||||||
private double terrainZoom = 5;
|
private double zoom = 5;
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@ArrayType(min = 1, type = String.class)
|
@ArrayType(min = 1, type = String.class)
|
||||||
@ -68,35 +68,15 @@ public class IrisBiomePaletteLayer
|
|||||||
return getBlockData().get(0);
|
return getBlockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dispersion.equals(Dispersion.SCATTER))
|
return getLayerGenerator(rng).fit(getBlockData(), x, y, z);
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getLayerGenerator(RNG rng)
|
public CNG getLayerGenerator(RNG rng)
|
||||||
{
|
{
|
||||||
return layerGenerator.aquire(() ->
|
return layerGenerator.aquire(() ->
|
||||||
{
|
{
|
||||||
CNG layerGenerator = new CNG(rng);
|
|
||||||
RNG rngx = rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size());
|
RNG rngx = rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size());
|
||||||
|
return style.create(rngx);
|
||||||
switch(dispersion)
|
|
||||||
{
|
|
||||||
case SCATTER:
|
|
||||||
layerGenerator = CNG.signature(rngx).freq(1000000);
|
|
||||||
break;
|
|
||||||
case WISPY:
|
|
||||||
layerGenerator = CNG.signature(rngx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return layerGenerator;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Desc("Represents a dimension")
|
@Desc("Represents a dimension")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@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 STONE = Material.STONE.createBlockData();
|
||||||
public static final BlockData WATER = Material.WATER.createBlockData();
|
public static final BlockData WATER = Material.WATER.createBlockData();
|
||||||
|
|
||||||
@ -238,8 +237,12 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The dispersion of materials for the rock palette")
|
@Desc("The noise style for rock types")
|
||||||
private Dispersion rockDispersion = Dispersion.SCATTER;
|
private NoiseStyle rockStyle = NoiseStyle.STATIC;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The noise style for fluid types")
|
||||||
|
private NoiseStyle fluidStyle = NoiseStyle.STATIC;
|
||||||
|
|
||||||
@MinNumber(0.0001)
|
@MinNumber(0.0001)
|
||||||
@MaxNumber(512)
|
@MaxNumber(512)
|
||||||
@ -274,33 +277,29 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
private transient AtomicCache<Double> rad = new AtomicCache<>();
|
private transient AtomicCache<Double> rad = new AtomicCache<>();
|
||||||
private transient boolean inverted = false;
|
private transient boolean inverted = false;
|
||||||
|
|
||||||
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g)
|
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g) {
|
||||||
{
|
return cacheFilters.aquire(() -> {
|
||||||
return cacheFilters.aquire(() ->
|
|
||||||
{
|
|
||||||
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
|
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
|
||||||
|
|
||||||
for(IrisPostProcessor i : getPostProcessors())
|
for (IrisPostProcessor i : getPostProcessors()) {
|
||||||
{
|
|
||||||
cacheFilters.add(g.createProcessor(i.getProcessor(), i.getPhase()));
|
cacheFilters.add(g.createProcessor(i.getProcessor(), i.getPhase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setMinPhase(0);
|
g.setMinPhase(0);
|
||||||
g.setMaxPhase(0);
|
g.setMaxPhase(0);
|
||||||
|
|
||||||
for(IrisPostBlockFilter i : cacheFilters)
|
for (IrisPostBlockFilter i : cacheFilters) {
|
||||||
{
|
|
||||||
g.setMinPhase(Math.min(g.getMinPhase(), i.getPhase()));
|
g.setMinPhase(Math.min(g.getMinPhase(), i.getPhase()));
|
||||||
g.setMaxPhase(Math.max(g.getMaxPhase(), 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;
|
return cacheFilters;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KList<IrisCompatabilityFilter> getDefaultCompatability()
|
public static KList<IrisCompatabilityFilter> getDefaultCompatability() {
|
||||||
{
|
|
||||||
KList<IrisCompatabilityFilter> filters = new KList<>();
|
KList<IrisCompatabilityFilter> filters = new KList<>();
|
||||||
|
|
||||||
// Below 1.16
|
// Below 1.16
|
||||||
@ -439,18 +438,15 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getCoordFracture(RNG rng, int signature)
|
public CNG getCoordFracture(RNG rng, int signature) {
|
||||||
{
|
return coordFracture.aquire(() -> {
|
||||||
return coordFracture.aquire(() ->
|
|
||||||
{
|
|
||||||
CNG coordFracture = CNG.signature(rng.nextParallelRNG(signature));
|
CNG coordFracture = CNG.signature(rng.nextParallelRNG(signature));
|
||||||
coordFracture.scale(0.012 / coordFractureZoom);
|
coordFracture.scale(0.012 / coordFractureZoom);
|
||||||
return coordFracture;
|
return coordFracture;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private KList<IrisPostProcessor> getDefaultPostProcessors()
|
private KList<IrisPostProcessor> getDefaultPostProcessors() {
|
||||||
{
|
|
||||||
KList<IrisPostProcessor> p = new KList<IrisPostProcessor>();
|
KList<IrisPostProcessor> p = new KList<IrisPostProcessor>();
|
||||||
|
|
||||||
p.add(new IrisPostProcessor("wall-painter"));
|
p.add(new IrisPostProcessor("wall-painter"));
|
||||||
@ -460,59 +456,32 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getRock(RNG rng, double x, double y, double z)
|
public BlockData getRock(RNG rng, double x, double y, double z) {
|
||||||
{
|
if (getRockData().isEmpty()) {
|
||||||
if(getRockData().isEmpty())
|
|
||||||
{
|
|
||||||
return STONE;
|
return STONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getRockData().size() == 1)
|
if (getRockData().size() == 1) {
|
||||||
{
|
|
||||||
return getRockData().get(0);
|
return getRockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rockDispersion.equals(Dispersion.SCATTER))
|
return getRockGenerator(rng).fit(getRockData(), x, y, z);
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getRockGenerator(RNG rng)
|
public CNG getRockGenerator(RNG rng) {
|
||||||
{
|
return rockLayerGenerator.aquire(() -> {
|
||||||
return rockLayerGenerator.aquire(() ->
|
RNG rngx = rng.nextParallelRNG(
|
||||||
{
|
(int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||||
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
return rockStyle.create(rngx);
|
||||||
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 KList<BlockData> getRockData()
|
public KList<BlockData> getRockData() {
|
||||||
{
|
return rockData.aquire(() -> {
|
||||||
return rockData.aquire(() ->
|
|
||||||
{
|
|
||||||
KList<BlockData> rockData = new KList<>();
|
KList<BlockData> rockData = new KList<>();
|
||||||
for(String ix : rockPalette)
|
for (String ix : rockPalette) {
|
||||||
{
|
|
||||||
BlockData bx = B.getBlockData(ix);
|
BlockData bx = B.getBlockData(ix);
|
||||||
if(bx != null)
|
if (bx != null) {
|
||||||
{
|
|
||||||
rockData.add(bx);
|
rockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -521,59 +490,32 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getFluid(RNG rng, double x, double y, double z)
|
public BlockData getFluid(RNG rng, double x, double y, double z) {
|
||||||
{
|
if (getFluidData().isEmpty()) {
|
||||||
if(getFluidData().isEmpty())
|
|
||||||
{
|
|
||||||
return WATER;
|
return WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getFluidData().size() == 1)
|
if (getFluidData().size() == 1) {
|
||||||
{
|
|
||||||
return getFluidData().get(0);
|
return getFluidData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rockDispersion.equals(Dispersion.SCATTER))
|
return getFluidGenerator(rng).fit(getFluidData(), x, y, z);
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getFluidGenerator(RNG rng)
|
public CNG getFluidGenerator(RNG rng) {
|
||||||
{
|
return fluidLayerGenerator.aquire(() -> {
|
||||||
return fluidLayerGenerator.aquire(() ->
|
RNG rngx = rng.nextParallelRNG(getFluidData().size()
|
||||||
{
|
* (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||||
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
return fluidStyle.create(rngx);
|
||||||
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 KList<BlockData> getFluidData()
|
public KList<BlockData> getFluidData() {
|
||||||
{
|
return fluidData.aquire(() -> {
|
||||||
return fluidData.aquire(() ->
|
|
||||||
{
|
|
||||||
KList<BlockData> fluidData = new KList<>();
|
KList<BlockData> fluidData = new KList<>();
|
||||||
for(String ix : fluidPalette)
|
for (String ix : fluidPalette) {
|
||||||
{
|
|
||||||
BlockData bx = B.getBlockData(ix);
|
BlockData bx = B.getBlockData(ix);
|
||||||
if(bx != null)
|
if (bx != null) {
|
||||||
{
|
|
||||||
fluidData.add(bx);
|
fluidData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -582,49 +524,40 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDimensionAngle()
|
public double getDimensionAngle() {
|
||||||
{
|
|
||||||
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
|
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double sinRotate()
|
public double sinRotate() {
|
||||||
{
|
|
||||||
return sinr.aquire(() -> Math.sin(getDimensionAngle()));
|
return sinr.aquire(() -> Math.sin(getDimensionAngle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double cosRotate()
|
public double cosRotate() {
|
||||||
{
|
|
||||||
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
|
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g)
|
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g) {
|
||||||
{
|
|
||||||
KList<IrisRegion> r = new KList<>();
|
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));
|
r.add(g != null ? g.loadRegion(i) : Iris.globaldata.getRegionLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g)
|
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g) {
|
||||||
{
|
|
||||||
KList<IrisBiome> r = new KList<>();
|
KList<IrisBiome> r = new KList<>();
|
||||||
|
|
||||||
for(IrisRegion i : getAllRegions(g))
|
for (IrisRegion i : getAllRegions(g)) {
|
||||||
{
|
|
||||||
r.addAll(i.getAllBiomes(g));
|
r.addAll(i.getAllBiomes(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkPosition getParallaxSize(ContextualChunkGenerator g)
|
public ChunkPosition getParallaxSize(ContextualChunkGenerator g) {
|
||||||
{
|
return parallaxSize.aquire(() -> {
|
||||||
return parallaxSize.aquire(() ->
|
|
||||||
{
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
|
||||||
@ -632,50 +565,40 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
KList<IrisRegion> r = getAllRegions(g);
|
KList<IrisRegion> r = getAllRegions(g);
|
||||||
KList<IrisBiome> b = getAllBiomes(g);
|
KList<IrisBiome> b = getAllBiomes(g);
|
||||||
|
|
||||||
for(IrisBiome i : b)
|
for (IrisBiome i : b) {
|
||||||
{
|
for (IrisObjectPlacement j : i.getObjects()) {
|
||||||
for(IrisObjectPlacement j : i.getObjects())
|
|
||||||
{
|
|
||||||
objects.addAll(j.getPlace());
|
objects.addAll(j.getPlace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String i : objects)
|
for (String i : objects) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
|
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
|
||||||
x = bv.getBlockX() > x ? bv.getBlockX() : x;
|
x = bv.getBlockX() > x ? bv.getBlockX() : x;
|
||||||
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
|
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();
|
int max = i.getMaxDimension();
|
||||||
x = max > x ? max : x;
|
x = max > x ? max : x;
|
||||||
z = max > z ? max : z;
|
z = max > z ? max : z;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisRegion v : r)
|
for (IrisRegion v : r) {
|
||||||
{
|
for (IrisDepositGenerator i : v.getDeposits()) {
|
||||||
for(IrisDepositGenerator i : v.getDeposits())
|
|
||||||
{
|
|
||||||
int max = i.getMaxDimension();
|
int max = i.getMaxDimension();
|
||||||
x = max > x ? max : x;
|
x = max > x ? max : x;
|
||||||
z = max > z ? max : z;
|
z = max > z ? max : z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisBiome v : b)
|
for (IrisBiome v : b) {
|
||||||
{
|
for (IrisDepositGenerator i : v.getDeposits()) {
|
||||||
for(IrisDepositGenerator i : v.getDeposits())
|
|
||||||
{
|
|
||||||
int max = i.getMaxDimension();
|
int max = i.getMaxDimension();
|
||||||
x = max > x ? max : x;
|
x = max > x ? max : x;
|
||||||
z = max > z ? max : z;
|
z = max > z ? max : z;
|
||||||
@ -691,12 +614,9 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData resolve(String bd)
|
public BlockData resolve(String bd) {
|
||||||
{
|
for (IrisCompatabilityFilter i : getCompatability()) {
|
||||||
for(IrisCompatabilityFilter i : getCompatability())
|
if (i.getWhen().equalsIgnoreCase(bd)) {
|
||||||
{
|
|
||||||
if(i.getWhen().equalsIgnoreCase(bd))
|
|
||||||
{
|
|
||||||
return i.getReplace();
|
return i.getReplace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ public class IrisNoiseGenerator
|
|||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("If this generator uses the default iris swirly/wispy noise generator. Set to false for pure simplex.")
|
@Desc("The Noise Style")
|
||||||
private boolean irisBased = true;
|
private NoiseStyle style = NoiseStyle.IRIS;
|
||||||
|
|
||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -97,7 +97,7 @@ public class IrisNoiseGenerator
|
|||||||
|
|
||||||
protected CNG getGenerator(long superSeed)
|
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()
|
public double getMax()
|
||||||
|
103
src/main/java/com/volmit/iris/object/NoiseStyle.java
Normal file
103
src/main/java/com/volmit/iris/object/NoiseStyle.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user