Hey welcome now welcome back uh so now this could be a talk with henrik never about i was a terraforming minecraft but that was maybe misreading it but anyway here is hendrick kneebay welcome this is going to be a pretty geeky talk but this will be the right place to do a Geeky talk i guess right yes good okay i’m going to talk a bit about how code and math and a bit of tinkering can lead to really cool terrain because i think it’s interesting there are no uh takeaway points or learning points or call to actions or anything in this talk It’s just sharing interesting knowledge about how stuff works so if that’s what you want then you’re in the right place um so um minecraft is to some extent an earth simulator for those who have played it or watched other play it you see this thing that looks kind of like planet earth There’s animals in there and trees and rivers and some things that aren’t quite fully realistic but floating trees and armless suicide bombers blowing up at you some things we take some liberties with realism but overall it is an earth-like environment um and this is for those of you who wonder like How how does that work like how do you create um an environment that kind of looks like this and um a bit of context we we changed minecraft quite dramatically um about well for the past two years we we in the cave the cliffs update we basically changed everything about world generation We added much bigger caves we added huge mountain ranges and as we did this we realized that we can’t just add big caves in big mountains we have to change the whole terrain to match and we had a bunch of old legacy codes so it was like okay this would be the right Time let’s just rewrite most of it so that’s that’s that’s kind of what we did and before i get into the nitty-gritty details of how that how that works i want to talk a little bit about size because it’s hard to really understand how crazy big minecraft worlds are um this is earth This round ball we’re sitting on right now half a billion square kilometers of surface roughly and over over there is a minecraft world flat finite about three and a half billion so about seven times bigger than planet earth if you’re gonna explore a whole minecraft world you’ll need some time And that’s just one world every time you create every time you you create a new world in minecraft or you start a new game it generates a unique world just for you the likelihood of someone else seeing this exact world is very low it’s one in 18 quintillion And a quintillion is a one with 18 zeros so that’s an 18 with 18 zeros that’s how many different possible worlds there are and each of those worlds is seven times the size of earth so it’s it’s big and just to put that into perspective i told you it’s going to be geeky Milk away galaxy 100 billion planets ish minecraft 18 quintillion worlds if every minecraft world was a planet we would need how many milky ways 180 million milky ways size galaxies just to fit those so if you’re gonna explore all the possible minecraft content yeah it’ll again it’ll take time Um what’s interesting is of course minecraft is not a physical world it’s it’s a digital thing but even digital worlds take physical space uh so let’s let’s do that math a little bit um a minecraft world is a grid of blocks right kind of like a like a rubik’s cube where Every block is one meter uh but a rubik’s cube is three times three times three a minecraft world is 60 million times 60 million times 384 it’s a big rubik’s cube and a minecraft world is kind of from a data storage perspective a list of blocks right what block do we place at What position that’s kind of what it is and it adds up in data so one minecraft minecraft world roughly that’s not me is about 97 000 terabytes so 97 million gigabytes i guess if my math is right is one world um it wouldn’t fit on any disk the Biggest disk i could find was it was 100 terabytes so that’s you know pretty small in comparison you can’t fit a minecraft a single minecraft world on a disk and of course definitely can’t fit all of them um you would need that many bytes i’m not going to say that number I don’t know it doesn’t have a name um the whole earth data sphere that’s a new word i learned for this talk data sphere is how much total data storage on earth is roughly like that so you would need about 238 238 trillion worlds earth’s to store all the minecraft worlds Digitally so yeah it’s big even if you just look at disk space so then how the heck can the download be just a half a gig right um well obviously the download of minecraft does not contain any worlds it’s actually empty it only contains code to generate the World so i like to think of it kind of like there’s no body it’s just a dna to generate the body right and that’s kind of interesting because it’s like okay but how does that work and it is somewhat of an illusion we try to make this not noticeable to players So when i’m running around inside my world it feels like that world was always there but actually it’s generating as i move around and if you move really fast you can kind of see it happening right so over there in the background it’s not loading the world it’s generating the World it’s calculating it so makes you kind of wonder right maybe it’s like that in reality too right if you point your telescope to some unexplored area of the universe is that being generated just there for you who knows if it happens here maybe it happens there right just generated on demand And that’s what we call procedural terrain generation makes sense so far to those who work with this stuff you’re like duh this is obvious those have not worked with it maybe it’s like oh that’s really interesting some of you might be in between i don’t know but even though I work a lot with this i still i still find the naive strong interest in this it’s just fun but okay so what is this thing procedural terrain generation in minecraft we generate chunk by chunk so this is one chunk 16 by 16 wide and then full height that’s one chunk we generate One chunk at a time and um when we talk about procedural trained animation what is the procedure right the word procedure what are we talking about and that’s pretty much this right the procedure of asking hey what block should be here at this coordinate and the procedure says You know planks okay put planks right so it’s really just answering the question what should i place here and um for example flower over there right dirt stone etc and for those who don’t know the coordinate system in minecraft x is x and z are the horizontal components and The y is the vertical component so this is the procedure doing its job um but one challenge is that as we generate a chunk we want that chunk to fit with the next chunk right it should fit together seamlessly and maybe this is my world today and then i start playing minecraft For five years then i start playing minecraft again and i run off to the west it keeps generating and it fits magically so that’s a big challenge to make all trunks fit together seamlessly even across different versions of the game but i won’t talk about that so much in this talk um So yeah uh a chunk right that i made the trunk a bit wider just to just uh illustrate but a chunk is generated in steps so first step is terrain shaping which is really just deciding stone and air so for every position there’s going to be Either a stone block or an air block an air block it’s invisible so then it looks like this right it’s kind of first step and then at a later step we do water filling so we decide that okay all blocks below y level 64 or whatever Is going to be filled with water and then we get oceans and rivers and next is surface replacement so let me look at what biomed is is this a jungle or is it a desert and then based on that we replace the top layer with something so dirt grass And finally features and structures so uh yeah um the villages trees oars things like that so it’s done in multiple steps but in this talk i’ll focus mostly on on the first step the actual you know stone and air the shaping of the train and as you can see that also includes Caves right if we leave some air on the ground that becomes caves all right yeah show me the code i’m not going to show so much actual code because a i’m not sure i’m allowed to and b there’s lots of icky stuff in there performance optimizations and Stuff that we don’t need to get caught up in so i’ll just show simplified kind of pseudo code um what would be a like if we start from scratch right let’s do procedural world generation from scratch what might that look like so simple function random right so the world generation system asks what Should i place here and the answer is flip a coin and then okay stone or air if we do that our trunks look like this right um not terribly fun uh kind of hard to play the game but it is possible you can run around in there you might get stuck but This is technically procedural world generation right it is a chunk being generated procedurally so you know you have to start small right um but it would be nice to have some kind of a surface to run around on so let’s change it instead and introduce a fixed terrain height so we’ll say that Uh let’s say that the y level 100 that’s the surface right and then the answer to the question should be stone air well if we’re below y100 it’s done otherwise it’s air boom now we have surface right so i can i can actually you know i can Run around inside this world now as opposed to before that’s a good start i just need to be careful so i don’t fall off the edge um and if i apply surface decoration and then make the world a bit bigger then yeah i can run around here It is a bit boring it’s very flat uh but it is a procedurally generated world okay we want random terrain height so let’s let’s randomize that surface wire right so surface y equals 100 which is our base height plus a random number from 0 to 19. okay now what um Oh yeah as i mentioned before simplified code just make it easier to read but yeah this is what we get uh kind of a mess right that’s because every single block has a random height so there’s no continuity but there is a surface now and and it is procedural and random okay so We need to we need to step up our game here a little bit this is not really you know ending up where we want it um how do we get smooth terrain so looking into the world of math what is there that’s smooth well there’s this thing right called a sine curve that’s Kind of nice and smooth if we think of that as a as a terrain looking from the side we have valleys and hills and and sign curves are cool because they continue forever they never end right you can keep scrolling and it’ll just keep going and it’s always seamlessly smooth and fits together So this is something in the right direction let’s play with this right go to the code and say 100 plus sine x but that’s a very small number negative one to one so let’s amplify it a little bit times 10. so somewhere between the 90 and 110 now what happens okay We we have a signed terrain but now i can it’s looking a little bit more like a train maybe not quite as crazy but i want to configure this a little bit it’s it’s too uh yeah it’s just too uneven so let’s make some variables frequency amplitude right Um and applying those we can say that i want i want the slopes to be a little bit further apart and a little bit higher or lower or whatever and now we’re starting to get a little smoother shape but a little bit too 2d maybe so let’s actually make a two-dimensional We’ll do the same thing but instead of only in x dimension we do it in the z dimension also and i won’t go through that code in detail but basically um same thing but it but in in two directions and that gives us um these yeah nice little hills This started to kind of look a little bit like a world maybe what do you think so far the best right at least i think so and yeah let’s add water so we check if we are below sea level place water instead of air very simple and then look now the Dolphins are moving in now they’re happy they have a cool place to be and a bit of surface decoration on that and yeah this is kind of cool i think this is kind of cool it does get a bit repetitive though there’s something missing here and that Thing is randomness right all the worlds will look the same so that brings us to the next chapter purlin noise purlin is this guy ken perlin he came up with a cool trick a bunch of years ago where you basically can take instead of like if imagine an old television Television set with like noise so there’s random dots here right so for any given coordinate if that’s x and that’s why we pick a color right and that’s random so it’s just a mess well he came up with a mathematical trick that turns this into that instead so it Changes gradually instead of you know white black white black white white black it goes very white kind of gray kind of black and back towards white and gradually changes so it’s like you’ve been smudging this like with a rag or something it’s a really nice mathematical trick and there’s other variants of it Simplex noise there’s some people call this i think value noise i don’t know i’m just going to use the term pearly noise for now because that’s kind of where it started so the basic idea is two inputs in this case if it’s a 2d noise and one output So ask a question for this coordinate x z what what number do i get a number comes out and i choose a a shade of of white depending on that color it’s a 2d noise field a 1d noise field is the same thing but it’s just one input instead So in this case the input is an x an x value so for each x value i get a y value and that y value changes smoothly so it doesn’t go like that it changes smoothly so this is just different ways of visualizing perlin noise the cool thing about it though is That you don’t have to use it for terrain generation you can use it for pretty much anything it’s very useful for games so maybe i use this as a let’s say i’m playing a two-dimensional side-scroller game i could use a function like this to decide where are the aliens in the game right There are a lot of aliens here none over here or maybe the you know how many trees are there in that place or whatever it is how much gold am i going to find it’s just a way of creating randomness that changes gradually pretty useful but of course in this case we’re using This for terrain generation so i’m not going to talk about how perlin noise works because that’s even a little bit more geeky than i had planned for this talk plus uh time plus i’m not very good at explaining it so google it but um so let’s just abstract it there are lots of Libraries that do this so let’s just package it behind the black box and say perlin noise give me a number right so that’s what we’re doing here we’re saying dear pearl and noise please give me a number between negative one and one based on these two inputs and that’s what it’s gonna do Amplify it a little bit add it to the base surface and what happens well this is kind of cool right a little more random it changes gradually as we move around of course we can tweak it a little bit maybe increase amplitude i don’t know but this is kind of a good foundation Right for terrain generation um what i showed there was a single octave noise so what is an octave well if you think of this take the sine curve as an example again right in my mind purlin noise is the sine curve but a little bit randomly distorted but it’s easier to think about It as a sine curve so it goes up and down like this octave means add another curve so we got this one over here y equals sine x and we got this one here y equals sine of four x divided by four so we’re increasing the frequency so we get more More hills and we’re reducing the amplitude so they’re shorter and why would we do that well because if we add these together we get like a valley and a hill it’s still a valley on a hill like it was from the beginning this red line but now it’s a Valley and a hill with local variation so there’s a hill but a little bit of a dip there and there’s a valley but a little bit up there so you get this kind of high level train shape and then kind of more gradual low-level terrain shape On top of it it’s a really really simple and beautiful mathematical trick so if we had a third octave pretty cool right to start to look like a proper valley in a proper mountain and what’s interesting is there’s no randomness here even this is just sine curves so you can see the potential Right okay so let’s do octaves on on on parallel noise so this is an actual purl noise output right x is the input y is output so imagine this being a terrain going up and down and the second add a second octave to it add a third octave To it the terrain just becomes more interesting and varied and this can be tuned of course like a typical thing you do for an octave is double the frequency and half the amplitude but you can tweak those numbers all right uh so let’s do it let’s pretend that this perlin noise can Do octaves because all it’s doing is sampling multiple times sampling four times adding them together right so that’s kind of the only change i did here and already the terrain is looking even more interesting it’s not it’s not it’s it’s really about creating variation our goal is to to Create a world where exploring is fun even without any other content just exploring should be fun and interesting you shouldn’t just see the same same all the time that’s kind of the design goal okay so this is looking nice right i just added the sea level and the the Terrain features and the biomes it’s looking quite nice for let’s say 10 15 minutes maybe 30 minutes i can go around here and go like wow this is so cool but then after all i’ll be like it’s kind of looking the same still though it’s random but it’s the same ish it Goes a little bit up a little bit down you know so there’s something missing like where is where is the drama right we want drama we want this so how do we get randomness but how do we control the randomness just to some extent oh perfect timing see thing is i just Stand up by the way just have a second i spammed videos into my talk thinking that was a good idea well guess what that does to the powerpoint file it makes it massive so my my thing started crashing i had to split it into two different decks So i figure you guys can stretch while i open the next deck how about that we get to part two all right all right i hope you feel revitalized [Laughter] let’s take some drinks too so terrain what’s that oh terrain shape oh terrain shaping is um is the process of taking this randomness And taming it you know adding a little bit of control to it while still letting it be random i don’t know if it’s official thing it’s just what we call it internally um terrain shaping so noise transformation is when you take a noise like that sampling it over there right gives us Value from negative one to one and then doing something to it so multiplying by 20 and adding 100 that’s a transformation and it gave us gives us in this case some kind of terrain so let’s do more deliberate noise transformation we’re going to take our noise our pearly noise and i’m going To call it something i’m going to call it continentalness i could call it you know uncle bob it doesn’t matter but we use that as a mental metaphor for what it’s supposed to mean right and we’ll get more to that later so we give the noise a name And everywhere in the world has a value for continentalness so as i’m running around i can see that value change right in this flat world and now to the shaping really means creating an indirect connection between continentalness and terrain height by putting dots on the graph So in this case i’ll start very simple and say that let’s say that continental negative one maps to terrain height of 100 and then i add a second dot over here saying that continentalness of one also maps to terrain height of 100. okay and this is our our our spline our Like we fit a curve to these dots right not very hard to do and this gives us what a boring flat world again right here we are saying that i don’t care what continentalness is it’s the surface height is always going to be 100. okay but this is to illustrate the kind of Tool so now we can play around right let’s say that higher continentalness means higher terrain elevation like that and then we’re back to our nice purlin noise you know surface that we kind of saw before um because now continentalness is directly mapped to to terrain height So let’s let’s goof around a little bit let’s add a threshold here and say that well here it’s kind of smooth but from when continental goes from 0.3 to 0.4 we’re going to see a jump in terrain height and after that it’s going to flatten out so we’re making it like not symmetrical Now it’s interesting right the purlin noise varies quite smoothly but the terrain height doesn’t it has jumps so now you get these really cool things like these plateaus and when you add a bit of surface decoration yeah you start some getting getting some a lot more interesting terrain right a lot more variation Just by moving the dots around so we decided to do this on steroids we had um three noises here so continental erosion and something we call peaks and valleys and we can figure them differently so as you see erosion changes quite slowly this one tends to generate ridges we’ve Just configured it in that way and this one tends to generate they’re just a little different and they represent different things in the world so as i run around i see values for all three noises right and you can actually um as a player if You play on the job addition of the game you play a single player you can press f3 and you can see this pile of debug nonsense and if you dig into that here multi-noise c stands for continentalness e stands for erosion that stands for peaks and valleys so you Can kind of see basically these numbers as you run around the world and you can see what it does to the terrain so that gives us very interesting terrain like plateaus like this river valleys or you know big mountain ranges because we basically create a lot of These spline points so this is the actual code pretty much what we configured we’re saying that continentalness when it’s low this is supposed to represent kind of how far inland are we that’s the mental model right high continentalists we’re far inland low continentalness means we’re kind of offshore so that’s why as We are low here offshore terrain height goes way down below sea level and that’s how we get oceans so this single thing basically creates oceans and minecraft it’s pretty interesting and here we get kind of the coastline coming in and then as we go further up the scale we suddenly get plateaus And here it smooths out but these points lead to other splines too so we’re saying that when continentalness is over here terrain height is there but only if the other noises are at zero because then we have other splines connected to it so we’re saying that but If erosion let’s say is low then guess what boom the train height gets even higher if erosion is high turning gets lower and same thing there each dot here is connected to yet another one over here saying that in general peaks and valleys will generate well peaks and valleys This is super complicated to explain in fact i’ve forgotten multiples a while ago it’s kind of mind-bending but when you sit with it you move the dots around look what happens in the world it becomes clear for a little while until you go to lunch then you forget it all again right But it’s interesting the main thing though is that you don’t need to write tons of code to change your train you can move these dots around which also makes it kind of mod like mod friendly people outside mojang can tinker with these numbers you can do That you can make a cool world right by by changing these numbers so uh yeah this is an example this area in the world has high peaks and valleys so we see uh yeah peaks here for example it has high continentalness we’re far inland this is a lake actually and we Have low erosion which generally creates more mountainous regions so that together causes these steep mountain ridges this area of the world has high erosion which means it’s going to be kind of flat no matter what else so all this is done via spline points it creates an enormous amount of variation Um so here we see an example of a lake a mountain range here so flat area we want to cater to all playstyles some players want to build a castle on a mountain others just want a flat area to be able to run their horses on right others want To have lots of rivers to explore the world through so the d is that if you don’t like what you see just keep traveling because you’re almost certainly going to find something that you like after a while because there’s just almost infinite variation in there uh okay so these three noises kind of Together uh generate this is a like a map of the world and as you can see a lot of variation these are high mountains rivers coastlines deep ocean things like that yeah move the dots around changes the terrain you can also mess things up quite easily this actually happened by accident i Changed a few numbers in the wrong way and then oops maybe we shouldn’t ship this version i don’t know i still don’t remember exactly how it happened but um of course what i’m showing now is just the base terrain shape and the interesting bit of course happens when you add the biomes Right so biomes are kind of like the paint on on the surface to make the world really interesting these are fjords uh i worked on fjords does anybody write hitchhiker’s guide to galaxy i uh i did not win a prize for the fjords i’m very disappointed i wish i Won a prize for the shorts uh but it was very very uh hitchhiker guide moment at that time um okay so i’ve kind of oversimplified things a little bit for you um because let me just check the time here yeah uh this all the stuff i showed you so Far is just to generate the high level surface like roughly where is the where is you know where’s the terrain right now down here up there right so kind of low fidelity terrain height changes the actual details are controlled by something else which is called 3d noise and i consider not including this Because kind of hard to explain but i’m going to try but if you don’t get it don’t feel stupid it is kind of hard to explain in like three minutes but i’ll try 3d noise okay so what you’re seeing here is really the result of 3d noise Layered on top of the terrain shaping and the reason why we need it is because of this you can’t get this kind of crazy minecraft terrain using just purlin noise here we have overhangs and all kinds of weirdness happening and this is what minecraft is kind of famous For this kind of total you know wackiness that can happen and we really want to keep it so how does 3d noise generate this well 3d noise three inputs one output so the inputs are the coordinate of the world right an output is a value and we call that Value density just a mental model for what it’s supposed to be um so imagine that this is all the the positions in the world and each position has a value and pretend this is 3d okay so every position has a density value and all we care about is whether it’s Positive or negative so it gradually changes as as we you know in different parts of the world but there’s a threshold when it goes from positive to negative and we basically we basically defined that anything that is zero or negative is going to be air and everything if that’s positive is Going to be stone that’s why we use the term density right negative density there’s nothing there so it’s air positive density there’s something there let’s put stone right it has no implication in the gameplay itself it’s just a world generation kind of technique but when we create when we create a World using just this algorithm we get this i did a side slice of the world you get a world that is just stone and air and all the air parts here was where density happened to be negative and because it’s a purlin noise giving us these values it changes gradually right Okay why are we doing this right well it looks cool maybe that’s a good enough reason but we then apply a uh a bias to it so the higher up we are the more we lower the density value and the lower down we are the more we increase The density values we do an adjustment to it and that pretty much squashes it a little bit so it pretty much says that up here mostly air down here is mostly stone and here’s the place where density actually would would make a difference right So why do we do that well that’s how we generate the the the actual terrain um the detailed surface of the world because terrain shape is controlled by two things squashing factor and height offset squashing factor is what i just showed you this is an example of high squashing Factor where we with that bias is very strong so it’s basically almost like a flat world but as we relax that bias right we reduce squashing factor then the 3d noise is allowed to be shown right so i’m reducing squashing factor now and as you can see lower squashing factor means more Madness right and the other value height offset is just literally moving everything up or down right but those two numbers just those two numbers have a radical effect on the world so that’s how we kind of spice up the world uh in practice we can figure that the Same way using splines so we define how continentalness and all these other noises basically add points for uh squashing factor and we add points for terrain elevation just like everything else so those things together give us a mix of madness and kind of more normal looking terrain And i guess kind of this is where the the mix between realism and fantasy comes into play right 3d noise kind of gives a fantasy element well the the terrain shaping gives us more kind of realism to it and we want to be inspired by realism but not limited by it Okay so a bit about cave generation then this is these are the new big bigger caves we made and they are generated essentially using 3d noise as well so i’m going to talk a bit about that aquifer this underground water is was a whole separate chapter that would take About half a day to explain it was so freaking difficult but i’m really glad it’s over but uh okay noise field this is a noise field um imagine that let’s just do a 2d version of the world just to understand this better right we want to make caves In a 2d version of the world here’s a noise field um 2d noise and of course white and black is the is the perlino’s output let’s just decide that white is air and black is stone similar to what i showed you before right we decide that white is air black is stone If we do that and apply that to this little 2d world then we get a cave system right we get well not a cave system independent in not connected chambers here in this case right that’s really it it’s cave generation is easier than the other stuff um we call these cheese caves Because they kind of look like swiss cheese when you look at that map and they tend to generate these big chambers um and kind of yeah big chambers in in the caves however we notice that we do a little bit of transformation to make it a little Flatter to make it possible to run around there’s some tweaking we do but basically it’s it’s that that’s the base so we call them cheese caves because they looked a bit like cheese and then the name stuck and yeah the rest is history but we but what we didn’t get from this Was long tunnels so to get along tunnels after a lot of experimentation and i want to emphasize that everything i’m showing you here none of it was obvious to anyone we have to do a lot of head banging to really find it so it’s really easy to underestimate how hard it Is to change the core of a game in this way so it’s kind of risky and stressful but i’m glad it worked out really well but anyway um in this case we have another noise field and we just find that the border between black and white that’s going to be Errors we kind of take another approach now so that’s why that’s black here is the exactly that shade of gray is going to be air the rest is going to be stone if we do that we essentially get spaghetti so we call these spaghetti caves like long winding tunnels it’s a little Different in 3d there’s a little more we have to do for 3d but i don’t have time to explain that but the basic principle is the same this is called uh noise ridging because yeah we can go back to the algorithm there it’s really just take The absolute value of of the of the noise and if it’s less than a certain constant then it’s cave right so yeah that’s these um so-called spaghetti caves we have a thin version of them that we call noodle caves and what’s cool is when we combine these things that’s when the magic happens Right you take these caverns and you take these long tunnels and you mix them all up and you get incredibly interesting and varied cave systems you can just keep exploring even as a developer when we ex when i run around inside the cage i just keep getting surprised even though i Spent so much time like working with it so it’s really interesting how much variation you can get when you have enough variables that are kind of interplaying okay last bit biomes if we have time i think we do right so minecraft world is divided into biomes right so here we have a jungle And then over there we have some planes or savannah and as i mentioned before think of it kind of like a thin layer on top of the terrain so for example that would be the jungle or in the jungle we have jungle trees and a Lot of grass and stuff and desert a lot of sand right so biomes control things like what what’s the surface material what’s the color of the water and also things like what structures show up there right in deserts you can find desert temples in cold areas you can find igloos So it has a pretty big impact on gameplay experience and i’ll i’ll give an example of the same location now i made the whole world just desert so everything’s desert now exact same terrain shape but meadows instead now there’s a village that decided to show up for some reason exact same location grove Um and here you see by the the interplay of the cave the cave generation and the terrain generation when the caves poke out you get cave entrances it’s interesting uh badlands which is very characteristic and then uh here is a swamp you normally won’t see swamps up in the mountains but Hey i made a swamp world so this is what we got um and jungle so yeah uh biom biomes have a big impact on gameplay so how do we place them right how do we decide what biome to place where um so i’ll talk a bit about that um they’re based on Five noises so we have these three noises already mentioned then we have two more which we use for placement so temperature and humidity it doesn’t actually mean temperature minecraft doesn’t have heat you’re not gonna like start sweating when you go there it’s just a kind of a metaphor And the combination of those values decide which pile so now now we have five numbers here and they’re all changing as you move around and depending on what those numbers say they would we hit certain thresholds and it goes boom no more badlands now we want savannah because it got more humid i Guess or maybe it got a little cooler i don’t remember but one of these things hit a threshold so these we configure using tables because biomes are are discrete you’re either in desert or planes you can’t be kind of in both so it’s discrete therefore we use we don’t use splines we Use tables so this shows this shows a table if we’re in an area where peak noise is high then we look at continentalness and erosion and that decides which biome we’re in to make this easier to configure we split the noise values into number ranges so we said that you know Erosion 0 means a value from negative 1 to negative 0.78 right erosion 6 means 0.55 to 1. just to be able to reason reason about it so that’s what this zero means here it’s that number range and then we basically say that okay um let’s say uh this place i’m in right Now is far inland and um um quite like it sorry it has a high continental value and it has low erosion so then this basically lookup table says all right there’s going to be a peak here okay but what kind of peak there’s different types of peaks well that depends on temperature So in this case high continentals low erosion low temperature means jagged peaks it’s these snowy things right and this is independent of of terrain shaping or semi-independent we’ve configured them we’ve configured them to somewhat match so when the biome is going to be a mountainous biome terrain shaping is configured to generate Mountainous terrain but they’re not hard coupled it’s more like a soft coupling via the configuration but anyway so we travel a bit and here we come across a jungle so how did it decide that that’s gonna be a jungle well in this case we were low continentalness and medium erosion So this is going to be a middle biome and what the heck is a middle biome so we look at that table and that table says well okay it’s a middle biome huh and humidity is high and temperature is kind of high so it’s wet kind of hot Okay let’s put a jungle there right so we could have called these noises noise a noise b noise c but using these words like humidity and temperature it just makes it easier for us humans to actually understand what the heck we’re talking about when we’re configuring this stuff in the code But it is it is a metaphor and it’s not a perfect metaphor like for example it says wet here and yet there’s a desert doesn’t quite make sense but we’re not optimizing 100 realism we’re mainly optimizing for in this case having deserts be rather big but this gives us a lot of flexibility Um so yeah here’s our jungle so these five noises together generate in this case uh this is a map of the biomes in the world right you see that there’s a lot of interesting variation cold area here hot area with badlands and desert there’s a coastal region with some Beaches or there’s a massive swamp um it gives each part of the world its own characteristic so here we go big beaches um configuring this is tricky because you need to understand what you need to think you need to visualize a five dimensional grid what’s what’s hard about it why does it Matter because neighbors matter a lot we don’t want a desert to neighbor for example snowy peaks it just looks ridiculous so we when we configure these tables we think a lot about what biomes could neighbor which biomes but it’s a five-dimensional configuration space so each each cell has ten neighbors which makes It really hard but what’s interesting is after a while when you sit and work with this your head gets warped enough so you start seeing things in five as a five-dimensional grid and you get brain damaged so for for a while i was a bit brain-damaged i could be you know Outside looking at a slope there and seeing numbers in my head luckily i think i’ve recovered from that now feeling less messed up but yeah this kind of thing i drew this if you stare at long enough you either understand or you go insane one of those two things happen no guarantees offered Okay wrap up as i mentioned there are no takeaways it’s up to you what your takeaways are this is just me sharing what i thought think is interesting about terrain generation but i guess if anything it’s if you play minecraft it might be fun to think about Like hey now i know why there’s a mountain there or if you have kids or friends who play minecraft you can show off and say oh yeah i can see that must be a low erosion area over here that you’re in they’re like what i don’t know But also maybe you work in other areas maybe you work in game development or other areas where some of these techniques might be useful most of the stuff i talked about here is not unique to minecraft a lot of these techniques are quite commonly used in other games as well So but i just wanted to share yeah share what we’ve been doing and what we’ve been learning so yeah thanks a lot [Applause] so thank you very much i think we have time for questions miraculously we do anybody have any questions yeah okay let’s start closer did you consider any Other alternatives i mean like using machine learning so the question was did we consider other alternatives such as machine learning and yes we did a lot of exploration in the beginning of this update um one big consideration is is performance since the world is generated on the fly if we could pre-generate a World our options would be much wider but yeah performance was probably the biggest thing that pushed us in this direction so questions oh no you saw the weirdness did you darn it yeah that weirdness is an always too um weirdness is a weird noise um it’s it’s A it’s a noise that is used to generate let’s say we have a jungle but sometimes it’s a bamboo jungle well that’s because weirdness was negative so it’s it creates variance it’s also used to generate in some cases awareness is used as a noise that indirectly influences peaks and valleys So when awareness hits certain thresholds you suddenly get a river or a peak it’s kind of weird that’s why it’s called weirdness we couldn’t come up with a better term um but yeah good question good nice job spotting it yeah yeah 3d biomes is an interesting question we had a lot of Trouble trying to figure out what to do with that thing is before caves and cliffs update there were no cave biomes so biomes were 2d if you’re in planes it’s going to be planes no matter how high or low you go now you might be in planes and you go Into a cave and suddenly there’s a lush cave down there which is a different biome so we struggled a lot with how to make that work in a consistent way and we pretty much ended up with having all normal surface biomes be 2d they go All the way from top to bottom of the world and then we inject 3d biomes just for the caves so saying that okay this this 3d area is going to be drip stone caves with stelling my stalactites but everything above and below is going to be planes But that’s been very tricky because if initially we thought we would use 3d biomes for everything but then we got really weird things where i’m building my house and i you know and and i’m placing some blocks and suddenly the grass color changes 10 blocks higher up Why well because there’s a jungle in the sky right it’s planes here but there’s a jungle in the sky but i can’t see it because it’s just air and it’s just we’ve got all these weird educates we’re kind of like screw it biomes are 2d unless they’re caves and They’re 3d it’s a bit of a compromise but the technology for it is there so we might go back to making 3d models in the future once we figured out the design of it because it was really that we didn’t have time to figure out the implications of the design implications of it These are super cool questions by the way the world right what actually happens it would actually happen in this particular um it’s a little bit different on our different platforms java and bedrock but but in the job edition of the game once you explore a part of the world it Generates that chunk and saves it so generation is a one-time thing and then every time you change a block it just saves that so the world is persistent in a sense i think in bedrock it’s a little bit different but yeah it’s a very interesting question because some some other games don’t do That right i’m sure some of you how many work in game development i’m just curious um oh wait i thought sweden was the mecca for game companies nobody works in game development here well that’s interesting wow a few maybe anyway but a pretty common thing is that you just throw the delta So it’s basically saying that uh henrik added eight you know dirt blocks here and that’s all it saves and the next time you go there it regenerates that chunk and applies that change i’m not an expert on that kind of stuff i can see advantages and disadvantages But i would say probably mostly for historical reasons minecraft stores the chunk permanently once you’ve generated it yeah up there thank you yes yeah so the question was about about uh or generation right because in minecraft well it’s called minecraft you go mining you find ores and because we made the World bigger i didn’t mention that but with this update we made the world basically you know 50 higher and deeper so everything is bigger which means we need to fill the world with something right what if i go dig deep there needs to be something there and it basically forced us to Completely redo the balance of which ores generate where we took the opportunity to try to make that more interesting but the way ores are placed we actually didn’t really change that like basically at a high level for each chunk it randomly decides how many placements Of iron are there going to be here based on a configuration let’s say it decides that there’s going to be five blobs of iron and then it pretty much just rolls dice okay let’s try to place one down here oh i can’t there’s air there okay never Mind i’ll try to place over here ocean darn it skip that what about here oh here there’s stone let’s shoot in some iron ore so it’s old tech new configuration pretty much uh did we change other dimensions minecraft has dimensions right what i showed you now was the kind of the main Dimension called the overworld then there’s other dimensions um such as the another and the end and we didn’t do anything with that at all we didn’t touch it um maybe in the future thing is last update the update before this update was a total overhaul of the Nether so we tend to try to create a focus area for an update um yeah do you have plans to fix the gravity issue you chop down a tree and it falls down that’s interesting if we did we’d probably be uh crucified because it’s kind of part of minecraft’s Image that you have these dumb trees hanging in the air it’s also completely inconsistent because you can place a stone that hangs in there but if you play sand it falls down it makes no sense but it’s become kind of iconic so it’s probably going to stay that way and It’s my guess but i don’t know oh yeah that’s a really good question yeah as i showed you the chunks go from the bottom to the top right and that’s a terrible waste of resources because if i’m running around on the surface why should i generate terrain down way way below that i’m Maybe probably not going to see 99 of the time and that’s an absolute waste of time which you didn’t have time to fix because it’s the whole chunk thing is so deeply ingrained in the code that changing that making chunks 3d would be a huge and costly and difficult change Which maybe in the future someday but we decided that now we won’t have time to do it now we just have to pay the price of generating wasteful stuff down there all right go ahead you pick slime okay this is very you know it’s like specific minecrafter questions so The rest of you might be like what’s that slime chunk slime chunk is some chunks uh like we’ll spawn slimes and we don’t change anything with that like 10 of chunks in general are slime chunks and they will spawn slimes and it still is that way just like before um So we we changed almost everything about train generation but try to change as little as possible else how finely granular yeah minecraft we have these they’re one meter big right it’s pretty low low fidelity um and it’s kind of weird like why you know why is performance a challenge in a game that Is built on blocks uh but the big challenge in minecraft that makes it a performance sensitive product is that a we want to work on cheap computers right we have like very many players we want them to keep playing the game even if they don’t have a high-end computer So that’s one consideration but then the fact that minecraft is a dynamic world the player can change things so from a code perspective it’s really hard to optimize anything we can’t pre-calculate light for example because i might put a torch i might build a redstone contraption that moves everything back and forth So so the fact that everything is changeable in the world and the fact that it’s generated dynamically as you go means that it’s really hard to optimize plus the fact that now we made the world bigger so performance is actually always always a a challenge even though it Looks like a very blocky you know it looks like it might be simple but it’s actually a lot more tricky than it might seem okay i think that was the last question thank you very much all right thank you very much You Video Information
This video, titled ‘Reinventing Minecraft world generation by Henrik Kniberg’, was uploaded by Jfokus on 2022-05-09 05:57:59. It has garnered 474262 views and 21080 likes. The duration of the video is 00:49:41 or 2981 seconds.
The past year and a half I’ve worked almost full time with Minecraft world generation. We’ve radically changed how the world is generated, to enable dramatic new caves, massive mountains ranges and overall more natural-looking terrain.
In this talk we’ll geek out on the gory details of this. How does Minecraft procedural world generation actually work, what did we change and why? And what did we learn along the way?
I think procedural world generation is fascinating. Hopefully you will too after this 🙂
Henrik Kniberg, Mojang
Recorded at Jfokus 2022 in Stockholm 3rd of may http://www.jfokus.se