Performance: Terrain system basics
This affects the page load speed and rendering performance by how terrain data is loaded, rendered, and updated in the game scene.
Use Terrain LOD groups or split terrain into smaller chunks with culling and LOD. Example: Use Unity's Terrain LOD system or custom chunk loading scripts.
Terrain terrain = Terrain.activeTerrain; terrain.terrainData.size = new Vector3(10000, 600, 10000); // No LOD or chunking, full terrain rendered at once
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single large terrain without LOD | N/A (game objects) | High GPU reflows | Very high paint cost | [X] Bad |
| Terrain with LOD and chunking | N/A (game objects) | Minimal GPU reflows | Reduced paint cost | [OK] Good |
var terrainData = new TerrainData();
float[,] heights = new float[2,2] { {0.1f, 0.2f}, {0.3f, 0.4f} };
terrainData.SetHeights(0, 0, heights);
float height = terrainData.GetHeight(0, 0);TerrainData terrainData = new TerrainData();
float[,] heights = new float[2,2] { {0.1f, 0.2f}, {0.3f, 0.4f} };
terrainData.SetHeights(0, 0, heights);Pass the test and this pattern moves unknown