No Procedural Terrain without lags?


Im playing around with procedural terrain generation forever now.
But somehow I can never get something to work without lag - is it just not possible in unity or what?
Even if just a simple Terrain Object is created one after one, unity lags - afaik its not possible to do this multithreaded because it has to happen in the unity’s main thread.
Im now playing around with TerrainToolkit and create procedural terrains. As you can imagine calculations done by the toolkit take forever, applying the heightmap to a terrain also. Im sure the calculations could be done on the GPU, but applying a heightmap to a terrain not right?

So how does some guys get it to work, i see some vids on youtube and so where there is no lag - how is that possible?
Just simple object creation in unity (whatever object) without getting a lag …

Thanks in advance

I may not be the best person too answer this. but nobody else has so I’ll try.

I’m not very experienced but I’ve been looking into voxels recently.

In a tutorial I watched the presenter used
“IEnumerator” as a function name for building the mesh, saying it would cause the the mesh calculations to be done in the background
he had to make it “yield return 0;” at the end, whatever that means.

however even with that system there was still some Lag generated because unity had to calculate the noise for the mesh.

You can generate all the terrain data and heightmaps in a new thread, then just apply the data to the terrain in the main thread.