Infinite World?

Hey everyone, I’m trying to make a minecraft-like game in UE4 like the one done in blueprints here:

What I have so far is this:

So I use the simplex noise plugin woth some for loops to generate the tarrain:

The problem is that this is not infinite and I want it to be infinite and the other problem is performance cuz it makes alot of blocks.
So is there anyone that can maybe help me to make this world infinite instead of only being the size that you enter in the for loop
And also I need help on increasing the performance cuz this is really slow when I make the terrain size more than 100x100x5 blocks(witch is not even big)
I see that on the link I posted above, the guy mentioned something about doing fancy math to only make the visible cubes render and hides all cubes not currently seen to increase performance but I don’t know how to do that.
Any help will be greatly appreciated

Wow thanks for the answer, I’m starting to understand why the original minecraft has such a good performance. I’m still however a little stuck on achieving this in UE4 but at least I have a starting point now

You don’t generate the world when you start playing. Not completely anyway.

That’s what chunks are for in minecraft. Minecraft generates the world chunk by chunk. Bit by bit.

Here the noise algorithm comes in super handy. You have for coordinates X and Y a height Z. It doesn’t matter when you check that.

Minecraft splits chunks up in 16x16 blocks. At any time 8 chunks in all direction are loaded (so somewhere around 300). Whenever you leave a chunk the 9th row behind you which is still loaded will be unloaded and the 8th row of chunks in the direction you moved will be loaded. (Keep in mind here that they are loaded! Not rendered!)

Since you have the height and all that other stuff from your world generator you can just generate all of this on the fly for small portions of your world.

As for performance. You do realize that 100 x 100 x 5 is 50.000 blocks that will be rendered right? That also means 50.000 draw calls because you use individual blocks. That is bad. Real bad. Here is a great stack overflow answer on that topic:

You are submitting 50.000 times 12 triangles. Basically nothing.

To take as example Minecraft again. Minecraft only renders the visible surfaces. Not even only the visible blocks. Only the visible sides. In that sense the world isn’t even blocks. It’s tons of 2D surfaces put together in a blocky way.

Assuming you stay with 3D objects:

What you should do first of all is store your world somehow. You will want to load and save it anyway and you can’t really work with anything without knowing what’s there first. Sure you can just check it while generation but there you’re already wasting tons of performance by first creating all blocks.

Then check which blocks are next to air. Only create those. All others are irrelevant for now. When a block is destroyed the blocks next to it will have to be checked but for the initial world span we can ignore that (btw that is a block update. Whenever something happens to a block you gonna wanna update all adjacent blocks so you can do things like the fence for example. Or just start to render / spawn those blocks).