Skip to content

Add biome-specific ocean height and relative ocean height - #3427

Open
MrPiedPiper wants to merge 5 commits into
PixelGuys:masterfrom
MrPiedPiper:biome_water_levels
Open

Add biome-specific ocean height and relative ocean height#3427
MrPiedPiper wants to merge 5 commits into
PixelGuys:masterfrom
MrPiedPiper:biome_water_levels

Conversation

@MrPiedPiper

@MrPiedPiper MrPiedPiper commented Jul 26, 2026

Copy link
Copy Markdown

Changes:

  • Add new biome fields oceanHeight, liquidBlock, isOceanRelative, relativeOceanGap, and relativeOceanOffset.
  • Adjust surface structures to biome ocean height (relative ocean surface structures are not yet supported)

Ocean features:

  • Oceans can be made of any block, at any height.
  • Oceans can instead be relative to topmost blocks. Distance between ocean levels in the biome is chosen using relativeOceanGap, with offsets available using relativeOceanOffset. This is best used for small pools, as happening to aligning with biome height for deeper oceans is not likely.
  • Walls form to contain oceans. If neighboring oceans are compatible (based on ocean height and liquid block), no wall will form.
  • Caves are now supported via isOceanRelative

Performance:

I tested performance on master vs this update in 5 different newly generated worlds.
I started each world, waiting until generation finished, and noted the average time.

Master:
Seeds 0, 1, 2, 3 and 4 average time: 468451.1438742311

This update:
Seeds 0, 1, 2, 3 and 4 average time: 472425.7381765770
0.85% added time to generation

This update with more extreme settings applied to all biomes for a stress-test (oceanHeight 20, isOceanRelative true, relativeOceanGap 3, relativeOceanOffset 7)
Seeds 0, 1, 2, 3 and 4 average time: 542972.4462500415
15.91% added time to generation

Code used for benchmarks copied from BoringOrng here:

var sum: i96 = 0;
var count: usize = 0;

...
	const t1 = main.timestamp();

	defer {
		count += 1;
		sum += main.timestamp().nanoseconds - t1.nanoseconds;

		if (count%10 == 0)
			std.log.debug("avg gen_time: {}", .{@as(f64, @floatFromInt(sum))/@as(f64, @floatFromInt(count))});
	}

This was placed into the top of TerrainGenerator.zig's generate function.

@MrPiedPiper

Copy link
Copy Markdown
Author

Known issue: if an ocean is 128+ blocks above a surface block the ocean can be cut-off by a cave biome (e.g. sky). I figure I can/should make that a separate change.

@MrPiedPiper

Copy link
Copy Markdown
Author

Should close #570

@MrPiedPiper

MrPiedPiper commented Jul 26, 2026

Copy link
Copy Markdown
Author

Vanilla biomes with small modifications as an example:

cubyz:grasslands with

	.oceanHeight = 3,
	.relativeOceanGap = 8,
	.relativeOceanOffset = -3,
	.isOceanRelative = true,
grassland

cubyz:volcano/peak with

	.isOceanRelative = true,
	.liquidBlock = "cubyz:lava",
	.oceanHeight = 20,
	.relativeOceanGap = 64,
	.relativeOceanOffset = 15,
volcano

A completely different volcano because I couldn't find the first one again

volcano2

cubyz:cave/mantle/lava_pool with

	.liquidBlock = "cubyz:lava",
	.oceanHeight = 3,
	.relativeOceanGap = 6,
	.isOceanRelative = true,
	.ground_structure = .{
		"1 to 2 cubyz:magma",
	},

(note I removed the lava from the ground_structure)

mantle

@Wunka Wunka moved this to Low Priority in PRs to review Jul 27, 2026
@MrPiedPiper

Copy link
Copy Markdown
Author

Apparently that did not in-fact fix walls not forming right... I'll get that fixed up.

@IntegratedQuantum

Copy link
Copy Markdown
Member

Let's say I want to fill a cubyz:decorative/stone_pit biome with lava, how would I go about this?
I tried a few things based on the volcano example you made, but I think the current system is too limited for it (note that stone pits can spawn at any height).
Screenshot at 2026-07-30 20-13-18
I think we'd need a mode that allows you to set it up relative to the biome's base height, but that is not currently accessible anywhere.

@MrPiedPiper

MrPiedPiper commented Jul 30, 2026

Copy link
Copy Markdown
Author

Unfortunately, in this PR's current form, it's best suited for small pools or preset heights. The best I can think of for a cubyz:decorative/stone_pit would be something like this (I forgot to change it to lava):
stone_pit
It's the default stone pit with these added

	.oceanHeight = 4,
	.relativeOceanGap = 3,
	.isOceanRelative = true,

I agree, having access to the base biome height would be a real game-changer. I assume that'd mean attaching that information to another pre-existing system. I could look into adding that 👍

Is that sort of information something that would belong in MapFragment?

@IntegratedQuantum

Copy link
Copy Markdown
Member

Is that sort of information something that would belong in MapFragment?

Yes. Ideally all points on the map, instead of indexing the biome directly should index a palette of biomes, which could contain the base height of the biome and its biome seed (#431).

If you want to go for this, I'd suggest to make a separate PR for this.
In the mean time I'd like to get some artist opinion on the current system and parameters.

@IntegratedQuantum IntegratedQuantum moved this from Low Priority to Waiting for artistic review in PRs to review Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting for artistic review

Development

Successfully merging this pull request may close these issues.

3 participants