mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-10 09:46:03 +00:00
Cleanup
This commit is contained in:
@@ -33,8 +33,6 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
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};
|
||||
@@ -45,6 +43,9 @@ public class CNG {
|
||||
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};
|
||||
public static long hits = 0;
|
||||
public static long creates = 0;
|
||||
private final double opacity;
|
||||
private double scale;
|
||||
private double bakedScale;
|
||||
private double fscale;
|
||||
@@ -52,7 +53,6 @@ public class CNG {
|
||||
private KList<CNG> children;
|
||||
private CNG fracture;
|
||||
private NoiseGenerator generator;
|
||||
private final double opacity;
|
||||
private NoiseInjector injector;
|
||||
private RNG rng;
|
||||
private boolean noscale;
|
||||
@@ -63,16 +63,43 @@ public class CNG {
|
||||
private double power;
|
||||
private ProceduralStream<Double> customGenerator;
|
||||
|
||||
public NoiseGenerator getGen() {
|
||||
return generator;
|
||||
public CNG(RNG random) {
|
||||
this(random, 1);
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream() {
|
||||
return new CNGStream(this);
|
||||
public CNG(RNG random, int octaves) {
|
||||
this(random, 1D, octaves);
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream(double min, double max) {
|
||||
return new FittedStream<>(stream(), min, max);
|
||||
public CNG(RNG random, double opacity, int octaves) {
|
||||
this(random, NoiseType.SIMPLEX, opacity, octaves);
|
||||
}
|
||||
|
||||
public CNG(RNG random, NoiseType type, double opacity, int octaves) {
|
||||
this(random, type.create(random.nextParallelRNG((long) ((1113334944L * opacity) + 12922 + octaves)).lmax()), opacity, octaves);
|
||||
}
|
||||
|
||||
public CNG(RNG random, NoiseGenerator generator, double opacity, int octaves) {
|
||||
customGenerator = null;
|
||||
creates++;
|
||||
noscale = generator.isNoScale();
|
||||
this.oct = octaves;
|
||||
this.rng = random;
|
||||
power = 1;
|
||||
scale = 1;
|
||||
patch = 1;
|
||||
bakedScale = 1;
|
||||
fscale = 1;
|
||||
down = 0;
|
||||
up = 0;
|
||||
fracture = null;
|
||||
this.generator = generator;
|
||||
this.opacity = opacity;
|
||||
this.injector = ADD;
|
||||
|
||||
if (generator instanceof OctaveNoise) {
|
||||
((OctaveNoise) generator).setOctaves(octaves);
|
||||
}
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng) {
|
||||
@@ -95,7 +122,6 @@ public class CNG {
|
||||
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
|
||||
}
|
||||
|
||||
|
||||
public static CNG signatureDoubleFast(RNG rng, NoiseType t, NoiseType f) {
|
||||
return signatureThickFast(rng, t, f)
|
||||
.fractureWith(signatureFast(rng.nextParallelRNG(4956), t, f), 93);
|
||||
@@ -162,43 +188,16 @@ public class CNG {
|
||||
// @done
|
||||
}
|
||||
|
||||
public CNG(RNG random) {
|
||||
this(random, 1);
|
||||
public NoiseGenerator getGen() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public CNG(RNG random, int octaves) {
|
||||
this(random, 1D, octaves);
|
||||
public ProceduralStream<Double> stream() {
|
||||
return new CNGStream(this);
|
||||
}
|
||||
|
||||
public CNG(RNG random, double opacity, int octaves) {
|
||||
this(random, NoiseType.SIMPLEX, opacity, octaves);
|
||||
}
|
||||
|
||||
public CNG(RNG random, NoiseType type, double opacity, int octaves) {
|
||||
this(random, type.create(random.nextParallelRNG((long) ((1113334944L * opacity) + 12922 + octaves)).lmax()), opacity, octaves);
|
||||
}
|
||||
|
||||
public CNG(RNG random, NoiseGenerator generator, double opacity, int octaves) {
|
||||
customGenerator = null;
|
||||
creates++;
|
||||
noscale = generator.isNoScale();
|
||||
this.oct = octaves;
|
||||
this.rng = random;
|
||||
power = 1;
|
||||
scale = 1;
|
||||
patch = 1;
|
||||
bakedScale = 1;
|
||||
fscale = 1;
|
||||
down = 0;
|
||||
up = 0;
|
||||
fracture = null;
|
||||
this.generator = generator;
|
||||
this.opacity = opacity;
|
||||
this.injector = ADD;
|
||||
|
||||
if (generator instanceof OctaveNoise) {
|
||||
((OctaveNoise) generator).setOctaves(octaves);
|
||||
}
|
||||
public ProceduralStream<Double> stream(double min, double max) {
|
||||
return new FittedStream<>(stream(), min, max);
|
||||
}
|
||||
|
||||
public CNG bake() {
|
||||
|
||||
@@ -50,6 +50,11 @@ public class CloverNoise implements NoiseGenerator {
|
||||
* Java implementation of 2D Clover Noise. See https://github.com/ValgoBoi/clover-noise
|
||||
*/
|
||||
public static class Noise2D {
|
||||
private static final long HASH_A = 25214903917L;
|
||||
private static final long HASH_C = 11L;
|
||||
private static final long HASH_M = 0x1000000000000L;
|
||||
private static final double POINT_SPREAD = 0.3;
|
||||
private static final double CURL_DX = 0.0001;
|
||||
private final long seed;
|
||||
|
||||
/**
|
||||
@@ -68,10 +73,6 @@ public class CloverNoise implements NoiseGenerator {
|
||||
this(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private static final long HASH_A = 25214903917L;
|
||||
private static final long HASH_C = 11L;
|
||||
private static final long HASH_M = 0x1000000000000L;
|
||||
|
||||
private long doHash(long input, long seed) {
|
||||
input += seed;
|
||||
|
||||
@@ -97,8 +98,6 @@ public class CloverNoise implements NoiseGenerator {
|
||||
return (double) hash / HASH_M;
|
||||
}
|
||||
|
||||
private static final double POINT_SPREAD = 0.3;
|
||||
|
||||
private Vector2 offset(Vector2 position) {
|
||||
double hash = hash(position);
|
||||
double scale = Math.floor(hash * 50 + 1) / 100;
|
||||
@@ -248,8 +247,6 @@ public class CloverNoise implements NoiseGenerator {
|
||||
return fractalNoise(new Vector2(x, y), iterations);
|
||||
}
|
||||
|
||||
private static final double CURL_DX = 0.0001;
|
||||
|
||||
/**
|
||||
* Generates curl 2D Clover Noise at a specific point.
|
||||
*
|
||||
@@ -366,6 +363,11 @@ public class CloverNoise implements NoiseGenerator {
|
||||
}
|
||||
|
||||
public static class Noise3D {
|
||||
private static final long HASH_A = 25214903917L;
|
||||
private static final long HASH_C = 11L;
|
||||
private static final long HASH_M = 0x1000000000000L;
|
||||
private static final double POINT_SPREAD = 0.2;
|
||||
private static final double CURL_DX = 0.0001;
|
||||
private final long seed;
|
||||
|
||||
public Noise3D(long seed) {
|
||||
@@ -376,10 +378,6 @@ public class CloverNoise implements NoiseGenerator {
|
||||
this(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private static final long HASH_A = 25214903917L;
|
||||
private static final long HASH_C = 11L;
|
||||
private static final long HASH_M = 0x1000000000000L;
|
||||
|
||||
private long doHash(long input, long seed) {
|
||||
input += seed;
|
||||
|
||||
@@ -406,8 +404,6 @@ public class CloverNoise implements NoiseGenerator {
|
||||
return (double) hash / HASH_M;
|
||||
}
|
||||
|
||||
private static final double POINT_SPREAD = 0.2;
|
||||
|
||||
private Vector3 offset(Vector3 position) {
|
||||
double hash = hash(position);
|
||||
double theta = hash * Math.PI * 2000;
|
||||
@@ -720,8 +716,6 @@ public class CloverNoise implements NoiseGenerator {
|
||||
return fractalNoise(new Vector3(x, y, z), iterations);
|
||||
}
|
||||
|
||||
private static final double CURL_DX = 0.0001;
|
||||
|
||||
/**
|
||||
* Generates curl 3D Clover Noise at a specific point.
|
||||
*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user