Have you ever wondered how minecraft worlds were generated probably since you clicked on this video well to find out i mined through the minecraft source code to dig up some answers and crafted this video to share them with you before we begin if you haven’t seen my previous terrain generation video it Might be a good idea to watch that one before continuing with this one in that one i cover a lot of the fundamentals of terrain generation by coding a procedurally generated 3d landscape from scratch and this video will be building on a lot of the foundational concepts introduced in that video Without further ado let’s get started if you’re watching this video you’re probably already familiar with minecraft worlds but before we get into the details of how they’re generated we should first cover some quick background the first thing to know about minecraft worlds is that they are huge each world extends for 30 million Blocks in every direction except for height and since each block represents one square meter this means that a single minecraft world has a surface area about eight times the size of the surface of the earth that’s a whole lot of terrain to generate that would already be Pretty impressive if there was only a single minecraft world but there are actually around 2.8 trillion different possible worlds that can be generated and each one is unique this is a mind-boggling amount of content and what is especially impressive is that it comes in a shockingly small package While most modern games are tens or even hundreds of gigabytes minecraft fits all of these worlds in only a few hundred megabytes this is only possible because minecraft doesn’t store the worlds themselves it only stores the instructions to make them minecraft terrain like most 3d terrain in video games Is entirely based on noise when you begin the game a random 64-bit number called a seed is generated or chosen by the player and this seed is used to generate the world different seeds will produce different worlds and if you use the same seed you’ll always get the same result At least in the same version of minecraft as the details of terrain generation change from version to version this seed is used to generate noise functions which are used to control every aspect of the world i talked a lot about noise functions in my previous video but the main idea is that these Functions are random in the sense that you can’t predict what you’re going to get from them but they’re smooth the value you get depends on the values around it rather than each one being independent these functions determine everything from the height of the terrain to where different biomes are located To the location of ore clusters and underground strongholds now that we have that background info out of the way let’s get into the nitty gritty details minecraft terrain generation really happens at two different levels the individual chunk and the wider world as a whole it’s kind of like a jigsaw puzzle the Chunks that make up the world are the individual puzzle pieces and it’s only when they all come together that you begin to see a complete picture but before we can put the pizzas together we need to look at how each piece is made minecraft worlds don’t generate all at once But rather one chunk at a time a minecraft chunk is a 16 by 16 block area that stretches all the way down to the bedrock and all the way up to the build limit making them a total of 256 blocks high when you first join a minecraft world it Only generates a 16 by 16 chunk area these are called the spawn chunks then as you explore the world new chunks will be generated around you to create the illusion of a massive seamless world when generating a chunk minecraft goes through several stages these stages can be roughly divided into height map generation Oars adding surface blocks carving and adding structures and decorations during the height map stage the world is only made of three types of blocks stone water and air this stage is just about figuring out the general shape of the terrain without worrying about what anything should be made of All land is stone anything below y equals 63 is filled with water and the rest is just air you can sort of distinguish different biomes by the shape of the terrain as every biome is generated differently but at this stage everything looks pretty similar after this is what i call the ore stage Where the general structure of the world stays the same but a wider variety of materials can now be found instead of everything being made of purely cobblestone different types of stone dirt and even oars can be found the next stage replaces the top layer of blocks and adds a surface to the world It’s at this stage that the different biomes really start to stand apart from one another as depending on the biome the surface might be replaced with grass sand or other materials this is followed by the carving stage up until this point each chunk is basically well A solid chunk of blocks where the only thing that varies is height and material in my previous video i talked about the limitations of using height maps for terrain generation you can only move things up and down but you’re pretty limited in the kinds of 3d shapes that you can get The carving stage is where minecraft handles these limitations by literally carving away parts of the landscape to produce more interesting 3d effects it’s in this stage that you start to get things like caves ravines and canyons that could never be produced by a simple height map At this point the world looks a lot like the minecraft worlds we know and love but it still feels lifeless the last stage is to add all the finishing touches plants animals trees and structures it’s in this stage that trees are placed villagers and villages are spawned and The world gets filled with flowers cows and beehives so that’s how a single chunk is produced in minecraft to go back to our metaphor we can now produce a single puzzle piece however much like a single puzzle piece can’t give you the full picture a single chunk doesn’t tell us much About the larger structure of the world how does the game link these chunks together to get a smooth continuous world how does the game know whether it should decorate that specific chunk with sand and cactuses and not snow and polar bears let’s now take a look at how the Overall minecraft world is put together much like chunk generation the world itself is generated in layers in fact there are around 40 different layers that go into producing a minecraft world we won’t cover all of them but we will go through the major stages every minecraft world starts out entirely as ocean Every biome is numbered in the code and ocean happens to be number zero so in the first layer of world generation it’s the only kind of biome that exists this stage is just about creating the very first layer of noise on which everything else will be built This is hard to see with an ocean world but by messing with the ordering of the different biomes you can change the world so it’s entirely made of any other biome that you want by changing it to a plane’s biome for instance it becomes much easier to see the Underlying noise structure of the world the next several stages are all about layering additional levels of noise on top of each other at different scales by adding more and more noise layers together the world will become less repetitive and each new layer also reduces the amount of ocean and adds More land area to the world by the end of layer 8 the world that used to be almost entirely ocean is now about 50 land and the terrain is much more complex than it was with the single layer of noise the next layer is where we start getting a variety of biomes as Some of the land surface is assigned to be a colder climate this might be a good time to talk about temperature in minecraft every different biome in minecraft has a temperature value and this temperature can also change based on altitude it gets slightly colder the higher you go this temperature value Affects a number of things some things are more obvious like whether it rains or snows but others are more subtle such as the color of water grass and leaves which all change based on the temperature note that the temperature depends on the biome not the other way around but biomes are Generally clustered together with other biomes of similar temperatures this stage is simply separating areas that will be turned into cold biome clusters rather than the default temperate biomes it’s also important to note that at this stage and the next few after it you won’t actually be able to see the different biomes They’re only blocking out where different biome clusters should be the world is still going to be full of oceans and planes until we start assigning specific biome values a few more steps down the line the next several stages are edge stages the idea behind these stages is that it Would seem odd to go immediately from a very cold biome to a very warm biome so if there are biomes with very different temperatures next to each other they should be separated by something intermediate these stages add cold clusters between freezing and warm clusters and lush clusters between warm and cold clusters This results in smooth transitions between freezing to cold to lush or temperate to hot climates there’s also a stage that adds mushroom islands which are found only in the oceans and aren’t part of any biome cluster and another stage that marks certain biomes as special when biomes are finally assigned Those that are marked as special will be unusual variants of the biome like in eroded badlands instead of the standard badlands finally layer 19 takes these biome clusters and actually assigns specific biomes to them each cluster has a group of different biomes to choose from and each biome in this group has a Certain weight assigned to it for example a warm biome cluster can turn into either a desert savannah or plains biome each of these has different odds of forming deserts are about 50 percent more likely than savannah which in turn are twice as likely as planes cold lush and freezing clusters all Undergo a similar process once these biomes are assigned we’ll finally have a world with different biomes in it however we still have a ways to go before we’re finished one funny thing about this stage is that all the biomes are very tiny and very close together which makes Flying around it very fun for me after that we begin adding even more biome variations such as adding hill and mutated versions of the existing biomes we also have separate layers for adding special biomes such as sunflower planes and bamboo forests we then add a major feature that our world was missing Rivers although you can’t really see them at this stage however we’re now getting pretty close to the end the next few layers add shorelines between ocean and land biomes add different types of ocean such as frozen oceans and zooms into the world to make the biomes larger After this we’re all done and finally have a completed minecraft world that’s all i have for this week if you like this video make sure to leave a like and subscribe so you don’t miss more videos like this in the future if you have any questions about this video or want to suggest Topics for future minecraft or terrain generation videos please leave those in the comments down below if you like this video make sure to check out the rest of my channel i make videos on all sorts of game design and programming topics and join me next time when i will Finally unveil the secrets of the pokemon multiverse until then thank you so much for watching and i’ll see you all next time Video Information
This video, titled ‘How Minecraft Generates Massive Virtual Worlds from Scratch’, was uploaded by Rempton Games on 2021-02-28 16:24:04. It has garnered 3157 views and 109 likes. The duration of the video is 00:12:37 or 757 seconds.
You’ve probably played in a Minecraft world before, but have you ever wondered how that terrain was generated? In this video I go step by step to show you how chunks and biomes are formed, and modify the source code to show you every part of the process!
Blog / Transcript: https://remptongames.com/2021/02/28/how-minecraft-generates-massive-virtual-worlds-from-scratch/
Chapters:
00:00 Intro
00:38 Background Information 02:51 Chunk Generation Intro 04:10 Heightmap Stage
04:43 Ore Stage 05:01 Surface Stage 05:17 Carving Stage 06:05 Decoration Stage 06:20 Biome Generation Intro 07:09 Waterworld 07:47 Add More Land
08:17 Separate Cold Clusters + Temperature Discussion 09:29 Separate Cold and Warm Clusters 10:24 Assign Biomes 11:17 Add Biome Variations 11:32 Add Rivers, Shores, Etc. 12:00 Conclusion