Best way to render procedural worlds?

I’m creating a minecraft-type world, and I’m struggling to get chunks to load without freezing the game for 1-2 seconds. When my player moves, I need new chunks to render. I started off trying to load and render a full chunk column (16 chunks) at each tick, but the game freezes for like 10 seconds. So now I’ve tried load and render a single chunk each tick. The game still freezes for around a second each time a new chunk loads. What do you do to get around this problem?

My game is here: https://github.com/JoshPJackson/BlockGame
The rendering code is in the Render method in Game.cs https://github.com/JoshPJackson/BlockGame/blob/master/Assets/Scripts/Game.cs

The render code has nothing to do with it. It sounds like your loading code is way too slow. I would check and see if you can speed that up (maybe you need to use some run-length encoding in your storage format, for example). If not (or maybe even if so), you’ll just have to move the loading into a separate thread (which is a bit thorny since you can’t access Unity APIs off the main thread, but it can be done).

Hi Joe, what is run-length encoding?

Wikipedia explains it better than I can. :slight_smile: