Welcome in the last section of this tutorial about implementing different biomes there is a great article called autobiomes procedural generation of multibio landscape we have this chart which shows us basically that we can split our grid of chunks into our chunks basically but also we can split it into biomes by Simply creating a less granular grid and calculating some climate stats some climate simulation so for example we can say that we are calculating some temperature based on the different uh points on our less granular and basically this is what we are going to do the temperature of course will be Our noise value that we are going to calculate and based on this we are going to see that those are our climate stats and based of though on this temperature or this noise value we are going to check the biome that fits the criteria that we set for it We can also visit wikipedia typing biome and we are going to find this chart here this shows us based on some climate stats so we can see that this is the temperature and this is precipitation so i believe this is just the how much rain falls down in this area And based on this we can select what type of biome do we want to generate based on those conditions and i think that minecraft uses something similar to create its own biomes both of the articles will be attached in the description of this video the basic idea here is that we have Three steps to make pairs is those blue lines that are depicting the centers of our biomes and basically what we are going to do is based on the player position we are going to calculate in 80 directions that biome centers around the player we are Going to add some offset so that we can kind of create a more interesting looking landscape and then for each of those inner centers we are going to calculate the one more level of those centers so that we can have a better understanding what is going on there and how can we Populate those styles that are between this one and for example this one so here we are going to have consistent biome if we have this next thing that we will need to have is the value the noise value or the temperature value if you want to call it this way For our biome center so based on the this value we are going to say which center is in what type of biome and this will give us the possibility to create uh in accordance that process that column chunked based on what is the type of the biome and later on to Connect it kind of to have this line connecting those biomes instead of going uh with with a straight line to the next biome we are going to use domain warping to kind of calculate the distance between each biome and the value and then we are going to create a Very simple argo algorithm to say what is the range of this biome this green biome and what is the range of this desert biome and how we can create this kind of nice looking connections between those biomes okay so first stop is creating those centers of our biomes okay back in our project First thing that we are going to create is a script that will help us to generate eight points in eight directions around the point that we give this so we are going to go to our scripts folder right click create a c sharp script and i’m going to call it biom center finder Okay let’s open this script up in visual studio great we can make it into a static class since we are only going to use it for the biomes generation and first thing that we are going to do is we are going to create a very simple list so lets Delete the mono behavior inheritance delete the start and update and we will have we will need to have a list of directions so i have decided to create a public static list of vector to int neighbors eight directions equals new list of vector to int and i have Populated with all the directions so all a direction 0 1 1 1 1 0 and so on so that we can generate our 8 points around the player for our terrain generation next we are going to need a method that will calculate our biome centers so this will be a pretty long method What we are going to have here is a public static list of vector3 int method called calculate biom centers we are going to give it a vector3 layer position which is basically the center of our world because we are going to generate our world around our player and When we are moving our player the world needs to be generated around the player we are going to get int draw range and we are going to get map size as an end value now draw range and map size are just values from our world class so those are the Chunk size and chunk drawing range and based on those values we are going to calculate the biome length so as you might recall our terrain was drawn using this range in each direction so basically our biome range is one fourth of the terrain so this will be the basic biome size And based on this we are going to later on modify it so that we can get a bit better looking terrain so this will be the biome length next we are going to have a vector three origin this will be vector three and origin equals new vector three int And we are going to populate it with end values using math f dot round to end for x and for z value so if we are on position one divided by uh biom length which is about 120 or something like this times biom length this will Give us zero so we are going to calculate the player position in biome grid which is a much less granular and this same thing we are going to do with z value and for y we are going to set zero we are going to have a hash set of vector3 ins biome centered Temps and this will be a hash set since we may encounter the same position added a couple of times to the list so instead of list we are going to create a hashtag to avoid duplicates we are going to add the origin and next we Are going to look for each vector to in offset x y in inside our neighbors eight directions and in kind of tricky way calculate all the points so we have four points here four vector three ins which will be equal and we are going to take origin x and Origin z and zero as y as base next we are going to get the offset x and z x add to all of those and offset xzy add to all of those and next we are going to either multiply it by biome length or two times bio length And on the other side we are going to calculate this uh in a different way so first point will be times biome length second point will be x times bond length and z times two times bio length third point will be two times berm length on x And one time biome length on z and the last one will be two times berm length on both x and z now just elaborate on this if we have this point zero one we’re going to calculate the first point up so on z value and the second point Because on x we have zero so we’re going to basically take two times those points if we go back and we have now one and one let’s go to our map okay so for one and one we are going to calculate the biome lengths so this will Be this point on the diagonal axis we are going to add two to this so we are going to take this point we are going to add two to this we are going to take this point and we are going to add two to both so we are going to get this Point next we are going to take this point so we are going to take two times this those points next we are going to take those points uh in the lower right quadrant next we are going to get those uh below so on the z minus z axis next on the Lower left quadrant and next to the left and next in this upper left quadrant and next i think this will be it so basically this is a tricky way to get all of those positions i am quite sure that you can figure out a way to calculate this using Two for loops but basically those four points will calculate for us all of the points that we need using this biome length and we are going to always add this to our hash set and thanks to the heart set we are never going to get any duplicates so with this Done we are going to basically return those points so those will be the centers for the current centers of the biomes for the current location of our player now let’s file and save all because we are going to need to use this somewhere so let’s go back to unity And to use this we are going to open our terrain generator since this is basically responsible for selecting the biome so let’s select the terrain generator script those three dots and edit the script we haven’t added a lot to this class so let’s create a new method public void generate bio points Okay and we are going to take in the vector 3 layer position int and this will be draw range and into which will be map size which are all of the parameters that we need to add to give to our biom center finder study class and last thing will be vector 2 int And this will be our map seed offset okay and in this method we are going to calculate anything that we need to generate our biomes so to calculate our biomes and display it we are going to create a top here a serialized field list of vector3 ins biome centers equals New list okay with this we are going to go to our generate bio points and we are going to call biom centers equals new list to reset it and we are going to populate it by calling biom centers equals our biom center finder dot calculate biom centers And we are going to pass the player position the draw range and the map size so those will be the parameters of our biom centers and next thing that we are going to need is an ondraw gizmos method that will simply set the color of The gizmos to be color blue and for each of our biome center point in biome centers we are going to draw a line inside the biome center point and we are going to draw a line uh towards the up there in the up direction calling a biocenter Point plus vector three dot up times 255 just to draw a long line in the y direction okay but we still do not call this a generate biopoints method anywhere so let’s copy this and we are going to go to our world script so let’s go back to unity Okay let’s take the world open the world script so we are at the top of this class we are going to slide down where we have our generate world async method and when we are going to calculate the world generation data before that we are going to call our terrain generator dot Generate biome points and we have been given the position here so we are going to assume that this position is the player position next we will call we are going to give this chunk drawing range then map size as the map size and vec we should have up our seed offset as the Offset now map size doesn’t work because we have our chunk size instead let’s select a chunk size okay so we are going to every time we generate our world recalculate the bio points and use android gizmos to put them on our map let’s file and save all and let’s go back to unity Okay let’s press play let’s regenerate it and as you can see we have our uh biomes generated now our player i think is a in a bit different position than our biome center let’s move to it and as you can see this should be around zero zero Here is our first line this is the center of our biome near our player one more thing that we can do is add the main warping to move those biome centers a bit to have a bit more interesting looking biome centers instead of having all of those In one line but that’s what we can do in the next video okay and there in the next video as well we are going to start working on adding a new biome which will be the desert biome okay see you in the next video Video Information
This video, titled ‘Create MINECRAFT in Unity – S3 – P11 Different biomes theory’, was uploaded by Sunny Valley Studio on 2021-09-03 18:19:24. It has garnered 1601 views and 43 likes. The duration of the video is 00:13:55 or 835 seconds.
In the Section 3 we will explore how easy it is to make our code for the procedural voxel world tutorial multithreaded when we have separated data creation from the rendering of the chunks.
Section 1 – Voxel Terrain Engine https://youtube.com/playlist?list=PLcRSafycjWFdYej0h_9sMD6rEUCpa7hDH
Section 2 – Procedural generation https://youtube.com/playlist?list=PLcRSafycjWFesScBq3JgHMNd9Tidvk9hE
Section 3 – Multithreading https://youtube.com/playlist?list=PLcRSafycjWFceHTT-m5wU51oVlJySCJbr
Articles: https://link.springer.com/article/10.1007/s00371-020-01920-7 https://en.wikipedia.org/wiki/Biome
Learn more from about Unity Game Dev in my video courses at: https://courses.sunnyvalleystudio.com/
Code files for everyone: https://www.subscribepage.com/voxel_world_tutorial_section_2
Project / code files for patreons: https://www.patreon.com/posts/voxel-world-end-53323870?utm_medium=clipboard_copy&utm_source=copy_to_clipboard&utm_campaign=postshare
Project / code files for YT members: Link in members only community post: https://www.youtube.com/c/SunnyValleyStudio/community
You can support me through Patreon: https://www.patreon.com/sunnyvalleystudio
Articles: Perlin noise – https://adrianb.io/2014/08/09/perlinnoise.html Domain Warping – http://www.nolithius.com/articles/world-generation/world-generation-techniques-domain-warping
Join the discord if you have any questions! https://discord.gg/RQEtYHz