Step height knob

- Add tier stepHeight 1..2, default 2, in the settings fingerprint
- Snap channel heads by tier and keep ponds, lakes and inlets at 2
- Key riffle crests on any lower neighbour, falls unchanged
- Start one-block outlets at their pond's surface
- Reject tiers with a larger step than the next larger tier
- Recapture the fingerprint and schema digest
This commit is contained in:
Brian Fopiano committed 2026-11-03 12:17:28 -05:00
1 parent 750bade003
commit f809bacd29
28 files changed
+206 -75

No files matched your search

@@ -52,6 +52,11 @@ public class IrisHydrologyTier {
@Description("Smallest drop in blocks that becomes a waterfall.")
private int waterfallMinimumDrop = 6;
@MinNumber(1)
@MaxNumber(2)
@Description("Smallest step in blocks between this tier's water surfaces. 2 keeps channel surfaces on every second height above the sea. 1 lets a channel fall one block at a time, and works best with cascades false, which spreads drops into a gentle slope. Falls and plunge pools are unchanged. Ponds and lakes always use 2. A tier cannot use a larger step than the next larger tier.")
private int stepHeight = 2;
@MinNumber(0)
@MaxNumber(64)
@Description("Width in blocks of the band beside the water where the ground is reshaped into banks. 0 leaves the ground beside the channel as it is.")
@@ -23,6 +23,7 @@ import art.arcane.iris.generation.hydrology.config.IrisPondShore;
import art.arcane.iris.generation.hydrology.config.IrisSeaInlets;
import art.arcane.iris.generation.hydrology.underground.SeaInletPlanner;
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
import art.arcane.iris.generation.hydrology.water.LakeCandidate;
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
@@ -232,6 +233,7 @@ public final class HydrologySettings {
}
compiled.sort(Comparator.comparingDouble(HydrologyTier::minCatchment));
requireDistinctCatchments(compiled);
requireNoStepUpstream(compiled);
return List.copyOf(compiled);
}
@@ -246,6 +248,17 @@ public final class HydrologySettings {
}
}
private static void requireNoStepUpstream(List<HydrologyTier> sorted) {
for (int index = 1; index < sorted.size(); index++) {
HydrologyTier lower = sorted.get(index - 1);
HydrologyTier upper = sorted.get(index);
if (lower.stepHeight() > upper.stepHeight()) {
throw new IllegalArgumentException("Hydrology tier '" + lower.name() + "' has stepHeight " + lower.stepHeight() + " above the larger tier '"
+ upper.name() + "' with " + upper.stepHeight() + "; the water it feeds would stand above its own");
}
}
}
private static HydrologyTier tier(IrisHydrologyTier config, String field) {
FloatRange halfWidth = floatRange(config.getHalfWidth(), field + ".halfWidth", RangeFloor.POSITIVE);
if (halfWidth.max() > MAX_HALF_WIDTH) {
@@ -258,7 +271,7 @@ public final class HydrologySettings {
}
return new HydrologyTier(config.getName(), (float) config.getMinCatchment(), halfWidth.min(), halfWidth.max(),
(float) config.getWidthFactor(), (float) config.getDepthRatio(), config.getInset(), config.isCascades(),
config.getWaterfallMinimumDrop(), config.getBankBand(), config.getBankStyle(),
config.getWaterfallMinimumDrop(), config.getStepHeight(), config.getBankBand(), config.getBankStyle(),
estuary(config.getEstuary(), field + ".estuary"), delta(config, halfWidth.max(), field + ".delta"),
materials(config.getMaterials(), field + ".materials"), config.getFluid(), decorators(config.getDecorators(), field + ".decorators"));
}
@@ -583,6 +596,7 @@ public final class HydrologySettings {
requireNonNegative(config.getWidthFactor(), field + ".widthFactor");
requireNonNegative(config.getDepthRatio(), field + ".depthRatio");
requireAtLeast(config.getWaterfallMinimumDrop(), MIN_WATERFALL_DROP, field + ".waterfallMinimumDrop");
requireWithin(config.getStepHeight(), 1, WaterHeads.STANDING_STEP, field + ".stepHeight");
requireShoreDepth(config.getMaterials(), field + ".materials");
}
@@ -687,7 +701,7 @@ public final class HydrologySettings {
for (HydrologyTier tier : tiers) {
hash.add(tier.name()).add(tier.minCatchment()).add(tier.minHalfWidth()).add(tier.maxHalfWidth())
.add(tier.widthFactor()).add(tier.depthRatio()).add(tier.inset()).add(tier.cascades())
.add(tier.waterfallMinimumDrop()).add(tier.bankBand()).add(tier.bankStyle())
.add(tier.waterfallMinimumDrop()).add(tier.stepHeight()).add(tier.bankBand()).add(tier.bankStyle())
.add(tier.estuary().length()).add(tier.estuary().flare())
.add(tier.delta().channels()).add(tier.delta().spreadDegrees()).add(tier.delta().length())
.add(tier.materials()).add(tier.fluid());
@@ -114,17 +114,17 @@ final class ChunkFeatures {
boolean hasOnlyLevel(int head, int seaLevel) {
for (Pond pond : ponds) {
if (WaterHeads.snap(pond.level(), seaLevel) != head) {
if (WaterHeads.standing(pond.level(), seaLevel) != head) {
return false;
}
}
for (Pond lake : lakes) {
if (WaterHeads.snap(lake.level(), seaLevel) != head) {
if (WaterHeads.standing(lake.level(), seaLevel) != head) {
return false;
}
}
for (SeaInlet inlet : inlets) {
if (WaterHeads.snap(inlet.waterLevel(), seaLevel) != head) {
if (WaterHeads.standing(inlet.waterLevel(), seaLevel) != head) {
return false;
}
}
@@ -101,19 +101,19 @@ public final class LinkBlend {
}
private static Reach regraded(Reach reach, int[] grade, float[] halfWidth, float[] depth, int seaLevel) {
ReachStyle[] style = grade == reach.grade() ? reach.style() : restyled(reach.style(), grade, reach.tier().waterfallMinimumDrop(), seaLevel);
ReachStyle[] style = grade == reach.grade() ? reach.style() : restyled(reach.style(), grade, reach.tier().waterfallMinimumDrop(), seaLevel, reach.tier().stepHeight());
return new Reach(reach.id(), reach.tier(), reach.downstreamId(), reach.xs(), reach.zs(), grade, halfWidth, depth, style,
reach.catchment());
}
private static ReachStyle[] restyled(ReachStyle[] style, int[] grade, int waterfallMinimumDrop, int seaLevel) {
private static ReachStyle[] restyled(ReachStyle[] style, int[] grade, int waterfallMinimumDrop, int seaLevel, int stepHeight) {
boolean[] mouth = new boolean[style.length];
boolean[] outlet = new boolean[style.length];
for (int point = 0; point < style.length; point++) {
mouth[point] = style[point] == ReachStyle.MOUTH;
outlet[point] = style[point] == ReachStyle.POND_OUTLET;
}
return ReachShaper.styles(grade, mouth, outlet, waterfallMinimumDrop, seaLevel);
return ReachShaper.styles(grade, mouth, outlet, waterfallMinimumDrop, seaLevel, stepHeight);
}
private static int lowestEnd(List<Reach> feeders) {
@@ -77,7 +77,7 @@ public final class PondChannelSettlement {
BitSet visited = new BitSet(width * (bounds.maxZ() - bounds.minZ() + 1));
for (Reach reach : reaches) {
for (int segment = 0; segment + 1 < reach.xs().length; segment++) {
if (WaterHeads.snap(brinks.lowestGrade(reach, segment), seaLevel) >= WaterHeads.snap(level, seaLevel)) {
if (WaterHeads.snap(brinks.lowestGrade(reach, segment), seaLevel, reach.tier().stepHeight()) >= WaterHeads.standing(level, seaLevel)) {
continue;
}
float radius = Math.max(reach.halfWidth()[segment], reach.halfWidth()[segment + 1]) + 1f;
@@ -114,7 +114,7 @@ public final class PondChannelSettlement {
return level;
}
int head = brinks.head(channel);
return head < WaterHeads.snap(level, seaLevel) ? head : level;
return head < WaterHeads.standing(level, seaLevel) ? head : level;
}
private record Bounds(int minX, int minZ, int maxX, int maxZ) {
@@ -91,7 +91,7 @@ final class RasterComposer {
int ground = natural[cell];
SeaInlet inlet = features.openInletAt(x, z, inletColumn);
if (inlet != null) {
head[cell] = WaterHeads.snap(inlet.waterLevel(), settings.seaLevel());
head[cell] = WaterHeads.standing(inlet.waterLevel(), settings.seaLevel());
terrain[cell] = Math.min(Math.min(ground, inletColumn[0]), head[cell] - 1);
role[cell] = WaterRole.INLET;
feature[cell] = inlet.id();
@@ -105,15 +105,15 @@ final class RasterComposer {
double variation = BedProfile.variation(settings.seed(), x, z);
if (lake >= 0) {
Pond water = features.lake(lake);
standing(cell, water, trench(ground, WaterHeads.snap(water.level(), settings.seaLevel()), ground, variation, BedProfile.detail(settings.seed(), x, z)));
standing(cell, water, trench(ground, WaterHeads.standing(water.level(), settings.seaLevel()), ground, variation, BedProfile.detail(settings.seed(), x, z)));
return;
}
if (pondIndex >= 0) {
Pond water = features.pond(pondIndex);
pond[cell] = pondIndex;
double detail = BedProfile.detail(settings.seed(), x, z);
int floor = interior(cell) ? pondFloor(pondIndex, WaterHeads.snap(water.level(), settings.seaLevel()), x, z, ground, variation, detail) : ground;
standing(cell, water, trench(floor, WaterHeads.snap(water.level(), settings.seaLevel()), ground, variation, detail));
int floor = interior(cell) ? pondFloor(pondIndex, WaterHeads.standing(water.level(), settings.seaLevel()), x, z, ground, variation, detail) : ground;
standing(cell, water, trench(floor, WaterHeads.standing(water.level(), settings.seaLevel()), ground, variation, detail));
return;
}
if (cursor.channel.reach != null) {
@@ -124,7 +124,7 @@ final class RasterComposer {
}
private void standing(int cell, Pond water, int floor) {
head[cell] = WaterHeads.snap(water.level(), settings.seaLevel());
head[cell] = WaterHeads.standing(water.level(), settings.seaLevel());
terrain[cell] = Math.min(floor, head[cell] - 1);
role[cell] = WaterRole.POND;
feature[cell] = water.id();
@@ -206,8 +206,8 @@ final class RasterComposer {
}
int taper = settings.ponds().shore().taper();
boolean tapered = nearPond >= 0 && pondEdge <= taper;
if (tapered && ground > WaterHeads.snap(features.pond(nearPond).level(), settings.seaLevel())) {
cut = Math.min(cut, taperCut(WaterHeads.snap(features.pond(nearPond).level(), settings.seaLevel()), ground, BedProfile.position(pondEdge / taper, -variation)));
if (tapered && ground > WaterHeads.standing(features.pond(nearPond).level(), settings.seaLevel())) {
cut = Math.min(cut, taperCut(WaterHeads.standing(features.pond(nearPond).level(), settings.seaLevel()), ground, BedProfile.position(pondEdge / taper, -variation)));
}
terrain[cell] = raise == Integer.MIN_VALUE ? cut : Math.max(cut, raise);
if (bank.reach != null && (!tapered || bankEdge <= pondEdge)) {
@@ -336,17 +336,17 @@ final class RasterComposer {
}
SeaInlet inlet = features.openInletAt(x, z, inletColumn);
if (inlet != null) {
sample.set(WaterHeads.snap(inlet.waterLevel(), settings.seaLevel()), inlet.id(), WaterRole.INLET);
sample.set(WaterHeads.standing(inlet.waterLevel(), settings.seaLevel()), inlet.id(), WaterRole.INLET);
return;
}
int lake = features.lakeCovers(x, z) ? features.lakeAt(x, z, naturalAt(x, z)) : -1;
if (lake >= 0) {
sample.set(WaterHeads.snap(features.lake(lake).level(), settings.seaLevel()), features.lake(lake).id(), WaterRole.POND);
sample.set(WaterHeads.standing(features.lake(lake).level(), settings.seaLevel()), features.lake(lake).id(), WaterRole.POND);
return;
}
int pond = features.pondAt(x, z);
if (pond >= 0) {
sample.set(WaterHeads.snap(features.pond(pond).level(), settings.seaLevel()), features.pond(pond).id(), WaterRole.POND);
sample.set(WaterHeads.standing(features.pond(pond).level(), settings.seaLevel()), features.pond(pond).id(), WaterRole.POND);
return;
}
features.segments().nearest(x, z, ReachSegments.Scope.CHANNEL, cursor);
@@ -377,7 +377,7 @@ final class RasterComposer {
continue;
}
Pond held = features.pond(index);
int level = WaterHeads.snap(held.level(), settings.seaLevel());
int level = WaterHeads.standing(held.level(), settings.seaLevel());
if (held.damRaise() > 0 && terrain[cell] < level && level + 1 > crest) {
crest = level + 1;
dam = held.id();
@@ -35,11 +35,12 @@ final class ReachGeometry {
static ReachGeometry of(Reach reach, Reach linked, long seed, int seaLevel) {
int[] grade = reach.grade();
int stepHeight = reach.tier().stepHeight();
int[] steps = new int[grade.length - 1];
int count = 0;
boolean falls = false;
for (int segment = 0; segment + 1 < grade.length; segment++) {
if (WaterHeads.snap(grade[segment], seaLevel) != WaterHeads.snap(grade[segment + 1], seaLevel)) {
if (WaterHeads.snap(grade[segment], seaLevel, stepHeight) != WaterHeads.snap(grade[segment + 1], seaLevel, stepHeight)) {
steps[count++] = segment;
falls |= grade[segment] - grade[segment + 1] >= BRINK_MIN_DROP;
}
@@ -56,15 +57,15 @@ final class ReachGeometry {
double[] shifts = new double[count];
double[] starts = new double[count];
int curves = 0;
int start = WaterHeads.snap(grade[0], seaLevel);
int start = WaterHeads.snap(grade[0], seaLevel, stepHeight);
boolean outlet = reach.style()[0] == ReachStyle.POND_OUTLET;
boolean feeder = reach.downstreamId() != 0L;
int landing = WaterHeads.snap(grade[grade.length - 1], seaLevel);
int landing = WaterHeads.snap(grade[grade.length - 1], seaLevel, stepHeight);
for (int step = 0; step < count; step++) {
int segment = steps[step];
double middle = middle(along, segment);
int upper = WaterHeads.snap(grade[segment], seaLevel);
int lower = WaterHeads.snap(grade[segment + 1], seaLevel);
int upper = WaterHeads.snap(grade[segment], seaLevel, stepHeight);
int lower = WaterHeads.snap(grade[segment + 1], seaLevel, stepHeight);
if (grade[segment] - grade[segment + 1] < BRINK_MIN_DROP || linked.grade()[segment] - linked.grade()[segment + 1] < BRINK_MIN_DROP || middle <= held || outlet && upper == start || feeder && lower == landing
|| reach.style()[segment] == ReachStyle.MOUTH || reach.style()[segment + 1] == ReachStyle.MOUTH) {
continue;
@@ -57,9 +57,10 @@ final class ReachSegments {
boolean hasOnlyLevel(int head, int seaLevel) {
for (int index = 0; index < size; index++) {
int[] grade = reaches[index].grade();
int stepHeight = reaches[index].tier().stepHeight();
int start = grade[segments[index]];
int end = grade[segments[index] + 1];
if (WaterHeads.snap(start, seaLevel) != head || WaterHeads.snap(end, seaLevel) != head) {
if (WaterHeads.snap(start, seaLevel, stepHeight) != head || WaterHeads.snap(end, seaLevel, stepHeight) != head) {
return false;
}
}
@@ -108,7 +108,7 @@ final class RiffleProfile {
if (neighbour == DRY) {
continue;
}
crest |= neighbour <= head - 2;
crest |= neighbour < head;
if (flowing[cell] && neighbour - head >= PLUNGE_MIN_DROP) {
feet.computeIfAbsent(new Fall(head, neighbour), ignored -> new Seeds()).add(cell);
}
@@ -31,7 +31,7 @@ public final class TongueGuard {
int[] stopped = new int[tongues.length];
int count = 0;
for (int fall : tongues) {
int lowestGround = WaterHeads.snap(reach.grade()[fall], seaLevel) - 1 - maxFill;
int lowestGround = WaterHeads.snap(reach.grade()[fall], seaLevel, reach.tier().stepHeight()) - 1 - maxFill;
if (passesTheGround(reach, geometry, segments, cursor, fall, natural, lowestGround)) {
stopped[count++] = fall;
}
@@ -1,20 +1,24 @@
package art.arcane.iris.generation.hydrology.raster;
public final class WaterHeads {
private static final int STEP = 2;
public static final int STANDING_STEP = 2;
private WaterHeads() {
}
public static int snap(int planned, int seaLevel) {
return planned - Math.floorMod(planned - seaLevel, STEP);
public static int snap(int planned, int seaLevel, int stepHeight) {
return planned - Math.floorMod(planned - seaLevel, stepHeight);
}
public static int standing(int planned, int seaLevel) {
return snap(planned, seaLevel, STANDING_STEP);
}
static int channelHead(ReachCursor.Choice choice, ReachGeometry geometry, int seaLevel) {
return snap(choice.reach.grade()[geometry.point(choice)], seaLevel);
return snap(choice.reach.grade()[geometry.point(choice)], seaLevel, choice.reach.tier().stepHeight());
}
public static int lowestAboveSea(int seaLevel) {
return seaLevel + STEP;
public static int lowestAboveSea(int seaLevel, int stepHeight) {
return seaLevel + stepHeight;
}
}
@@ -16,6 +16,7 @@ public record HydrologyTier(
int inset,
boolean cascades,
int waterfallMinimumDrop,
int stepHeight,
int bankBand,
IrisBankStyle bankStyle,
Estuary estuary,
@@ -42,7 +42,8 @@ final class ReachGrader {
int source = outletPond[index];
if (source >= 0) {
settle(drafts, ponds, inflows[source], levels, fed, graded, settled, lakeFloor, source, seaLevel);
draft.carry = Math.min(draft.carry, levels[source]);
int pondHead = draft.tier.stepHeight() < WaterHeads.STANDING_STEP ? WaterHeads.standing(levels[source], seaLevel) : levels[source];
draft.carry = Math.min(draft.carry, pondHead);
fed[index] = levels[source];
}
for (int upstream : draft.incoming) {
@@ -65,7 +66,7 @@ final class ReachGrader {
}
int cap = draft.ocean[point] ? seaLevel : draft.target[point] + MAX_POOL;
int floor = lakeFloor[index] ? draft.floor : Math.max(seaLevel, Math.min(draft.floor, (int) Math.floor(draft.bank[point]) + maxFill));
floors[point] = draft.ocean[point] ? floor : Math.max(floor, WaterHeads.lowestAboveSea(seaLevel));
floors[point] = draft.ocean[point] ? floor : Math.max(floor, WaterHeads.lowestAboveSea(seaLevel, draft.tier.stepHeight()));
level = Math.min(level, Math.max(floor, Math.min(grade[point], cap)));
grade[point] = level;
}
@@ -386,7 +386,7 @@ public final class ReachShaper {
}
private static void restyle(ReachDraft draft, int seaLevel) {
draft.style = styles(draft.grade, draft.ocean, draft.fixed(), draft.tier.waterfallMinimumDrop(), seaLevel);
draft.style = styles(draft.grade, draft.ocean, draft.fixed(), draft.tier.waterfallMinimumDrop(), seaLevel, draft.tier.stepHeight());
}
private static void chaikin(ReachDraft draft) {
@@ -570,13 +570,13 @@ public final class ReachShaper {
return Math.clamp(1f - remaining / length, 0f, 1f);
}
public static ReachStyle[] styles(int[] grade, boolean[] ocean, boolean[] outletZone, int waterfallMinimumDrop, int seaLevel) {
public static ReachStyle[] styles(int[] grade, boolean[] ocean, boolean[] outletZone, int waterfallMinimumDrop, int seaLevel, int stepHeight) {
ReachStyle[] styles = new ReachStyle[grade.length];
for (int point = 0; point < grade.length; point++) {
int drop = point == 0 ? 0 : grade[point - 1] - grade[point];
styles[point] = style(drop, waterfallMinimumDrop, ocean[point], outletZone[point]);
if (drop == 1 && !ocean[point] && outletZone[point - 1]
&& WaterHeads.snap(grade[point - 1], seaLevel) - WaterHeads.snap(grade[point], seaLevel) >= 2) {
&& WaterHeads.snap(grade[point - 1], seaLevel, stepHeight) - WaterHeads.snap(grade[point], seaLevel, stepHeight) >= 2) {
styles[point] = ReachStyle.CASCADE;
}
}