mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Zoom continents like regions and biomes
continentZoom rescaled the baked style noise instead of zooming its input, so fractures kept their unzoomed size. No pins moved: none use a fractured continent style with continentZoom other than 1. v3: 98bc84fc5
This commit is contained in:
1 parent
fc3ea69d74
commit
f3bf0aea4b
4 files changed
+37
-16
No files matched your search
@@ -2,7 +2,7 @@ package art.arcane.iris.engine;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.iris.util.project.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class ContinentGenerator {
|
||||
@@ -11,16 +11,14 @@ public final class ContinentGenerator {
|
||||
private ContinentGenerator() {
|
||||
}
|
||||
|
||||
public static CNG create(IrisDimension dimension, RNG parentSeedSource, IrisData packData) {
|
||||
public static ProceduralStream<Double> create(IrisDimension dimension, RNG parentSeedSource, IrisData packData) {
|
||||
return dimension.getContinentalStyle()
|
||||
.createScaledGenerator(deriveContinentSeed(parentSeedSource), packData, inverseContinentZoom(dimension));
|
||||
.createNoCache(deriveContinentSeed(parentSeedSource), packData)
|
||||
.stream()
|
||||
.zoom(dimension.getContinentZoom());
|
||||
}
|
||||
|
||||
static RNG deriveContinentSeed(RNG parentSeedSource) {
|
||||
return parentSeedSource.nextParallelRNG(CONTINENT_SEED_SALT);
|
||||
}
|
||||
|
||||
private static double inverseContinentZoom(IrisDimension dimension) {
|
||||
return 1D / dimension.getContinentZoom();
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public class IrisComplex implements DataProvider {
|
||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||
bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(),
|
||||
Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) :
|
||||
ContinentGenerator.create(engine.getDimension(), rng, getData()).stream()
|
||||
ContinentGenerator.create(engine.getDimension(), rng, getData())
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
|
||||
.cache2D("bridgeStream", engine, cacheSize);
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> implode(focusBiome, x, z),
|
||||
|
||||
@@ -166,7 +166,7 @@ public class UpperDimensionContext implements DataProvider {
|
||||
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||
|
||||
ProceduralStream<InferredType> bridgeStream = ContinentGenerator.create(upperDim, rng, upperData).stream()
|
||||
ProceduralStream<InferredType> bridgeStream = ContinentGenerator.create(upperDim, rng, upperData)
|
||||
.convert(v -> v >= upperDim.getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = bridgeStream
|
||||
|
||||
@@ -6,6 +6,7 @@ import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.iris.util.project.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -16,6 +17,7 @@ import static org.mockito.Mockito.mock;
|
||||
public class ContinentGeneratorTest {
|
||||
private static final long WORLD_SEED = 7L;
|
||||
private static final double CONTINENT_ZOOM = 4D;
|
||||
private static final double FRACTURE_MULTIPLIER = 3D;
|
||||
private static final double CHILD_SCALE = 3D;
|
||||
private static final int CHILD_SIGNATURE = 5;
|
||||
private static final int CHILDREN_SEED_SALT = 2137;
|
||||
@@ -24,19 +26,32 @@ public class ContinentGeneratorTest {
|
||||
private final IrisData packData = mock(IrisData.class);
|
||||
|
||||
@Test
|
||||
public void continentMapIsTheUnscaledNoiseShrunkByTheContinentZoom() {
|
||||
IrisDimension dimension = dimensionWithContinentZoom();
|
||||
public void continentMapIsTheUnscaledNoiseSampledAtZoomedOutBlocks() {
|
||||
IrisDimension dimension = dimensionWithContinentStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX));
|
||||
CNG unscaled = dimension.getContinentalStyle()
|
||||
.createNoCache(ContinentGenerator.deriveContinentSeed(new RNG(WORLD_SEED)), packData);
|
||||
|
||||
CNG continent = ContinentGenerator.create(dimension, new RNG(WORLD_SEED), packData);
|
||||
ProceduralStream<Double> continent = ContinentGenerator.create(dimension, new RNG(WORLD_SEED), packData);
|
||||
|
||||
assertArrayEquals(sample(unscaled, 1D / CONTINENT_ZOOM), sample(continent, 1D), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fracturesOfTheContinentMapScaleWithTheContinentZoom() {
|
||||
IrisGeneratorStyle fractured = new IrisGeneratorStyle(NoiseStyle.SIMPLEX)
|
||||
.setFracture(new IrisGeneratorStyle(NoiseStyle.SIMPLEX).setMultiplier(FRACTURE_MULTIPLIER));
|
||||
IrisDimension zoomed = dimensionWithContinentStyle(fractured);
|
||||
IrisDimension unzoomed = dimensionWithContinentStyle(fractured).setContinentZoom(1D);
|
||||
|
||||
ProceduralStream<Double> zoomedContinent = ContinentGenerator.create(zoomed, new RNG(WORLD_SEED), packData);
|
||||
ProceduralStream<Double> unzoomedContinent = ContinentGenerator.create(unzoomed, new RNG(WORLD_SEED), packData);
|
||||
|
||||
assertArrayEquals(sample(unzoomedContinent, 1D / CONTINENT_ZOOM), sample(zoomedContinent, 1D), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rebuildingTheContinentMapZoomsItOnlyOnce() {
|
||||
IrisDimension dimension = dimensionWithContinentZoom();
|
||||
IrisDimension dimension = dimensionWithContinentStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX));
|
||||
double[] first = sample(ContinentGenerator.create(dimension, new RNG(WORLD_SEED), packData), 1D);
|
||||
|
||||
double[] rebuilt = sample(ContinentGenerator.create(dimension, new RNG(WORLD_SEED), packData), 1D);
|
||||
@@ -46,7 +61,7 @@ public class ContinentGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void buildingTheContinentMapLeavesTheSharedStyleGeneratorUnscaled() {
|
||||
IrisDimension dimension = dimensionWithContinentZoom();
|
||||
IrisDimension dimension = dimensionWithContinentStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX));
|
||||
RNG continentSeed = ContinentGenerator.deriveContinentSeed(new RNG(WORLD_SEED));
|
||||
double[] before = sample(dimension.getContinentalStyle().create(continentSeed, packData), 1D);
|
||||
|
||||
@@ -86,9 +101,9 @@ public class ContinentGeneratorTest {
|
||||
return biome;
|
||||
}
|
||||
|
||||
private static IrisDimension dimensionWithContinentZoom() {
|
||||
private static IrisDimension dimensionWithContinentStyle(IrisGeneratorStyle continentalStyle) {
|
||||
return new IrisDimension()
|
||||
.setContinentalStyle(new IrisGeneratorStyle(NoiseStyle.SIMPLEX))
|
||||
.setContinentalStyle(continentalStyle)
|
||||
.setContinentZoom(CONTINENT_ZOOM);
|
||||
}
|
||||
|
||||
@@ -99,4 +114,12 @@ public class ContinentGeneratorTest {
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
|
||||
private static double[] sample(ProceduralStream<Double> stream, double blockScale) {
|
||||
double[] samples = new double[SAMPLE_BLOCKS.length];
|
||||
for (int i = 0; i < SAMPLE_BLOCKS.length; i++) {
|
||||
samples[i] = stream.get(SAMPLE_BLOCKS[i][0] * blockScale, SAMPLE_BLOCKS[i][1] * blockScale);
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user