mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 08:14:45 +00:00
Drive overlay noise from generators
overlayNoise now links generator files with a min and max, like biome generators, so overlays get composites, exponent, cliffs and cells. Heights come from link.getHeight with seed heightSeed + 571093, in the main and upper dimensions; exported packs now include overlay generators. Inline styles are no longer read, and the unused IrisShapedGeneratorStyle is removed. No pin, golden or digest moved: no test pack uses overlayNoise, and worlds without it generate identically. Worlds with overlay noise change, since the noise now comes from a different seed. v3: ef77fc5a8
This commit is contained in:
1 parent
c2183bc470
commit
3eb8566ef9
7 files changed
+115
-103
No files matched your search
@@ -114,6 +114,7 @@ public class IrisPackageCompiler {
|
||||
dimension.getReachableBiomes(() -> dm).forEach((biome) -> addIfPresent(biomes, biome));
|
||||
regions.forEach(moduleResources::followSettingsOf);
|
||||
biomes.forEach((i) -> i.getGenerators().forEach((j) -> addIfPresent(generators, j.getCachedGenerator(() -> dm))));
|
||||
dimension.getOverlayNoise().forEach((j) -> addIfPresent(generators, j.getCachedGenerator(() -> dm)));
|
||||
biomes.forEach(moduleResources::followSettingsOf);
|
||||
KList<ObjectPlacement> allPlacements = new KList<>();
|
||||
regions.forEach((r) -> allPlacements.addAll(ObjectPlacements.all(r)));
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.core.studio.noise;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||
@@ -81,13 +81,13 @@ public final class NoiseSources {
|
||||
|
||||
// The overlay is summed the way the world adds it, with the world's seed, in blocks above the fluid.
|
||||
private static void addOverlayNoise(Engine engine, List<Entry> entries) {
|
||||
List<IrisShapedGeneratorStyle> overlay = engine.getDimension().getOverlayNoise();
|
||||
List<IrisBiomeGeneratorLink> overlay = engine.getDimension().getOverlayNoise();
|
||||
if (overlay.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BlockRange blocks = new BlockRange(
|
||||
overlay.stream().mapToInt(IrisShapedGeneratorStyle::getMin).sum(),
|
||||
overlay.stream().mapToInt(IrisShapedGeneratorStyle::getMax).sum());
|
||||
overlay.stream().mapToInt(IrisBiomeGeneratorLink::getMin).sum(),
|
||||
overlay.stream().mapToInt(IrisBiomeGeneratorLink::getMax).sum());
|
||||
Source source = new Source(OVERLAY_NOISE_ID, "Overlay noise", NoiseCategory.PACK_GENERATORS.label(), false, blocks);
|
||||
entries.add(new Entry(source, NoiseCategory.PACK_GENERATORS, seed -> engine.getComplex().getOverlayStream()::get));
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.image.IrisImageMapRuntime;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||
import art.arcane.iris.engine.object.noise.IrisInterpolator;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
@@ -79,6 +79,7 @@ public class IrisComplex implements DataProvider {
|
||||
IrisGenerator::getLoadKey,
|
||||
Comparator.nullsFirst(Comparator.naturalOrder())
|
||||
);
|
||||
static final int OVERLAY_GENERATOR_SEED = 571093;
|
||||
private static final int DEEPEST_CHILD_LEVEL = 3;
|
||||
/** How many levels of children a biome can be replaced through, parent first. */
|
||||
public static final int CHILD_PICK_LEVELS = DEEPEST_CHILD_LEVEL + 1;
|
||||
@@ -199,14 +200,15 @@ public class IrisComplex implements DataProvider {
|
||||
frozenGenerators[frozenIndex] = generatorGroups[frozenIndex].generators();
|
||||
}
|
||||
generatorBounds = buildGeneratorBounds(engine);
|
||||
KList<IrisShapedGeneratorStyle> overlayNoise = engine.getDimension().getOverlayNoise();
|
||||
KList<IrisBiomeGeneratorLink> overlayNoise = engine.getDimension().getOverlayNoise();
|
||||
long overlaySeed = engine.getSeedManager().getHeight() + OVERLAY_GENERATOR_SEED;
|
||||
overlayStream = overlayNoise.isEmpty()
|
||||
? ProceduralStream.ofDouble((x, z) -> 0.0D)
|
||||
: ProceduralStream.ofDouble((x, z) -> {
|
||||
double value = 0D;
|
||||
|
||||
for (IrisShapedGeneratorStyle style : overlayNoise) {
|
||||
value += style.get(rng, getData(), x, z);
|
||||
for (IrisBiomeGeneratorLink link : overlayNoise) {
|
||||
value += link.getHeight(this, x, z, overlaySeed);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
@@ -10,7 +10,7 @@ import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||
import art.arcane.iris.engine.object.noise.IrisInterpolator;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.util.common.data.DataProvider;
|
||||
@@ -180,19 +180,19 @@ public class UpperDimensionContext implements DataProvider {
|
||||
.convertAware2D((biome, x, z) -> mappedBiome(imageMapRuntime, biome, x, z))
|
||||
.cache2D("upperImageMappedBaseBiomeStream", engine, cacheSize);
|
||||
|
||||
KList<IrisShapedGeneratorStyle> overlayNoise = upperDim.getOverlayNoise();
|
||||
long heightSeed = engine.getSeedManager().getHeight() ^ seedOffset;
|
||||
long overlaySeed = heightSeed + IrisComplex.OVERLAY_GENERATOR_SEED;
|
||||
KList<IrisBiomeGeneratorLink> overlayNoise = upperDim.getOverlayNoise();
|
||||
ProceduralStream<Double> overlayStream = overlayNoise.isEmpty()
|
||||
? ProceduralStream.ofDouble((x, z) -> 0.0D)
|
||||
: ProceduralStream.ofDouble((x, z) -> {
|
||||
double value = 0D;
|
||||
for (IrisShapedGeneratorStyle style : overlayNoise) {
|
||||
value += style.get(rng, upperData, x, z);
|
||||
for (IrisBiomeGeneratorLink link : overlayNoise) {
|
||||
value += link.getHeight(dataProvider, x, z, overlaySeed);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
long heightSeed = engine.getSeedManager().getHeight() ^ seedOffset;
|
||||
|
||||
ProceduralStream<Double> heightStream = ProceduralStream.of((x, z) -> {
|
||||
IrisBiome b = baseBiomeStream.get(x, z);
|
||||
if (b == null) {
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.noise;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("shaped-style")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("This represents a generator with a min and max height")
|
||||
@Data
|
||||
public class IrisShapedGeneratorStyle {
|
||||
@Required
|
||||
@Desc("The generator id")
|
||||
private IrisGeneratorStyle generator = new IrisGeneratorStyle(NoiseStyle.IRIS);
|
||||
|
||||
@Required
|
||||
@MinNumber(-2032)
|
||||
@MaxNumber(2032)
|
||||
@Desc("The min block value")
|
||||
private int min = 0;
|
||||
|
||||
@Required
|
||||
@MinNumber(-2032)
|
||||
@MaxNumber(2032)
|
||||
@Desc("The max block value")
|
||||
private int max = 0;
|
||||
|
||||
public IrisShapedGeneratorStyle(NoiseStyle style, int min, int max) {
|
||||
this(style);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public IrisShapedGeneratorStyle(NoiseStyle style) {
|
||||
this.generator = new IrisGeneratorStyle(style);
|
||||
}
|
||||
|
||||
public double get(RNG rng, IrisData data, double... dim) {
|
||||
return generator.create(rng, data).fitDouble(min, max, dim);
|
||||
}
|
||||
|
||||
public double get(RNG rng, IrisData data, double x, double z) {
|
||||
return generator.create(rng, data).fitDouble(min, max, x, z);
|
||||
}
|
||||
|
||||
public double get(RNG rng, IrisData data, double x, double y, double z) {
|
||||
return generator.create(rng, data).fitDouble(min, max, x, y, z);
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return min == max || getGenerator().isFlat();
|
||||
}
|
||||
|
||||
public int getMid() {
|
||||
return (getMax() + getMin()) / 2;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import art.arcane.iris.engine.object.image.IrisImageMap;
|
||||
import art.arcane.iris.engine.object.image.IrisImageMapApplication;
|
||||
import art.arcane.iris.engine.object.image.IrisImageMapBinding;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.noise.NoiseStyle;
|
||||
import art.arcane.iris.engine.object.runtime.StudioMode;
|
||||
import art.arcane.iris.engine.object.value.IrisRange;
|
||||
@@ -30,6 +29,7 @@ import art.arcane.iris.engine.object.world.IrisEnvironment;
|
||||
import art.arcane.iris.engine.object.world.IrisWorldBoundary;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
||||
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.core.IrisDatapackCompiler.DimensionHeight;
|
||||
@@ -205,9 +205,9 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private boolean useMantle = true;
|
||||
@Desc("Prevent Leaf decay as if placed in creative mode")
|
||||
private boolean preventLeafDecay = false;
|
||||
@ArrayType(min = 1, type = IrisShapedGeneratorStyle.class)
|
||||
@Desc("Overlay additional noise on top of the interoplated terrain.")
|
||||
private KList<IrisShapedGeneratorStyle> overlayNoise = new KList<>();
|
||||
@ArrayType(min = 1, type = IrisBiomeGeneratorLink.class)
|
||||
@Desc("Generators whose heights (min to max blocks) are added on top of the interpolated terrain. The generator's interpolator is not used.")
|
||||
private KList<IrisBiomeGeneratorLink> overlayNoise = new KList<>();
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
@Desc("External Modrinth, HTTP(S) or file URL datapack sources owned by this dimension. Bukkit registers their resources server-wide, but Iris excludes their structure sets and definitions from generation and locate state in vanilla worlds and Iris dimensions that do not declare the same source. Local ZIPs under Iris/datapacks/imports are discovered automatically and enabled for every Iris dimension. Editable auto-import is limited to resources supplied by configured or discovered sources. Any registered datapack structure can be placed directly through nativeStructures without conversion. Replacing native generation requires a dimension-level structure placement with nativeSuppression set to REPLACE_SOURCE; provenance alone never disables native structures.")
|
||||
private KList<String> datapackImports = new KList<>();
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package art.arcane.iris.engine.object.world.biome;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.common.data.DataProvider;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisBiomeGeneratorLinkTest {
|
||||
private static final String GENERATOR_KEY = "overlay";
|
||||
private static final int MIN_BLOCKS = -4;
|
||||
private static final int MAX_BLOCKS = 12;
|
||||
private static final long SEED = 571093L + 77L;
|
||||
|
||||
@Test
|
||||
public void heightLerpsBetweenMinAndMaxByGeneratorOutput() {
|
||||
assertEquals(MIN_BLOCKS, link().getHeight(provider(fixed(0D, new AtomicLong())), 0D, 0D, SEED), 0D);
|
||||
assertEquals(4D, link().getHeight(provider(fixed(0.5D, new AtomicLong())), 0D, 0D, SEED), 1.0E-12D);
|
||||
assertEquals(MAX_BLOCKS, link().getHeight(provider(fixed(1D, new AtomicLong())), 0D, 0D, SEED), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generatorOutputIsClampedToUnitRangeBeforeTheLerp() {
|
||||
assertEquals(MIN_BLOCKS, link().getHeight(provider(fixed(-3D, new AtomicLong())), 0D, 0D, SEED), 0D);
|
||||
assertEquals(MAX_BLOCKS, link().getHeight(provider(fixed(2.5D, new AtomicLong())), 0D, 0D, SEED), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generatorSamplesWithTheSeedItIsGiven() {
|
||||
AtomicLong sampledSeed = new AtomicLong();
|
||||
|
||||
link().getHeight(provider(fixed(0.5D, sampledSeed)), 0D, 0D, SEED);
|
||||
|
||||
assertEquals(SEED, sampledSeed.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingGeneratorGivesFlatMinimumOverlay() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ResourceLoader<IrisGenerator> loader = mock(ResourceLoader.class);
|
||||
when(data.getGeneratorLoader()).thenReturn(loader);
|
||||
|
||||
assertEquals(MIN_BLOCKS, link().getHeight(() -> data, 12D, 34D, SEED), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dimensionDecodesOverlayNoiseAsGeneratorLinks() {
|
||||
String json = "{\"overlayNoise\": [{\"generator\": \"hills\", \"min\": -2, \"max\": 9}]}";
|
||||
|
||||
IrisDimension dimension = new Gson().fromJson(json, IrisDimension.class);
|
||||
|
||||
assertEquals(1, dimension.getOverlayNoise().size());
|
||||
IrisBiomeGeneratorLink link = dimension.getOverlayNoise().get(0);
|
||||
assertEquals("hills", link.getGenerator());
|
||||
assertEquals(-2, link.getMin());
|
||||
assertEquals(9, link.getMax());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dimensionWithoutOverlayNoiseHasNone() {
|
||||
assertTrue(new IrisDimension().getOverlayNoise().isEmpty());
|
||||
}
|
||||
|
||||
private IrisBiomeGeneratorLink link() {
|
||||
return new IrisBiomeGeneratorLink(GENERATOR_KEY, MIN_BLOCKS, MAX_BLOCKS);
|
||||
}
|
||||
|
||||
private DataProvider provider(IrisGenerator generator) {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ResourceLoader<IrisGenerator> loader = mock(ResourceLoader.class);
|
||||
when(loader.load(GENERATOR_KEY)).thenReturn(generator);
|
||||
when(data.getGeneratorLoader()).thenReturn(loader);
|
||||
return () -> data;
|
||||
}
|
||||
|
||||
private IrisGenerator fixed(double height, AtomicLong sampledSeed) {
|
||||
return new IrisGenerator() {
|
||||
@Override
|
||||
public double getHeight(double x, double z, long seed) {
|
||||
sampledSeed.set(seed);
|
||||
return height;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user