Hello and welcome to code blaze and today I’m starting a new series in a mural engine in which will be creating voxel chunks or minecraft like terrain and this time I’ll be doing it the proper way where I will be building meshes using like we’ll be creating the vertex arrays And the triangles this is an updated version of a previous video that I created in which hydrated voxel terrain using blueprints but that was basically using instanced meshes and creating cubes according to a height map and another reason I am doing this again is because the noise plug-in that was used In that video is no longer maintained and it’s not supported with the current version of Android engine so there’s a new noise plug-in out there if I just my plugins and it’s called yeah it’s this fast noise generator now or F&G you can search for it on the marketplace and It’s available for free so you can basically add it again the API is pretty much the same because both of these noise plugins work under how Burns fasteners library so there won’t be much difference here and what we’ll be creating is this blueprint actor called chunk which you can place in the world And it will take a call according to the world position you’ll be it will create a height map and generate the mesh so if I basically move it you can see the mesh changes it’s not the most performant by changing the mesh but yeah it will work And if I go inside this you’ll see there are no hidden faces now that was a problem with the previous method I used using instance cube so this saves a lot of performance but there are faces between the chunk borders now that is something you can even reduce that but It is not something that be I will be covering over in this video series so that’s it this reason this 1600 so to do this we will need a few things that we’ll need to set up so the first thing you will need to create 2 in homes one Would be a block enum so to create a name you just right-click go on WP and you can create an enumeration from here so this block in um just basically holds the different types of blocks that you want in a voxel heading so form either with the null block the air block And stone block now if you’re going full Minecraft and you can add all that blonde class box and you know all the different types of blocks that you need a new filter in even the shadows in this enum and the second enum that I have is this direction enum which basically has Six constants that’s the forward right back left up now corresponding to the different accesses so this enum is basically to make stuff more readable otherwise you can get W without this enum and use basically numbers 0 1 2 3 4 5 for the corresponding directions and That’s it so the final result would look something like this in which we have three parts in the block generation so this is where we create the height map and fill in the blocks array according to the height map then we have the mesh building this is where we populate the Vertex data the triangle dot and the UV data and finally we have the rendering where we use the generated data to render like create the actual mesh and show it in the game and to do this we have a few variables and a few functions And that’s what we will be setting up in this video so I basically created an empty blueprint with the base class as an actor and I have created all these variables and functions so I will go over them and you can create them as you follow along so the first thing I did Was add a procedural mesh component so if we go into add components and search for procedural image you can basically add this component and I basically made this component as the default route and moved it over the default scene route and it doesn’t matter if it’s the scene Route or not basically you need to have this procedure mesh component this is the component 2 which will pass the generated vertex data and it will actually render it and then we have some variables so you go over functions later so the first variable we have is the block So this basically is a vector array and it holds eight values so these are basically the vertex positions of a basic cube so cube has eight points and this basically has those and then we have the block triangle data now to explain this yeah so the data I have Here is actually the data that I have used in unity so I have basically converted over to done really system so there is a change in the units and the accesses also but what I need to explain here is the triangles so for triangles I have six arrays corresponding to each of The phase so if I want to create a face in the like the front face of the cube I’ll be using 0 1 2 3 points and if I want to create like the back face of the cube I’ll be using this set of points and these numbers actually correspond to The index of the vertex positions so the front face would actually use the 0 1 2 & 3 these four positions to create the face so that’s what’s there in the triangles array and I basically flattened out so rather than it being a two dimensional array I have flattened It out to one dimensional array and that can easy and you can basically convert any higher or that idea to a lower order ready and use a formula to get the correct index so you can see these food I have this all elements here so I’ll have these both block back and the Vertex data in the descriptions so I’ll just copy it here and paste it there so you can select the whole thing and actually paste it here so you won’t need to even type this everything and once you have the block data and the triangle data so the triangle data is basically An integer array if I didn’t go over that next we another constant that we have is the size of the chunk in x y&z this is basically an integer and I have set it to 16 so you know if you want chunks of like if you don’t want them to Be of the same size on each axis you can do that but I’d rather have them as a sixteen by sixteen chunks next we have a scale now this is the scale of each and individual cube and I will basically default this to one and one would be pretty much okay For each and every use case you won’t need anything other than one but you can play with it if you want something else and you can even have it as a float but for my case I just want it as one and these are the four constants that we’ll Have and this won’t change next we will have three more arrays which will hold the vertex data the triangle data and the Givi data so keep in mind the block vertex data and the actual meshes vertex rot are two different things this is a constant and this is an array that will Populate while the generation and this is the thing that will pass through the procedure mesh to the final rendering so the vertex data is a vector array the triangle data is an integer array and we have the UV data which is a vector 2d array and other than that we have these Chunk blocks array so this is basically an array of our initial type on the like we create the numeration block search area of that and these are all the variables that we’ll be needing other than this we have few helper functions so we have this create face And this create from phase function will basically create a face anywhere in the world in any direction so the create face will basically take a position in the direction so direction will be like of a cube which face will be great the front face the back chase the topsis and Everything the gate face vertices will basically take the direction and the position of whatever we have supplied and it will query the block vertex dot and get the proper vertices for the current face that needs to be created is empty is a basically a boolean check function then I’ll have generation this Will basically say whether a given block is an empty block or not so the navi block in block is an empty block whereas the stone Bach the stone block is an octave block so you can have this thing customized to has your D Huez case then We have the gap block index so actually this block set is a one dimensional array and considering the size I have a 16 so the length of this array would be 4 0 96 actually the blocks in the chunk would be in a 16 by 16 by 16 3d array and I Have again flatten it down to a 1 dimensional array and this gate block index will basically take an XYZ 10th position and compute the index corresponding index in the blocks array and turn it so it’s again a utility function that will be used in many places this gate position in Direction Is again a utility function so if we specify or give it a vector like a position anywhere in the world and this is if I find me the next position in this directions it will basically increment the value by one of the corresponding axis if we want the Position in the forward direction so if I give it 0 0 0 it will return me 1 0 0 it will basically increment the x-axis and return me again this is a utility function that will be used and finally we’ll have this check function so this function will be used to check whether The like basically we have empty this is where we will do the checking of the Khorasan and the neighboring blocks whether they are empty blocks or opaque blocks and dependent upon that will be created in creating the face if required so these are all those things that you Need to require to do this generation and we’ll be doing this whole thing in a single blueprint and that too most of this will happen in the construction script you can do this in begin play if you want like if you want to change the C then everything at or Anything you can do that but for this tutorial purposes doing it in construction script is easy then I don’t need to play again and again I can basically show you the measure in the viewport and another thing is that other than this create phase functions all of these functions will be pure functions And will be and inputs and outputs as and when we implement them so this is basically what is required for the set up and I will find again show you what will the final result would be so we’ll be creating these chunks okay and in the next episode I hope we be Able to implement the create phase function so if you leave leave a like and if you like this and if you have any other suggestions please leave them down below in the comments and subscribe for the upcoming videos and how I hope you like this thank you bye Video Information
This video, titled ‘UE4 Blueprint Tutorial – Minecraft like Voxel Terrain Generation : Part 1 Project Setup’, was uploaded by CodeBlaze on 2020-06-16 09:46:54. It has garnered 6414 views and 113 likes. The duration of the video is 00:11:37 or 697 seconds.
This is simple blueprint tutorial series for minecraft like voxel terrain generation
Project Source – https://github.com/BLaZeKiLL/UE4-Voxel-Tutorial/tree/master
Playlist – https://www.youtube.com/playlist?list=PLgji-9GMuqkKHBbUZroj_h7rd36Jdtygf
Voxel Chunks in Unity – https://www.youtube.com/playlist?list=PLgji-9GMuqkI77VmFk0Rol4AWKp-OgkGr
You can copy the following data (including brackets) and paste it in the editor
Block Vertex Data – ((X=100.000000,Y=100.000000,Z=100.000000),(X=100.000000,Y=0.000000,Z=100.000000),(X=100.000000,Y=0.000000,Z=0.000000),(X=100.000000,Y=100.000000,Z=0.000000),(X=0.000000,Y=0.000000,Z=100.000000),(X=0.000000,Y=100.000000,Z=100.000000),(X=0.000000,Y=100.000000,Z=0.000000),(X=0.000000,Y=0.000000,Z=0.000000))
Block Triangle Data – (0,1,2,3,5,0,3,6,4,5,6,7,1,4,7,2,5,4,1,0,3,2,7,6)
Auburns Fast Noise Library – https://github.com/Auburns/FastNoise Fast Noise Generator Plugin – https://www.unrealengine.com/marketplace/en-US/product/fast-noise-generator
Follow me on Insta – https://www.instagram.com/code.blaze/
#UnrealEngine4 #Minecraft #WithMe