How to load stacking chunks on the fly? (545759)

First: I’m not sure if this is the correct sub-forum for this question. Please feel free to move it to the correct place.

I’m currently working on an infinite world, mostly inspired by minecraft.
A Chunk consists of 16x16x16 blocks. A block(cube) is 1x1x1.

This runs very smoothly with a ViewRange of 12 Chunks (12x16) on my computer. Fine.
When I change the Chunk height to 256 this becomes - obviously - incredible laggy.

So what I basically want to do is stacking chunks. That means my world could be [∞,16,∞] chunks large.

The question is now how to generate chunks on the fly?
At the moment I generate not existing chunks circular around my position (near to far). Since I don’t stack chunks yet, this is not very complex.

As important side note here: I also want to have biomes, with different min/max height. So in Biome Flatlands the highest layer with blocks would be 8 (8x16) - in Biome Mountains the highest layer with blocks would be 14 (14x16). Just as example.

What I could do would be loading 1 Chunk above and below me for example.
But here **the problem would be, that transitions between different bioms could be larger than one chunk on y.

My current chunk loading in action

For the completeness here my current chunk loading “algorithm”

  private IEnumerator UpdateChunks(){
        for (int i = 1; i < VIEW_RANGE; i += ChunkWidth) {
            float vr = i;
            for (float x = transform.position.x - vr; x < transform.position.x + vr; x += ChunkWidth) {
                for (float z = transform.position.z - vr; z < transform.position.z + vr; z += ChunkWidth) {

                    _pos.Set(x, 0, z); // no y, yet
                    _pos.x = Mathf.Floor(_pos.x/ChunkWidth)*ChunkWidth;
                    _pos.z = Mathf.Floor(_pos.z/ChunkWidth)*ChunkWidth;

                    Chunk chunk = Chunk.FindChunk(_pos);
              
                    // If Chunk is already created, continue
                    if (chunk != null)
                        continue;

                    // Create and load a new Chunk..
                    chunk = (Chunk) Instantiate(ChunkFab, _pos, Quaternion.identity);
                }
            }
            // Skip to next frame
            yield return 0;
        }
    }

This is basically a repost of this question on answer

Well just iterate over 3d coords insted of 2d if u want to stack chunks.
If i recall correctly minecraft doesn’t stack chunks, but uses a fixed height of ex: 256. But both solutions should be doable. I would recommend doing the generation on a background thread to prevent any fps drops when loading chunks.

I wouldn’t go the route of having chunks with different resolutions, that sounds like alot of work with making sure there’s a valid transistion between resolutions.

    for(int i = -xzViewRange; i < xzViewRange; i+= chunkWidth)
     {
       for(int j = -viewHeight; j < viewHeight; j+= chunkHeight)
       {
         for(int l = -xzViewRange; l < xzViewRange; l+= chunkLength)
         {
           float x = Mathf.Floor( (this.transform.position.x + i) / chunkWidth ) * chunkWidth;
           float y = Mathf.Floor( (this.transform.position.y + j) / chunkHeight ) * chunkHeight;
           float z = Mathf.Floor( (this.transform.position.z + l) / chunkLength ) * chunkLength;
           if( ! ChunkExists(x,y,z) )
             CreateChunk(x,y,z);
         }
       }
     }