Remove studio render paths

- Drop IrisRenderer.renderStudio, renderStudioBase and refineStudioBiome with their adaptive, height and river atlases
- Drop RenderType.RIVER and the test-only WaterMap.draw
- Port the river renderer tests to the live WaterTile path
- Use a settled WaterTile as the map overlay test oracle
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-02 00:00:10 -05:00
1 parent 490016b56a
commit 6cbe4b2c09
9 files changed
+115 -661

No files matched your search

@@ -39,7 +39,7 @@ final class IrisBiomeColorRenderer {
static Color getColor(IrisBiome biome, Engine engine, RenderType type) {
switch (type) {
case BIOME, HEIGHT, CAVE_LAND, REGION, BIOME_SEA, BIOME_LAND, RIVER -> {
case BIOME, HEIGHT, CAVE_LAND, REGION, BIOME_SEA, BIOME_LAND -> {
return biome.getCacheColor().aquire(() -> {
if (biome.getColor() == null) {
RandomColor randomColor = new RandomColor(biome.getName().hashCode());
@@ -88,64 +88,6 @@ public final class IrisRenderer {
int resolution,
RenderType currentType,
BooleanSupplier cancelled
) {
return render(sx, sz, size, resolution, currentType, cancelled, false, false);
}
public BufferedImage renderStudio(
double sx,
double sz,
double size,
int resolution,
RenderType currentType,
BooleanSupplier cancelled
) {
return render(sx, sz, size, resolution, currentType, cancelled, true, true);
}
public BufferedImage renderStudioBase(
double sx,
double sz,
double size,
int resolution,
RenderType currentType,
BooleanSupplier cancelled
) {
return render(sx, sz, size, resolution, currentType, cancelled, true, false);
}
public BufferedImage refineStudioBiome(
double sx,
double sz,
double size,
BufferedImage base,
BooleanSupplier cancelled
) {
Objects.requireNonNull(base, "base");
Objects.requireNonNull(cancelled, "cancelled");
checkCancelled(cancelled);
if (!Double.isFinite(sx) || !Double.isFinite(sz) || !Double.isFinite(size) || size <= 0D
|| base.getWidth() != base.getHeight()) {
throw new IllegalArgumentException("Vision biome refinement requires finite coordinates and a square base image");
}
int resolution = base.getWidth();
BufferedImage image = new BufferedImage(resolution, resolution, BufferedImage.TYPE_INT_RGB);
base.copyData(image.getRaster());
int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
renderRiverAtlas(pixels, resolution, sx, sz, size / resolution, renderer, cancelled, true);
checkCancelled(cancelled);
return image;
}
private BufferedImage render(
double sx,
double sz,
double size,
int resolution,
RenderType currentType,
BooleanSupplier cancelled,
boolean studio,
boolean riverOverlay
) {
if (!Double.isFinite(sx) || !Double.isFinite(sz) || !Double.isFinite(size) || size <= 0D) {
throw new IllegalArgumentException("Vision render coordinates and size must be finite");
@@ -160,23 +102,7 @@ public final class IrisRenderer {
BufferedImage image = new BufferedImage(resolution, resolution, BufferedImage.TYPE_INT_RGB);
int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
double step = size / resolution;
if (studio && currentType == RenderType.HEIGHT) {
renderHeightAtlas(pixels, resolution, sx, sz, step, renderer, cancelled);
return image;
}
if (currentType == RenderType.RIVER) {
Arrays.fill(pixels, NO_RIVER);
renderRiverAtlas(pixels, resolution, sx, sz, step, renderer, cancelled, false);
return image;
}
PixelShader shader = shader(currentType, studio);
if (studio && adaptiveStudioType(currentType)) {
renderAdaptiveAtlas(pixels, resolution, sx, sz, step, shader, cancelled);
if (currentType == RenderType.BIOME && riverOverlay) {
renderRiverAtlas(pixels, resolution, sx, sz, step, renderer, cancelled, true);
}
return image;
}
PixelShader shader = shader(currentType);
int groupSize = sampleGroup(step, resolution);
for (int groupZ = 0; groupZ < resolution; groupZ += groupSize) {
@@ -248,118 +174,19 @@ public final class IrisRenderer {
return Math.max(1, Math.min(resolution, (int) Math.floor(16D / absoluteStep)));
}
private PixelShader shader(RenderType currentType, boolean studio) {
private PixelShader shader(RenderType currentType) {
IrisComplex complex = renderer.getComplex();
return switch (currentType) {
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> biomeShader(
studio ? complex.getBaseBiomeStream() : complex.getTrueBiomeStream(), currentType);
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> biomeShader(complex.getTrueBiomeStream(), currentType);
case BIOME_LAND -> biomeShader(complex.getLandBiomeStream(), currentType);
case BIOME_SEA -> biomeShader(complex.getSeaBiomeStream(), currentType);
case REGION -> regionShader(complex, currentType);
case CAVE_LAND -> biomeShader(complex.getCaveBiomeStream(), currentType);
case HEIGHT -> heightShader(studio ? complex.getNaturalHeightStream() : complex.getHeightStream());
case RIVER -> throw new IllegalArgumentException("River maps render from the water raster atlas, not a pixel shader");
case CONTINENT -> studio
? continentShader(complex.getBaseBiomeStream())
: this::continentColor;
case HEIGHT -> heightShader(complex.getHeightStream());
case CONTINENT -> this::continentColor;
};
}
private static boolean adaptiveStudioType(RenderType type) {
return switch (type) {
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD, BIOME_LAND, BIOME_SEA, REGION, CAVE_LAND,
CONTINENT -> true;
case HEIGHT, RIVER -> false;
};
}
private static void renderAdaptiveAtlas(
int[] pixels,
int resolution,
double startX,
double startZ,
double step,
PixelShader shader,
BooleanSupplier cancelled
) {
int maximumPixels = Math.max(1, Math.min(16, (int) Math.floor(64D / step)));
int blockPixels = Integer.highestOneBit(maximumPixels);
AdaptiveSampler sampler = new AdaptiveSampler(pixels, resolution, startX, startZ, step, shader, cancelled);
for (int pixelZ = 0; pixelZ < resolution; pixelZ += blockPixels) {
int height = Math.min(blockPixels, resolution - pixelZ);
for (int pixelX = 0; pixelX < resolution; pixelX += blockPixels) {
sampler.render(pixelX, pixelZ, Math.min(blockPixels, resolution - pixelX), height);
}
}
}
private static void renderHeightAtlas(
int[] pixels,
int resolution,
double startX,
double startZ,
double step,
Engine engine,
BooleanSupplier cancelled
) {
IrisComplex complex = engine.getComplex();
IrisDimension dimension = engine.getDimension();
double fluidHeight = dimension == null ? 0D : dimension.getFluidHeight();
int maximumPixels = Math.max(1, Math.min(16, (int) Math.floor(64D / step)));
int blockPixels = Integer.highestOneBit(maximumPixels);
HeightSampler sampler = new HeightSampler(
pixels,
resolution,
startX,
startZ,
step,
complex.getNaturalHeightStream(),
engine.getHeight(),
fluidHeight,
cancelled
);
for (int pixelZ = 0; pixelZ < resolution; pixelZ += blockPixels) {
int height = Math.min(blockPixels, resolution - pixelZ);
for (int pixelX = 0; pixelX < resolution; pixelX += blockPixels) {
sampler.render(pixelX, pixelZ, Math.min(blockPixels, resolution - pixelX), height);
}
}
}
private static void renderRiverAtlas(
int[] pixels,
int resolution,
double startX,
double startZ,
double step,
Engine engine,
BooleanSupplier cancelled,
boolean composite
) {
HydrologyRuntime runtime = engine.getComplex().getHydrologyRuntime();
if (runtime == null || !runtime.enabled() || step > WaterMap.MAX_STEP) {
return;
}
WaterMap map = WaterMap.draw(runtime, resolution, startX, startZ, step, cancelled);
map.drawCavePools(GenerationSemanticQueries.recordedCavePools(engine, Math.floorDiv((int) Math.floor(startX), 16),
Math.floorDiv((int) Math.floor(startZ), 16), Math.floorDiv((int) Math.ceil(startX + resolution * step) - 1, 16),
Math.floorDiv((int) Math.ceil(startZ + resolution * step) - 1, 16)));
for (int pixelZ = 0; pixelZ < resolution; pixelZ++) {
for (int pixelX = 0; pixelX < resolution; pixelX++) {
HydrologyFeatureType type = map.at(pixelX, pixelZ);
if (type == null) {
continue;
}
int index = pixelZ * resolution + pixelX;
int color = hydrologyFeatureColor(type);
pixels[index] = composite ? blend(pixels[index], color, RIVER_OVERLAY) : color;
}
}
if (map.provisional()) {
ProvisionalSampling.mark();
}
}
private PixelShader biomeShader(ProceduralStream<IrisBiome> stream, RenderType currentType) {
IdentityHashMap<IrisBiome, Integer> colors = new IdentityHashMap<>();
return (double x, double z) -> {
@@ -403,19 +230,6 @@ public final class IrisRenderer {
return continentColor(biome);
}
private PixelShader continentShader(ProceduralStream<IrisBiome> stream) {
IdentityHashMap<IrisBiome, Integer> colors = new IdentityHashMap<>();
return (double x, double z) -> {
IrisBiome biome = stream.get(x, z);
Integer color = colors.get(biome);
if (color == null) {
color = continentColor(biome);
colors.put(biome, color);
}
return color;
};
}
private int continentColor(IrisBiome biome) {
if (biome == null) {
return GREEN;
@@ -534,254 +348,4 @@ public final class IrisRenderer {
private interface PixelShader {
int color(double x, double z);
}
private static final class AdaptiveSampler {
private final int[] pixels;
private final boolean[] sampled;
private final int resolution;
private final double startX;
private final double startZ;
private final double step;
private final PixelShader shader;
private final BooleanSupplier cancelled;
private AdaptiveSampler(
int[] pixels,
int resolution,
double startX,
double startZ,
double step,
PixelShader shader,
BooleanSupplier cancelled
) {
this.pixels = pixels;
this.sampled = new boolean[pixels.length];
this.resolution = resolution;
this.startX = startX;
this.startZ = startZ;
this.step = step;
this.shader = shader;
this.cancelled = cancelled;
}
private void render(int pixelX, int pixelZ, int width, int height) {
checkCancelled(cancelled);
if (width == 1 && height == 1) {
sample(pixelX, pixelZ);
return;
}
int maximumX = pixelX + width - 1;
int maximumZ = pixelZ + height - 1;
int centerX = pixelX + width / 2;
int centerZ = pixelZ + height / 2;
int color = sample(pixelX, pixelZ);
if (sample(maximumX, pixelZ) == color
&& sample(pixelX, maximumZ) == color
&& sample(maximumX, maximumZ) == color
&& sample(centerX, centerZ) == color) {
fill(pixelX, pixelZ, width, height, color);
return;
}
int leftWidth = Math.max(1, width / 2);
int rightWidth = width - leftWidth;
int topHeight = Math.max(1, height / 2);
int bottomHeight = height - topHeight;
render(pixelX, pixelZ, leftWidth, topHeight);
if (rightWidth > 0) {
render(pixelX + leftWidth, pixelZ, rightWidth, topHeight);
}
if (bottomHeight > 0) {
render(pixelX, pixelZ + topHeight, leftWidth, bottomHeight);
if (rightWidth > 0) {
render(pixelX + leftWidth, pixelZ + topHeight, rightWidth, bottomHeight);
}
}
}
private int sample(int pixelX, int pixelZ) {
int index = pixelZ * resolution + pixelX;
if (!sampled[index]) {
pixels[index] = shader.color(startX + pixelX * step, startZ + pixelZ * step);
sampled[index] = true;
}
return pixels[index];
}
private void fill(int pixelX, int pixelZ, int width, int height, int color) {
for (int row = pixelZ; row < pixelZ + height; row++) {
int start = row * resolution + pixelX;
Arrays.fill(pixels, start, start + width, color);
Arrays.fill(sampled, start, start + width, true);
}
}
}
private static final class HeightSampler {
private static final double MAXIMUM_INTERPOLATION_ERROR = 1.5D;
private final int[] pixels;
private final double[] heights;
private final boolean[] sampled;
private final int resolution;
private final double startX;
private final double startZ;
private final double step;
private final ProceduralStream<Double> stream;
private final double maximumHeight;
private final double fluidHeight;
private final BooleanSupplier cancelled;
private HeightSampler(
int[] pixels,
int resolution,
double startX,
double startZ,
double step,
ProceduralStream<Double> stream,
double maximumHeight,
double fluidHeight,
BooleanSupplier cancelled
) {
this.pixels = pixels;
this.heights = new double[pixels.length];
this.sampled = new boolean[pixels.length];
this.resolution = resolution;
this.startX = startX;
this.startZ = startZ;
this.step = step;
this.stream = stream;
this.maximumHeight = maximumHeight;
this.fluidHeight = fluidHeight;
this.cancelled = cancelled;
}
private void render(int pixelX, int pixelZ, int width, int height) {
checkCancelled(cancelled);
if (width == 1 && height == 1) {
pixels[pixelZ * resolution + pixelX] = heightColor(
sample(pixelX, pixelZ), maximumHeight, fluidHeight);
return;
}
int maximumX = pixelX + width - 1;
int maximumZ = pixelZ + height - 1;
int centerX = pixelX + width / 2;
int centerZ = pixelZ + height / 2;
double topLeft = sample(pixelX, pixelZ);
double topRight = sample(maximumX, pixelZ);
double bottomLeft = sample(pixelX, maximumZ);
double bottomRight = sample(maximumX, maximumZ);
if (matchesPlane(pixelX, pixelZ, width, height, topLeft, topRight, bottomLeft, bottomRight,
centerX, pixelZ)
&& matchesPlane(pixelX, pixelZ, width, height, topLeft, topRight, bottomLeft, bottomRight,
pixelX, centerZ)
&& matchesPlane(pixelX, pixelZ, width, height, topLeft, topRight, bottomLeft, bottomRight,
maximumX, centerZ)
&& matchesPlane(pixelX, pixelZ, width, height, topLeft, topRight, bottomLeft, bottomRight,
centerX, maximumZ)
&& matchesPlane(pixelX, pixelZ, width, height, topLeft, topRight, bottomLeft, bottomRight,
centerX, centerZ)) {
fillPlane(pixelX, pixelZ, width, height, topLeft, topRight, bottomLeft, bottomRight);
return;
}
int leftWidth = Math.max(1, width / 2);
int rightWidth = width - leftWidth;
int topHeight = Math.max(1, height / 2);
int bottomHeight = height - topHeight;
render(pixelX, pixelZ, leftWidth, topHeight);
if (rightWidth > 0) {
render(pixelX + leftWidth, pixelZ, rightWidth, topHeight);
}
if (bottomHeight > 0) {
render(pixelX, pixelZ + topHeight, leftWidth, bottomHeight);
if (rightWidth > 0) {
render(pixelX + leftWidth, pixelZ + topHeight, rightWidth, bottomHeight);
}
}
}
private boolean matchesPlane(
int pixelX,
int pixelZ,
int width,
int height,
double topLeft,
double topRight,
double bottomLeft,
double bottomRight,
int sampleX,
int sampleZ
) {
double predicted = interpolate(
pixelX,
pixelZ,
width,
height,
topLeft,
topRight,
bottomLeft,
bottomRight,
sampleX,
sampleZ
);
return Math.abs(sample(sampleX, sampleZ) - predicted) <= MAXIMUM_INTERPOLATION_ERROR;
}
private void fillPlane(
int pixelX,
int pixelZ,
int width,
int height,
double topLeft,
double topRight,
double bottomLeft,
double bottomRight
) {
for (int row = pixelZ; row < pixelZ + height; row++) {
int offset = row * resolution;
for (int column = pixelX; column < pixelX + width; column++) {
double value = interpolate(
pixelX,
pixelZ,
width,
height,
topLeft,
topRight,
bottomLeft,
bottomRight,
column,
row
);
pixels[offset + column] = heightColor(value, maximumHeight, fluidHeight);
}
}
}
private double sample(int pixelX, int pixelZ) {
int index = pixelZ * resolution + pixelX;
if (!sampled[index]) {
heights[index] = stream.getDouble(startX + pixelX * step, startZ + pixelZ * step);
sampled[index] = true;
}
return heights[index];
}
private static double interpolate(
int pixelX,
int pixelZ,
int width,
int height,
double topLeft,
double topRight,
double bottomLeft,
double bottomRight,
int sampleX,
int sampleZ
) {
double x = width <= 1 ? 0D : (sampleX - pixelX) / (double) (width - 1);
double z = height <= 1 ? 0D : (sampleZ - pixelZ) / (double) (height - 1);
double top = topLeft + (topRight - topLeft) * x;
double bottom = bottomLeft + (bottomRight - bottomLeft) * x;
return top + (bottom - top) * z;
}
}
}
@@ -19,5 +19,5 @@
package art.arcane.iris.studio.render;
public enum RenderType {
BIOME, BIOME_LAND, BIOME_SEA, REGION, CAVE_LAND, RIVER, HEIGHT, OBJECT_LOAD, DECORATOR_LOAD, CONTINENT, LAYER_LOAD
BIOME, BIOME_LAND, BIOME_SEA, REGION, CAVE_LAND, HEIGHT, OBJECT_LOAD, DECORATOR_LOAD, CONTINENT, LAYER_LOAD
}
@@ -53,12 +53,6 @@ final class WaterMap {
provisional = true;
}
static WaterMap draw(HydrologyRuntime runtime, int resolution, double startX, double startZ, double step, BooleanSupplier cancelled) {
WaterMap map = new WaterMap(runtime, resolution, startX, startZ, step);
map.advance(cancelled);
return map;
}
void advance(BooleanSupplier cancelled) {
if (!provisional) {
return;