- Home /
Terrain Chunk loading
I am working on a project that create mesh chunks of terrain generated with procedural noise, and i tried a couple of ways which lead to, chunks loading in the distance before loading near the player and performance issues. So i needed some help. My questions are:
What would be the best way to load and unload chunks even with a fast moving player?
How can I prioritize chunk loading on player distance
Answer by TonyLi · May 08, 2013 at 04:39 PM
Here are some ideas:
Sort the chunks-to-be-loaded by distance and direction the player is moving. It's more important to load chunks in front of the player than behind him. For distance, you can compute distance squared; no need to waste time on the square root operation.
Load more chunks in front of the player, or more chunks in a larger radius around the player, so they don't pop into view close to the player's camera, and the game has a chance to load enough chunks in front of a fast-moving player.
Pre-generate some terrain patterns and reuse them (perhaps rotating them for variety) instead of apply procedural noise at runtime. Or, if you really want to compute the noise at runtime, you could fall back to pregenerated chunks only if the loader is falling behind.