r/howdidtheycodeit • • Jul 30 '22
how to games create large worlds?
I am not talking about purely procedural worlds like Minecraft that use algorithms like perlin noise to generate infinite or near infinite terrain. I am talking about games or worlds that are non procedural like gta 5 or partially non procedural. How are these worlds made so that they have good performance on average devices?
45
Upvotes
67
u/loofou Jul 30 '22
The same way as procedural worlds: Chunks and smart LOD. You basically try to limit the world to only what's relevant to the player right now. Can't see behind the wall? Unload it. That mountain on the other side of the map? Super simple 500 poly mesh.
Once you get closer to objects and their relevancy and size on screen increases, you also replace them with higher poly meshes and start to load it n more detail.
When you are in the North of the map in GTA 5, the entire city in the south is just a few super simple meshes and some blurry dots to fake lights and movement of cars. This entire "chunk" of the map is replaced with something that looks like the city, but is in fact nothing but smoke and mirrors :)
13
u/Fribbtastic Jul 30 '22
Have you ever wondered why textures or objects pop up on the screen when you move through a game sometimes?
Because of that.
To use a more visual example, I found the gif below very informative about this
https://i.pinimg.com/originals/75/29/61/752961eee18960334f3a42d7cab7934e.gif
As you can see, the bluish cone is the camera the player is looking at, you can also see that chunks are being loaded when the camera is getting close to them and unloaded when it gets further away.
What you can't see is a feature called LOD or "level of detail". This basically is used to change the, well, level of detail on an object depending on the distance to the camera. The further away the camera is, the less detailed the object needs to be because you wouldn't be able to see that detail anyway.
3
u/LiverLipsMcGrowll Jul 30 '22
One element is task management. You cant switch from low resolution to high all on one frame. Too much data needs to be loaded from disk and the interface from disk->ram->gpu is relatively slow. Thats why you see things load in over time when you zip across a game like GTAV. Instead of a loading screen you spread out the process into smaller chunks with different priorities that can be processed without framerate drops.
7
u/Narkata55 Jul 30 '22
I'll let someone more qualified speak on the specifics, but in general it comes down to compression, clever layout of assets, and the fact that the games you're referring to are actually pretty massive in file size (especially compared to older games and games with much smaller maps)
There's no getting around the fact that bigger worlds need more disk space than smaller worlds (all other things equal) but:
For performance, that generally just comes down to efficient multithreading and loading/unloading of data. Predicting where a player will go, only loading in what they are near to, and culling/unloading things as they go off-screen/get too far respectively, all go a long way to helping performance. But there is a bottleneck at a certain point: you're not running GTA 5 on a Blackberry anytime soon
0
u/[deleted] Jul 30 '22
People have said a lot about level of detail and chunk loading, but in practice game designers have various platforms they can use to write a game. Unity is popular and free to play around with. Unreal Engine is used on tons of games. There are others…These design platforms provide a sandbox with a set of rules, like physics, and frequently some art assets to get started with. Some provide a way to create additional assets. Additional programs can also be used to generate assets including hand drawing. Assets are building blocks. A bush is an asset. A table. The wall. A gun. The shop keeper. Assets are characters and things. The designer positions these assets in a sandbox and creates map elements by shaping the sandbox elements similar to how you would manipulate any 3D model such as in Sketchup. This can happen in 2d or in 3D. Placeholder shapes can exist that more detailed skins are plastered over as artist talent and processing power allow. If the world is large then there are a lot of models. Batman Arkham is a good example. The programmers created buildings and walls and decorated everything to create Gotham. One piece at a time. Arkham is also a great example of the things others have been talking about with its use of Scaleform and other design tools.
Tldr; they make models and place them in a sandbox.