Skip to content

Commit

Permalink
Preview some of the failed experimental noises.
Browse files Browse the repository at this point in the history
This is how we learn from our mistakes.
  • Loading branch information
tommyettinger committed May 18, 2023
1 parent 89deb88 commit 295837d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
18 changes: 14 additions & 4 deletions squidlib-util/src/main/java/squidpony/squidmath/PyrNoise.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ public static double valueNoise(int seed, double x, double y)
x += ya - 0.5;
ya += ya;
x /= ya;
// Cubic
// x *= x * (3 - 2 * x);
// ya *= ya * (3 - 2 * ya);
x = Noise.extreme(x);
ya = Noise.extreme(ya);

// Quintic
// x = Noise.extreme(x);
// ya = Noise.extreme(ya);

// ya = Math.sqrt(ya);

// ya = (ya - 0.5);
Expand All @@ -97,6 +101,7 @@ public static double valueNoise(int seed, double x, double y)
// + x * (ya * hashPart1024(xFloor + STEPX + STEPX, yFloor, seed) + cc))
// * (0x1.0040100401004p-10);

// ya *= ya;
return (ya * ((1 - x) * hashPart1024(xFloor, yFloor, seed) + x * hashPart1024(xFloor + STEPX + STEPX, yFloor, seed))
+ (1 - ya) * cap) * (0x1.0040100401004p-10);
}
Expand All @@ -108,10 +113,14 @@ public static double valueNoise(int seed, double x, double y)
y += xa - 0.5;
xa += xa;
y /= xa;

// Cubic
// y *= y * (3 - 2 * y);
// xa *= xa * (3 - 2 * xa);
y = Noise.extreme(y);
xa = Noise.extreme(xa);

// Quintic
// y = Noise.extreme(y);
// xa = Noise.extreme(xa);

// xa = Math.sqrt(xa);

Expand All @@ -129,6 +138,7 @@ public static double valueNoise(int seed, double x, double y)
// double cc = (1 - xa) * cap;
// return ((1 - y) * (xa * hashPart1024(xFloor, yFloor, seed) + cc)
// + y * (xa * hashPart1024(xFloor, yFloor + STEPY + STEPY, seed) + cc)) * (0x1.0040100401004p-10);
// xa *= xa;
return (xa * ((1 - y) * hashPart1024(xFloor, yFloor, seed) + y * hashPart1024(xFloor, yFloor + STEPY + STEPY, seed))
+ (1 - xa) * cap) * (0x1.0040100401004p-10);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ public class NoiseVarietyVisualizer extends ApplicationAdapter {
private ValueNoise value = new ValueNoise(1234567890);
private LumpNoise lump = new LumpNoise(1234567890);
private WeavingNoise weave = new WeavingNoise(1234567890);
private PyrNoise pyr = new PyrNoise(1234567890);

private Noise.Noise2D[] noises2 = {weave, foam, simplex, value, classic};
private Noise.Noise3D[] noises3 = {weave, foam, simplex, value, classic};
private Noise.Noise4D[] noises4 = {weave, foam, simplex, value, classic};
private Noise.Noise5D[] noises5 = {weave, foam, simplex, value, classic};
private Noise.Noise6D[] noises6 = {weave, foam, simplex, value, classic};
private Noise.Noise2D[] noises2 = {weave, foam, simplex, value, classic, pyr, octo, lump};
private Noise.Noise3D[] noises3 = {weave, foam, simplex, value, classic, pyr, octo, lump};
private Noise.Noise4D[] noises4 = {weave, foam, simplex, value, classic, pyr, octo, lump};
private Noise.Noise5D[] noises5 = {weave, foam, simplex, value, classic, pyr, octo, lump};
private Noise.Noise6D[] noises6 = {weave, foam, simplex, value, classic, pyr, octo, lump};

// private HashedValueNoise value = new HashedValueNoise(new FlawedPointHash.CubeHash(1234567890, 32));
// private FastNoise value = new FastNoise(1234567890, 1f, FastNoise.VALUE, 1);
private int noiseType = 0; // 0 for classic, 1 for wave, 2 for fast, 3 for experimental
private int noiseType = 5; // 0 for classic, 1 for wave, 2 for fast, 3 for experimental
private int dim = 0; // this can be 0, 1, or 2; add 2 to get the actual dimensions
private int octaves = 0;
private float freq = (float) Math.exp(-4.0);
Expand Down Expand Up @@ -117,12 +118,12 @@ public boolean keyDown(int keycode) {
seed += 0x9E3779B97F4A7C15L;
break;
case MINUS:
noiseType = (noiseType + 4) % 5;
noiseType = (noiseType + 7) % 8;
break;
case N: // noise type
case EQUALS:
case ENTER:
noiseType = (noiseType + 1) % 5;
noiseType = (noiseType + 1) % 8;
break;
case D: //dimension
dim = (dim + 1) % 5;
Expand Down

0 comments on commit 295837d

Please sign in to comment.