mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 00:06:10 +00:00
Fix noise
This commit is contained in:
@@ -31,6 +31,7 @@ public class CNG
|
||||
private final double opacity;
|
||||
private NoiseInjector injector;
|
||||
private RNG rng;
|
||||
private boolean noscale;
|
||||
private int oct;
|
||||
private double patch;
|
||||
private double up;
|
||||
@@ -124,6 +125,7 @@ public class CNG
|
||||
public CNG(RNG random, NoiseType t, double opacity, int octaves)
|
||||
{
|
||||
creates++;
|
||||
noscale = t.equals(NoiseType.WHITE);
|
||||
this.oct = octaves;
|
||||
this.rng = random;
|
||||
power = 1;
|
||||
@@ -332,8 +334,8 @@ public class CNG
|
||||
|
||||
public double noise(double... dim)
|
||||
{
|
||||
double scale = this.bakedScale * this.scale;
|
||||
double f = (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
|
||||
double scale = noscale ? 1 : this.bakedScale * this.scale;
|
||||
double f = noscale ? 0 : (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;
|
||||
|
||||
@@ -353,21 +353,21 @@ public class FastNoise
|
||||
|
||||
private static double DValCoord2D(int seed, long x, long y)
|
||||
{
|
||||
int n = seed;
|
||||
long n = seed;
|
||||
n ^= X_PRIME_L * x;
|
||||
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)
|
||||
{
|
||||
int n = seed;
|
||||
long n = seed;
|
||||
n ^= X_PRIME_L * x;
|
||||
n ^= Y_PRIME_L * y;
|
||||
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)
|
||||
@@ -628,7 +628,7 @@ public class FastNoise
|
||||
{
|
||||
long i = Double.doubleToRawLongBits(f);
|
||||
|
||||
return i ^ (i >> 16);
|
||||
return i ^ (i >> 32);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private double f(double m)
|
||||
{
|
||||
return m;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user