There comes a time in every game developpers life where they must spend an arbitrary amount of time learning how to make Minecraft from the ground up.
I have reached that point.
This was a rather small project, mainly to get myself acquainted with using C++ in Unreal engine as i had always had a little difficulty getting accustomed to Unreal Engines peculiarities. I learned a lot, and definitely found myself much more comfortable with coding in Unreal Engine.
The main resoure that i used to gain an understanding of voxel based generation was a Youtube series by CodeBlaze, which did an excelent job in explaining how the fundamental system works.
So allow me to give a brief overview.
The first step is to generate the noisemap, which we use as a heightmap to determine the shape of the terrain. For this i used a library, there's a plugin for it too, but I couldn't get it to work.
You then need to sample the pixels at the x and y positions of your blocks.
Noise maps like this will return values between -1 and 1 so you need to do a little calculation like this in order to get your actual height as represented by the heightmap.
Now that we have the heightmap, we then fill in the data of each position of our grid into an array, by assigning the block as "Air" if block lies above the heightmap or "Stone" if below. You can get a lot more complicated with it, but that's the basics.
Now that we have our data, we need to render all of our blocks. In this step efficiency is key, as we dont want to be rendering sides of the blocks that will be impossible to see.
So after determining that a side of the cube has air next to it, we can then construct the vertices, triangles, normals, and uv's for that quad. Add it to an array of mesh data, and when you are ready to generate your terrain, run a simple function.
There's also greedy meshing, which I did implement, but it is a lot more complicated to explain so i think i'll leave this very brief and surface level explanation here.
I may revisit this project and start putting in more gameplay focused features, but as far as acheiving my goal of getting more accustomed with Unreal Engine, I'm pretty satisfied.