Handle resolution and biome blending

This commit is contained in:
Astrash
2022-08-07 11:46:55 +10:00
parent bc324df7ca
commit d170b4e0fd
4 changed files with 16 additions and 11 deletions

View File

@@ -54,6 +54,6 @@ public class BiomePipelineTemplate implements ObjectTemplate<BiomeProvider> {
@Override
public BiomeProvider get() {
return new PipelineBiomeProvider(new PipelineImpl(source, stages, 10), resolution, blendSampler, blendAmplitude);
return new PipelineBiomeProvider(new PipelineImpl(source, stages, resolution, 500), resolution, blendSampler, blendAmplitude);
}
}

View File

@@ -15,11 +15,13 @@ public class BiomeChunkImpl implements BiomeChunk {
private PipelineBiome[][] biomes;
private final SeededVector worldOrigin;
private final int chunkOriginArrayIndex;
private final int worldCoordinateScale;
public BiomeChunkImpl(SeededVector worldOrigin, PipelineImpl pipeline) {
this.worldOrigin = worldOrigin;
this.chunkOriginArrayIndex = pipeline.getChunkOriginArrayIndex();
this.worldCoordinateScale = pipeline.getResolution();
int size = pipeline.getArraySize();
@@ -86,11 +88,11 @@ public class BiomeChunkImpl implements BiomeChunk {
}
private int xIndexToWorldCoordinate(int xIndex) {
return worldOrigin.x() + xIndex - chunkOriginArrayIndex;
return (worldOrigin.x() + xIndex - chunkOriginArrayIndex) * worldCoordinateScale;
}
private int zIndexToWorldCoordinate(int zIndex) {
return worldOrigin.z() + zIndex - chunkOriginArrayIndex;
return (worldOrigin.z() + zIndex - chunkOriginArrayIndex) * worldCoordinateScale;
}
protected static int initialSizeToArraySize(int expanderCount, int initialSize) {

View File

@@ -74,14 +74,11 @@ public class PipelineBiomeProvider implements BiomeProvider {
public Biome getBiome(int x, int z, long seed) {
// x += mutator.noise(seed + 1, x, z) * noiseAmp;
// z += mutator.noise(seed + 2, x, z) * noiseAmp;
// x /= resolution;
// z /= resolution;
x += mutator.noise(seed + 1, x, z) * noiseAmp;
z += mutator.noise(seed + 2, x, z) * noiseAmp;
// x *= resolution;
// z *= resolution;
x /= resolution;
z /= resolution;
int chunkX = FastMath.floorDiv(x, chunkSize);
int chunkZ = FastMath.floorDiv(z, chunkSize);

View File

@@ -19,10 +19,12 @@ public class PipelineImpl implements Pipeline {
private final int expanderCount;
private final int arraySize;
private final int chunkOriginArrayIndex;
private final int resolution;
public PipelineImpl(Source source, List<Stage> stages, int idealChunkArraySize) {
public PipelineImpl(Source source, List<Stage> stages, int resolution, int idealChunkArraySize) {
this.source = source;
this.stages = stages;
this.resolution = resolution;
this.expanderCount = (int) stages.stream().filter(s -> s instanceof Expander).count();
// Optimize for the ideal array size
@@ -79,4 +81,8 @@ public class PipelineImpl implements Pipeline {
public int getChunkOriginArrayIndex() {
return chunkOriginArrayIndex;
}
public int getResolution() {
return resolution;
}
}