Make the biome transition smooth

fixes #1107
This commit is contained in:
IntegratedQuantum 2025-02-24 20:47:55 +01:00
parent 43b6d9e5a0
commit ba50014acd

View File

@ -94,8 +94,8 @@ pub fn generateMapFragment(map: *MapFragment, worldSeed: u64) void {
const wy: f32 = @floatFromInt(y*map.pos.voxelSize + map.pos.wy); const wy: f32 = @floatFromInt(y*map.pos.voxelSize + map.pos.wy);
const offsetX = (xOffsetMap.get(x, y) - 0.5)*offsetScale; const offsetX = (xOffsetMap.get(x, y) - 0.5)*offsetScale;
const offsetY = (yOffsetMap.get(x, y) - 0.5)*offsetScale; const offsetY = (yOffsetMap.get(x, y) - 0.5)*offsetScale;
var updatedX = wx + offsetX; const updatedX = wx + offsetX;
var updatedY = wy + offsetY; const updatedY = wy + offsetY;
var xBiome: i32 = @intFromFloat(@floor((updatedX - @as(f32, @floatFromInt(map.pos.wx)))/biomeSize)); var xBiome: i32 = @intFromFloat(@floor((updatedX - @as(f32, @floatFromInt(map.pos.wx)))/biomeSize));
var yBiome: i32 = @intFromFloat(@floor((updatedY - @as(f32, @floatFromInt(map.pos.wy)))/biomeSize)); var yBiome: i32 = @intFromFloat(@floor((updatedY - @as(f32, @floatFromInt(map.pos.wy)))/biomeSize));
const relXBiome = (0.5 + offsetX + @as(f32, @floatFromInt(x*map.pos.voxelSize -% xBiome*biomeSize)))/biomeSize; const relXBiome = (0.5 + offsetX + @as(f32, @floatFromInt(x*map.pos.voxelSize -% xBiome*biomeSize)))/biomeSize;
@ -156,8 +156,6 @@ pub fn generateMapFragment(map: *MapFragment, worldSeed: u64) void {
// Select a biome. Also adding some white noise to make a smoother transition. // Select a biome. Also adding some white noise to make a smoother transition.
updatedX += random.nextFloatSigned(&seed)*3.5*biomeSize/32;
updatedY += random.nextFloatSigned(&seed)*3.5*biomeSize/32;
xBiome = @intFromFloat(@round((updatedX - @as(f32, @floatFromInt(map.pos.wx)))/biomeSize)); xBiome = @intFromFloat(@round((updatedX - @as(f32, @floatFromInt(map.pos.wx)))/biomeSize));
xBiome += offset; xBiome += offset;
yBiome = @intFromFloat(@round((updatedY - @as(f32, @floatFromInt(map.pos.wy)))/biomeSize)); yBiome = @intFromFloat(@round((updatedY - @as(f32, @floatFromInt(map.pos.wy)))/biomeSize));