I’ve recently been working on 3D infinite terrain generation, but when it generates the new layer of blocks, it runs awkwardly slow (0.5 fps). I’m not expecting it to run fast, but I think id should be able to get around 10 fps when I’m rendering. Just a quick rundown of how my code works, I have 5x 5 grid of meshes, each composed of a 10 x 10 grid of noise height values (vertices within the mesh). when i reach the point where it is triggered to regenerate, it moves all the meshes in the 5 x 5 grid down one and generates a new layer. Any help on how to speed this up would be appreciated. Also, thanks @Ignatz for the lighting shader.
We have some similarities in the code, but the main difference is that I make the noise-calculation in the vertex shader rather than in Lua. Then I use a 3x3 grid of meshes which I move according to the camera with some messy code so that the camera always is above the middle grid.
Each vertex height position is then calculated with the function h() in the shader taking the offset information from Lua that specifies where the grid-item is positioned in the world to generate correct perlin noise values that match neighbour grid meshes.
Tell me if you need some more explanations. It would be interesting to see improvements in speed and artistic value with some fog and such. You should be able to remove some draw calls to meshes depending on the camera direction, but I have ignored that for now,
It’s not generating it, but working off a height map, with some mojo for precooking lighting. The lightmap generation is slow, and the heightfield is fixed (I’ve done some work, but it’s parked at the mo on heightfield generation), but the rendering is fairly efficient.
It uses a quad tree for culling unseen areas, and a single fixed mesh with vertex processing for heights for the drawing with differing resolution depending how close to the camera it is.
Code is dirty, but it might provide some ideas. (all free as I got most of it off the web anyway)