mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 11:09:06 +00:00
normalize
This commit is contained in:
@@ -34,16 +34,21 @@ public class CNG {
|
||||
private double down;
|
||||
private double power;
|
||||
|
||||
public NoiseGenerator getGen()
|
||||
{
|
||||
return generator;
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng) {
|
||||
return signature(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng, NoiseType t) {
|
||||
// @builder
|
||||
return new CNG(rng.nextParallelRNG(17), t, 1D, 3).scale(0.012)
|
||||
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, 2).scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 2).scale(0.15), 24), 44)
|
||||
.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);
|
||||
// @done
|
||||
}
|
||||
@@ -68,6 +73,8 @@ public class CNG {
|
||||
scale = 1;
|
||||
patch = 1;
|
||||
fscale = 1;
|
||||
down = 0;
|
||||
up = 0;
|
||||
fracture = null;
|
||||
generator = t.create(random.nextParallelRNG(33).lmax());
|
||||
this.opacity = opacity;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
public class CellHeightNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
|
||||
@@ -11,7 +13,7 @@ public class CellHeightNoise implements NoiseGenerator {
|
||||
}
|
||||
|
||||
private double filter(double noise) {
|
||||
return (noise / 2D) + 0.5D;
|
||||
return M.clip((noise / 2D) + 0.5D, 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,75 +1,43 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class SimplexNoise implements NoiseGenerator, OctaveNoise {
|
||||
private final OpenSimplex n;
|
||||
private final SNG n;
|
||||
private int octaves;
|
||||
|
||||
public SimplexNoise(long seed) {
|
||||
this.n = new OpenSimplex(seed);
|
||||
this.n = new SNG(new RNG(seed));
|
||||
octaves = 1;
|
||||
}
|
||||
|
||||
public double f(double v) {
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
if (octaves <= 1) {
|
||||
return (n.noise2_XBeforeY(x, 0) / 2D) + 0.5D;
|
||||
return f(n.noise(x));
|
||||
}
|
||||
|
||||
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;
|
||||
return f(n.noise(x, octaves, 1D, 1D, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
if (octaves <= 1) {
|
||||
return (n.noise2(x, z) / 2D) + 0.5D;
|
||||
return f(n.noise(x, z));
|
||||
}
|
||||
|
||||
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;
|
||||
return f(n.noise(x, z, octaves, 1D, 1D, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
if (octaves <= 1) {
|
||||
return (n.noise3_XZBeforeY(x, y, z) / 2D) + 0.5D;
|
||||
return f(n.noise(x, y, z));
|
||||
}
|
||||
|
||||
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;
|
||||
return f(n.noise(x, y, z, octaves, 1D, 1D, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.volmit.iris.noise;
|
||||
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
public class VascularNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
|
||||
@@ -11,7 +13,7 @@ public class VascularNoise implements NoiseGenerator {
|
||||
}
|
||||
|
||||
private double filter(double noise) {
|
||||
return 1D - ((noise / 2D) + 0.5D);
|
||||
return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user