mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Fix noise
This commit is contained in:
parent
bb7e277f19
commit
6153b25bc7
@ -31,6 +31,7 @@ public class CNG
|
|||||||
private final double opacity;
|
private final double opacity;
|
||||||
private NoiseInjector injector;
|
private NoiseInjector injector;
|
||||||
private RNG rng;
|
private RNG rng;
|
||||||
|
private boolean noscale;
|
||||||
private int oct;
|
private int oct;
|
||||||
private double patch;
|
private double patch;
|
||||||
private double up;
|
private double up;
|
||||||
@ -124,6 +125,7 @@ public class CNG
|
|||||||
public CNG(RNG random, NoiseType t, double opacity, int octaves)
|
public CNG(RNG random, NoiseType t, double opacity, int octaves)
|
||||||
{
|
{
|
||||||
creates++;
|
creates++;
|
||||||
|
noscale = t.equals(NoiseType.WHITE);
|
||||||
this.oct = octaves;
|
this.oct = octaves;
|
||||||
this.rng = random;
|
this.rng = random;
|
||||||
power = 1;
|
power = 1;
|
||||||
@ -332,8 +334,8 @@ public class CNG
|
|||||||
|
|
||||||
public double noise(double... dim)
|
public double noise(double... dim)
|
||||||
{
|
{
|
||||||
double scale = this.bakedScale * this.scale;
|
double scale = noscale ? 1 : this.bakedScale * this.scale;
|
||||||
double f = (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
|
double f = noscale ? 0 : (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;
|
||||||
|
@ -353,21 +353,21 @@ public class FastNoise
|
|||||||
|
|
||||||
private static double DValCoord2D(int seed, long x, long y)
|
private static double DValCoord2D(int seed, long x, long y)
|
||||||
{
|
{
|
||||||
int n = seed;
|
long n = seed;
|
||||||
n ^= X_PRIME_L * x;
|
n ^= X_PRIME_L * x;
|
||||||
n ^= Y_PRIME_L * y;
|
n ^= Y_PRIME_L * y;
|
||||||
|
|
||||||
return ((n * n * n * 604930000L) / 21474836480000D) % 2D;
|
return ((n * n * n * 60493L) / (double) Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double DValCoord3D(int seed, long x, long y, long z)
|
private static double DValCoord3D(int seed, long x, long y, long z)
|
||||||
{
|
{
|
||||||
int n = seed;
|
long n = seed;
|
||||||
n ^= X_PRIME_L * x;
|
n ^= X_PRIME_L * x;
|
||||||
n ^= Y_PRIME_L * y;
|
n ^= Y_PRIME_L * y;
|
||||||
n ^= Z_PRIME_L * z;
|
n ^= Z_PRIME_L * z;
|
||||||
|
|
||||||
return ((n * n * n * 604930000L) / 21474836480000D) % 2D;
|
return ((n * n * n * 60493L) / (double) Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float ValCoord3D(int seed, int x, int y, int z)
|
private static float ValCoord3D(int seed, int x, int y, int z)
|
||||||
@ -628,7 +628,7 @@ public class FastNoise
|
|||||||
{
|
{
|
||||||
long i = Double.doubleToRawLongBits(f);
|
long i = Double.doubleToRawLongBits(f);
|
||||||
|
|
||||||
return i ^ (i >> 16);
|
return i ^ (i >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetWhiteNoise(float x, float y, float z, float w)
|
public float GetWhiteNoise(float x, float y, float z, float w)
|
||||||
|
@ -9,21 +9,26 @@ public class WhiteNoise implements NoiseGenerator
|
|||||||
n = new FastNoise((int) seed);
|
n = new FastNoise((int) seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double f(double m)
|
||||||
|
{
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double noise(double x)
|
public double noise(double x)
|
||||||
{
|
{
|
||||||
return (n.GetWhiteNoise(Float.intBitsToFloat((int) Double.doubleToLongBits(x / 1000d)) % 1000000F, 0) / 2D) + 0.5D;
|
return (n.DGetWhiteNoise(f(x), 0d) / 2D) + 0.5D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double noise(double x, double z)
|
public double noise(double x, double z)
|
||||||
{
|
{
|
||||||
return (n.GetWhiteNoise(Float.intBitsToFloat((int) Double.doubleToLongBits(x / 1000d)) % 1000000F, Float.intBitsToFloat((int) Double.doubleToLongBits(z / 1000d)) % 1000000F) / 2D) + 0.5D;
|
return (n.DGetWhiteNoise(f(x), f(z)) / 2D) + 0.5D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double noise(double x, double y, double z)
|
public double noise(double x, double y, double z)
|
||||||
{
|
{
|
||||||
return (n.GetWhiteNoise(Float.intBitsToFloat((int) Double.doubleToLongBits(x / 1000d)) % 1000000F, Float.intBitsToFloat((int) Double.doubleToLongBits(y / 1000d)) % 1000000F, Float.intBitsToFloat((int) Double.doubleToLongBits(z / 1000d)) % 1000000F) / 2D) + 0.5D;
|
return (n.DGetWhiteNoise(f(x), f(y), f(z)) / 2D) + 0.5D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,12 @@ import com.volmit.iris.util.RNG;
|
|||||||
|
|
||||||
@Desc("Styles of noise")
|
@Desc("Styles of noise")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
public enum NoiseStyle {
|
public enum NoiseStyle
|
||||||
|
{
|
||||||
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
|
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
STATIC(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1)),
|
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.")
|
@Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
IRIS(rng -> CNG.signature(rng).scale(1)),
|
IRIS(rng -> CNG.signature(rng).scale(1)),
|
||||||
@ -44,9 +37,7 @@ public enum NoiseStyle {
|
|||||||
|
|
||||||
@Desc("Very Detailed smoke using simplex fractured with fractal billow simplex at high octaves.")
|
@Desc("Very Detailed smoke using simplex fractured with fractal billow simplex at high octaves.")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
FRACTAL_SMOKE(rng -> new CNG(rng, 1D, 1)
|
FRACTAL_SMOKE(rng -> new CNG(rng, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 8).scale(0.2), 1000).scale(0.34)),
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 8).scale(0.2), 1000)
|
|
||||||
.scale(0.34)),
|
|
||||||
|
|
||||||
@Desc("Thinner Veins.")
|
@Desc("Thinner Veins.")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -54,19 +45,15 @@ public enum NoiseStyle {
|
|||||||
|
|
||||||
@Desc("Cells of simplex noise")
|
@Desc("Cells of simplex noise")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
SIMPLEX_CELLS(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1)
|
SIMPLEX_CELLS(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1).fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.CELLULAR, 1D, 1).scale(1), 200)),
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.CELLULAR, 1D, 1).scale(1), 200)),
|
|
||||||
|
|
||||||
@Desc("Veins of simplex noise")
|
@Desc("Veins of simplex noise")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
SIMPLEX_VASCULAR(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1)
|
SIMPLEX_VASCULAR(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1).fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.VASCULAR, 1D, 1).scale(1), 200)),
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.VASCULAR, 1D, 1).scale(1), 200)),
|
|
||||||
|
|
||||||
@Desc("Very Detailed fluid using simplex fractured with fractal billow simplex at high octaves.")
|
@Desc("Very Detailed fluid using simplex fractured with fractal billow simplex at high octaves.")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
FRACTAL_WATER(rng -> new CNG(rng, 1D, 1)
|
FRACTAL_WATER(rng -> new CNG(rng, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 9).scale(0.03), 9900).scale(1.14)),
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 9).scale(0.03), 9900)
|
|
||||||
.scale(1.14)),
|
|
||||||
|
|
||||||
@Desc("Perlin. Like simplex but more natural")
|
@Desc("Perlin. Like simplex but more natural")
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -413,17 +400,21 @@ public enum NoiseStyle {
|
|||||||
VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)),
|
VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private CNGFactory f;
|
private CNGFactory f;
|
||||||
|
|
||||||
private NoiseStyle(CNGFactory f) {
|
private NoiseStyle(CNGFactory f)
|
||||||
|
{
|
||||||
this.f = f;
|
this.f = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG create(RNG seed) {
|
public CNG create(RNG seed)
|
||||||
|
{
|
||||||
return f.create(seed).bake();
|
return f.create(seed).bake();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisGeneratorStyle style() {
|
public IrisGeneratorStyle style()
|
||||||
|
{
|
||||||
return new IrisGeneratorStyle(this);
|
return new IrisGeneratorStyle(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user