mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-17 13:49:59 +00:00
NV
This commit is contained in:
@@ -34,22 +34,58 @@ public class CNG {
|
||||
private double down;
|
||||
private double power;
|
||||
|
||||
public NoiseGenerator getGen()
|
||||
{
|
||||
public NoiseGenerator getGen() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
|
||||
public static CNG signature(RNG rng) {
|
||||
return signature(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureHalf(RNG rng) {
|
||||
return signatureHalf(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureThick(RNG rng) {
|
||||
return signatureThick(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureDouble(RNG rng) {
|
||||
return signatureDouble(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureDouble(RNG rng, NoiseType t) {
|
||||
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng, NoiseType t) {
|
||||
// @builder
|
||||
return new CNG(rng.nextParallelRNG(17), t, 1D, 1).scale(0.012)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 2).scale(0.018)
|
||||
.child(new CNG(rng.nextParallelRNG(19), 1, 1).scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.15), 24), 44)
|
||||
.down(0.3).patch(2.5);
|
||||
return new CNG(rng.nextParallelRNG(17), t, 1D, 1)
|
||||
.fractureWith(
|
||||
new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 620), 145),
|
||||
44);
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureThick(RNG rng, NoiseType t) {
|
||||
// @builder
|
||||
return new CNG(rng.nextParallelRNG(133), t, 1D, 1)
|
||||
.fractureWith(
|
||||
new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.5)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.11)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.4), 620), 145),
|
||||
44);
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureHalf(RNG rng, NoiseType t) {
|
||||
// @builder
|
||||
return new CNG(rng.nextParallelRNG(127), t, 1D, 1).fractureWith(
|
||||
new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1)
|
||||
.scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 420), 99),
|
||||
22);
|
||||
// @done
|
||||
}
|
||||
|
||||
|
||||
28
src/main/java/com/volmit/iris/noise/CubicNoise.java
Normal file
28
src/main/java/com/volmit/iris/noise/CubicNoise.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
public class CubicNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
|
||||
public CubicNoise(long seed) {
|
||||
this.n = new FastNoise((int) seed);
|
||||
}
|
||||
|
||||
private double f(double n) {
|
||||
return (n / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return f(n.GetCubic((float) x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetCubic((float) x, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return f(n.GetCubic((float) x, (float) y, (float) z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.noise.FastNoise.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoise n;
|
||||
|
||||
public FractalBillowSimplexNoise(long seed) {
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
n.SetFractalOctaves(1);
|
||||
n.SetFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return f(n.GetSimplexFractal((float) x, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetSimplexFractal((float) x, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return f(n.GetSimplexFractal((float) x, (float) y, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o) {
|
||||
n.SetFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.noise.FastNoise.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoise n;
|
||||
|
||||
public FractalFBMSimplexNoise(long seed) {
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
n.SetFractalOctaves(1);
|
||||
n.SetFractalType(FractalType.FBM);
|
||||
}
|
||||
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return f(n.GetSimplexFractal((float) x, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetSimplexFractal((float) x, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return f(n.GetSimplexFractal((float) x, (float) y, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o) {
|
||||
n.SetFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.noise.FastNoise.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final FastNoise n;
|
||||
|
||||
public FractalRigidMultiSimplexNoise(long seed) {
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
n.SetFractalOctaves(1);
|
||||
n.SetFractalType(FractalType.RigidMulti);
|
||||
}
|
||||
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return f(n.GetSimplexFractal((float) x, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetSimplexFractal((float) x, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return f(n.GetSimplexFractal((float) x, (float) y, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o) {
|
||||
n.SetFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/volmit/iris/noise/GlobNoise.java
Normal file
32
src/main/java/com/volmit/iris/noise/GlobNoise.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
public class GlobNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
|
||||
public GlobNoise(long seed) {
|
||||
this.n = new FastNoise((int) seed);
|
||||
n.SetNoiseType(FastNoise.NoiseType.Cellular);
|
||||
n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Div);
|
||||
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
return n+1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return f(n.GetCellular((float) x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return f(n.GetCellular((float) x, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return f(n.GetCellular((float) x, (float) y, (float) z));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
public enum NoiseType {
|
||||
WHITE(seed -> new WhiteNoise(seed)),
|
||||
WHITE(seed -> new WhiteNoise(seed)),
|
||||
SIMPLEX(seed -> new SimplexNoise(seed)),
|
||||
CELLULAR(seed -> new CellularNoise(seed)),
|
||||
FRACTAL_BILLOW_SIMPLEX(seed -> new FractalBillowSimplexNoise(seed)),
|
||||
FRACTAL_FBM_SIMPLEX(seed -> new FractalFBMSimplexNoise(seed)),
|
||||
FRACTAL_RIGID_MULTI_SIMPLEX(seed -> new FractalRigidMultiSimplexNoise(seed)),
|
||||
CELLULAR(seed -> new CellularNoise(seed)),
|
||||
GLOB(seed -> new GlobNoise(seed)),
|
||||
CUBIC(seed -> new CubicNoise(seed)),
|
||||
CELLULAR_HEIGHT(seed -> new CellHeightNoise(seed)),
|
||||
VASCULAR(seed -> new VascularNoise(seed));
|
||||
|
||||
@@ -12,9 +17,8 @@ public enum NoiseType {
|
||||
private NoiseType(NoiseFactory f) {
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public NoiseGenerator create(long seed)
|
||||
{
|
||||
|
||||
public NoiseGenerator create(long seed) {
|
||||
return f.create(seed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.object.NoiseStyle;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class Research {
|
||||
|
||||
public static void main(String[] args) {
|
||||
CNG cng = NoiseStyle.VIGOCTAVE_SIMPLEX.create(new RNG(RNG.r.nextLong()));
|
||||
|
||||
double max = -1;
|
||||
double min = 2;
|
||||
|
||||
for (int i = 0; i < 999999; i++) {
|
||||
double n = cng.noise(i, i * 2, i * 4);
|
||||
|
||||
if (n < min) {
|
||||
min = n;
|
||||
}
|
||||
|
||||
if (n > max) {
|
||||
max = n;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(min + " - " + max);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user