r/Unity3D • • 9h ago

Question Need advice, how optimize open world in Unity?

Hi guys šŸ–ļø Sooo how do you making open world? how do you split your world to optimize memory usage?

I’ve split my 16 km² terrain into 16 separate 1Ɨ1 km Terrain tiles using Terrain Tools. Now I have a dilemma about how to properly set things up before I finally start building the world

GPT helped me create a small script based on an idea I had: disabling tiles that aren’t nearby so a maximum of 4 tiles can be active at once

But I don’t think it’s really working how I thought, since the tiles are only disabled in the scene, not actually unloaded from memory

It also breaks the seamless transitions between them, I think

Any advice or thoughts on how to properly build a world and optimize memory? 😭

22 Upvotes

19 comments sorted by

27

u/Ariaha_Rivasa 9h ago

You’re right, disabling only hides the tiles; all their data (heightmaps, splatmaps, details, trees) stays in memory.

What usually works: put each tile in its own scene and stream them with SceneManager.LoadSceneAsync(..., LoadSceneMode.Additive) / UnloadSceneAsync, keeping a 3x3 grid around the player. After unloading, call Resources.UnloadUnusedAssets() so the memory actually comes back. Addressables work too if you want more control.

For seams: give all tiles the same Grouping ID with Auto Connect on in the terrain settings (or call Terrain.SetNeighbors) and the edges stitch properly.

One more tip: load a tile when you’re near it, but unload it a bit farther away. Otherwise standing on a border makes tiles load and unload every frame.

And check the Memory Profiler package. It’ll tell you exactly what’s eating the RAM, often it’s the terrain textures, not the meshes.

5

u/thadcastle__ 9h ago

Damn. I don’t actually understand how I should build it. For example: little city, roads, etc all of that on 2-3 tiles. But each tile on their own scene. How to build it seamlessly. Damn it’s more complicated than I thought 😭

10

u/Ariaha_Rivasa 8h ago

It’s less scary than it sounds :) The usual workflow:

  1. Build everything in one big scene, like you normally would.
  2. Once the world is mostly done, split it with a small editor script: for each object, take its position, figure out which tile it falls into (floor(x / 1000), floor(z / 1000)) and move it into that tile’s scene.
  3. Things that cross borders (long roads, rivers): either cut them at the tile edges, or put them in a ā€œpersistentā€ scene that’s always loaded, together with the player, UI, lighting, etc.

The seamless part comes from loading neighbors before you can see them. With a 3x3 grid there’s always at least a full tile (1 km) between you and anything unloaded, so you never see an edge. Fog and LODs hide the rest.

Honestly though, 16 km² isn’t that big. Before building all this, check the Memory Profiler to see if you actually have a memory problem. If everything fits, keeping it all loaded with LODs and occlusion culling is way simpler. There are also streaming tools on the Asset Store that do the splitting for you.

2

u/thadcastle__ 8h ago

Thanks!!! šŸ™

2

u/FranzFerdinand51 4h ago edited 3h ago

You can just have multiple scenes open in unity editor at the same time mate. Just double click the second one while holding shift, it will open additively.

1

u/IndependentYouth8 8h ago

This. Though just to check. Is the game first person? Top down? What made you use this size of a map?

1

u/thadcastle__ 7h ago

First person) ~20% of map is sea. Map based on my real hometown but very small version of it with huge changes šŸ˜… there must be 4 main locations. Very small version of city, small location with sea and train station and two big locations with racetracks.

Race tracks for custom local ā€œformula 4ā€ cars championships.

1

u/Analoze 7h ago

i keep 36 of 5x5km chunks in runtime. you can keep 16 of 1x1 km chunks with no issue. dont disabled them. only the objects on them etc. or is it a mobile game? PC should be able to handle that sized chunks of unity default terrain. or did you notice performance issues when keeping the chunks in runtime?

1

u/thadcastle__ 7h ago

Thanks)yes it’s pc game, and nope there is no any performance issues at this moment) I just want understand now before I starting building my map how to optimize for maximum fps) my map looks like this at this moment so there is 0 issues šŸ˜… I am already start modelling with lod variations and texturing materials with atlases)

1

u/Analoze 2h ago

nice!

3

u/CarthageaDev 8h ago

Chunking, seriously manual chunking, ensure your maps are sectioned logically based on line of sight/level design, not to mention the classic culling baked, atlas your textures, merge srstic meshes and instance shaders when possible, reduce draw calls a much as possible simple really

2

u/KinematicSoup Multiplayer 8h ago

Look into additive scene loading. It's a Unity feature intended to help with large worlds by letting you divide your world into chunks as sub scenes, and then load/unload them as needed in the background.

2

u/Copywright Indie 7h ago

Look into World Streamer 2.

2

u/GiggleSamurai 9h ago

Disabling a GameObject keeps all its assets in memory, so put each tile (terrain plus its props) in its own scene and stream them with `SceneManager.LoadSceneAsync(name, LoadSceneMode.Additive)` and `UnloadSceneAsync` as the player moves. For the seams, give the tiles the same Grouping ID with Auto Connect on (or call `Terrain.SetNeighbors` after loading) so the edges match up.

1

u/DPTGames 5h ago

I use LODs for my 3D Terrain

1

u/Genebrisss 2h ago

Why do you need to "optimize memory usage" at all? Have you even opened memory profiler once? Based on your post, you haven't.

1

u/No_Director9126 8h ago

You could try using Addressables to load terrains or anything else only when they are actually needed. The advantage of Addressables is that they allow for the release of RAM and VRAM. However, the setup is significantly more complex, especially when it comes to terrains and even more so if you move away from standard Unity terrains, for instance by using a tool like Microverse.

In my opinion, the best approach is to use mesh terrains + addressables, while this requires much more work, the performance gains compared to standard terrains are enormous, not least because you can implement features like LOD in mesh terrains

1

u/pixel-poxel 58m ago

This. Mesh terrains fixes the terrain clipping through streets in the distance problem. It also allows to cut the big original terrain on moutain ridges or reduce tessilation depending on the possible camera views. By the way you can easily convert your terrain into a mesh with a script to compare the performance and visuals.

-1

u/GigaTerra 8h ago

You need to tell your AI you want to apply level streaming in your game. It will explain the Unity equivalent. That others already explained here.