Stop fractured noise from mirroring across x = z

- Read each composite fracture axis from its own reseeded generator at unswapped coordinates in IrisNoiseGenerator and the batched NoiseLayerProgram
- Read the datapack exporter's z warps at unswapped coordinates
- Add a mirror test for the composite fracture and move the fracture test reference to per-axis seeds
- Retake NoiseSeedCohesionTest (Linux/Windows digest), IrisCaveCarver3DCellKernelTest PACK_SHARED and three IrisMathNoiseHotPathParityTest values
This commit is contained in:
piexel committed 2026-11-14 17:32:08 +01:00
1 parent 832070cd69
commit ed44db5497
8 files changed
+197 -133

No files matched your search

@@ -85,7 +85,7 @@ public class IrisCaveCarver3DCellKernelTest {
@Test
public void packStyleProfilesSharingFieldsMatchGoldenWriteSequence() throws Exception {
assertScenario(Scenario.PACK_SHARED, 0xdbe20a1ca87f9cc7L, 269035);
assertScenario(Scenario.PACK_SHARED, 0xb464b50d050e766dL, 288720);
}
@Test
@@ -0,0 +1,68 @@
package art.arcane.iris.generation.noise;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.noise.NoiseGenerator;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public final class IrisNoiseGeneratorFractureMirrorTest {
private static final long SEED = 71L;
private static final int GRID_SIZE = 40;
private static final double GRID_STEP = 7.3D;
private static final double MIRRORED = 1.0E-12D;
private static final int ALLOWED_MIRRORED_SAMPLES = 2;
@Test
public void aCompositeFractureIsNotMirroredAcrossTheDiagonal() {
IrisNoiseGenerator fractured = diagonalSymmetricRoot().setFracture(new KList<>(fracture()));
assertTrue(mirroredSamples(fractured) <= ALLOWED_MIRRORED_SAMPLES);
}
@Test
public void theDiagonalSymmetricRootIsMirroredWithoutAFracture() {
assertTrue(mirroredSamples(diagonalSymmetricRoot()) > ALLOWED_MIRRORED_SAMPLES);
}
private static int mirroredSamples(IrisNoiseGenerator noise) {
int mirroredSamples = 0;
for (int i = 0; i < GRID_SIZE; i++) {
for (int j = i + 1; j < GRID_SIZE; j++) {
double a = i * GRID_STEP;
double b = j * GRID_STEP + 0.5D;
if (Math.abs(noise.getNoise(SEED, a, b, null) - noise.getNoise(SEED, b, a, null)) < MIRRORED) {
mirroredSamples++;
}
}
}
return mirroredSamples;
}
private static IrisNoiseGenerator diagonalSymmetricRoot() {
IrisNoiseGenerator root = new IrisNoiseGenerator().setStyle(NoiseStyle.SIMPLEX.style()).setSeed(5L);
root.getGenerator(SEED, null, null).setGenerator(new DiagonalSymmetricGenerator());
return root;
}
private static IrisNoiseGenerator fracture() {
return new IrisNoiseGenerator().setStyle(NoiseStyle.SIMPLEX.style()).setSeed(9L).setZoom(40D).setOpacity(40D);
}
private static final class DiagonalSymmetricGenerator implements NoiseGenerator {
@Override
public double noise(double x) {
return noise(x, 0D, 0D);
}
@Override
public double noise(double x, double z) {
return noise(x, z, 0D);
}
@Override
public double noise(double x, double y, double z) {
return 0.5D + (Math.sin(x * 0.11D) + Math.sin(y * 0.11D) + Math.sin(z * 0.11D)) / 6D;
}
}
}
@@ -225,6 +225,11 @@ public final class IrisNoiseGeneratorFractureTest {
private static double reference(IrisNoiseGenerator node, long superSeed, double xv, double zv,
IrisData data, Engine engine) {
return reference(node, superSeed, xv, zv, data, engine, IrisNoiseGenerator.X_AXIS);
}
private static double reference(IrisNoiseGenerator node, long superSeed, double xv, double zv,
IrisData data, Engine engine, int axis) {
if (!node.isEnabled()) {
return node.getOffsetY();
}
@@ -234,14 +239,16 @@ public final class IrisNoiseGeneratorFractureTest {
for (IrisNoiseGenerator child : node.getFracture()) {
if (child.isEnabled()) {
double offset = child.getOpacity() / 2D;
x += reference(child, superSeed + node.getSeed() + salt, xv, zv, data, engine) - offset;
z += reference(child, superSeed + node.getSeed() + salt, zv, xv, data, engine) - offset;
long childSeed = superSeed + node.getSeed() + salt;
x += reference(child, childSeed, xv, zv, data, engine, IrisNoiseGenerator.X_AXIS) - offset;
z += reference(child, childSeed, xv, zv, data, engine, IrisNoiseGenerator.Z_AXIS) - offset;
}
salt += 819;
}
double sampleX = (x / node.getZoom()) + node.getOffsetX();
double sampleZ = (z / node.getZoom()) + node.getOffsetZ();
double result = node.getGenerator(superSeed, data, engine).noiseFast2D(sampleX, sampleZ) * node.getOpacity();
CNG generator = node.getGenerator(superSeed, data, engine).reseededForAxis(axis);
double result = generator.noiseFast2D(sampleX, sampleZ) * node.getOpacity();
result = node.isNegative() ? -result + node.getOpacity() : result;
result = (node.getExponent() != 1D ? result < 0D ? -Math.pow(-result, node.getExponent())
: Math.pow(result, node.getExponent()) : result) + node.getOffsetY();
@@ -18,7 +18,7 @@ public class NoiseSeedCohesionTest {
private static final long[] SEEDS = {813753L, -935731L, Long.MIN_VALUE};
private static final double[] COORDINATES = {-29_999_983.25D, -513D, -64D, -1D, 0D, 0.125D, 17D, 64D, 8192D, 29_999_983.25D};
private static final double PINNED_SAMPLE_SCALE = 1.0E9D;
private static final long PINNED_HASH_WINDOWS = 2597318414939754011L;
private static final long PINNED_HASH_WINDOWS = 6074446696529759284L;
private static final long PINNED_HASH_MAC = -602781966673993721L;
@Test
@@ -38,17 +38,17 @@ public class IrisMathNoiseHotPathParityTest {
.setStyle(NoiseStyle.PERLIN_IRIS.style())
.setExponent(1.15D);
assertEquals(0.5084984235498856D, noiseGenerator.getNoise(9988L, 31.25D, -17.5D, null), 0D);
assertEquals(0.4646529061250786D, noiseGenerator.getNoise(9988L, 31.25D, -17.5D, null), 0D);
IrisGeneratorStyle style = NoiseStyle.IRIS_DOUBLE.style();
assertEquals(0.6224926166486215D, style.createNoCache(new RNG(112233L), null).noiseFast2D(42.5D, -19.75D), 0D);
assertEquals(0.6855680984398492D, style.createNoCache(new RNG(112233L), null).noiseFast2D(42.5D, -19.75D), 0D);
IrisGenerator generator = new IrisGenerator()
.setZoom(9.5D)
.setOpacity(0.91D)
.setComposite(new KList<IrisNoiseGenerator>().qadd(noiseGenerator));
assertEquals(0.43997118860461754D, generator.getHeight(63.0D, -27.0D, 445566L), 0D);
assertEquals(0.5023367573389593D, generator.getHeight(63.0D, -27.0D, 445566L), 0D);
}
@Test