Insprill/dv-mapify

Procedural map generation fails for maps larger than 16x16km

Opened this issue · 2 comments

We need a different approach to generating the height map, since a single texture can't be more than 16x16k pixels.

This only affects the map item?
We could simply, on larger sizes, average pixels.
So instead of doing it 1m = 1px, we'd average a 2x2 square into a single pixel. Bigger even, 4x4, etc.

Yeah, it's only items. It depends on the terrain resolution as well, since that's what determines the texture size.

int heightmapResolution = terrains[0].terrainData.heightmapResolution;
int terrainWidth = heightmapResolution - 1;
int totalWidth = terrainWidth * Mathf.CeilToInt(Mathf.Sqrt(terrainCount));
Texture2D combinedTexture = new Texture2D(totalWidth, totalWidth, TextureFormat.RGBA32, false);

That's a pretty bad way of doing it, and we should instead pack it into a 4k texture, then smooth the value on small maps and down sample it on larger ones.