[Cubes] New Update Soon: Greedy Meshing

Hey guys, :smile:

I’m really happy that a lot of people are using Cubes for their games and are posting questions and even improvements/contributions (that helped me a lot, honestly) and it’s time to give something back again I guess.
Since I had a little spare time the last week, I worked on a system customize the meshmerger that will be used. In other words, Cubes has now greedy meshing which you can select in the settings object.

If you don’t know what greedy meshing is, I guess those screenshots can explain it:
(Left = “Default” Merger, Right = Greedy Merger)

Notice the fps improvement due to the lower amount of vertices. (400k -> 80k and 90k -> 6k)
For the ones wondering how to set it up in the code, it will be selectable in the CubesSettings object:

settings.setMeshMerger(new GreedyMerger());
settings.setBlockMaterial(new BlockChunk_MaterialGreedy(application.getAssetManager(), "Textures/cubes/terrain.png"));

As you see,you will still be able to use your own forked material (or even merger) instead of the default one for the greedy merger (But you will have to care since there are few shader and vertex information tricks going on to texture the whole thing - I will explain it all in the wiki, but just so you know you still HAVE the possibility to use your own material). Also, the whole texturing is done via @nehon’s ShaderNodes, which are greater than expected, so you will be able to reuse it somehow in your own material if you want to.

I don’t exactly know when I will release the update, maybe this week or next one, most likely when I had time to update the wiki.
So yeah, thanks all for your help, contributions and kind words.

Yours, destro :slight_smile:

11 Likes

cool

Looks pretty cool :smile:

Cool, will it support custom-modeled blocks? On that note, are there any resources on how to make custom modeled blocks?

Hey,
do you even realize that there is a notable rendering overhead between your chunks?^^
It becomes very apparent in the unmerged wireframe screenshots, and is still visible in the merged version.
Essentially, the problem is that the blocks you render need access to their neighbor blocks that lie in neighboring chunks to correctly determine if their “chunk border” faces should be rendered or not. Currently, they always render them, and in scenes with dense chunks, this becomes a huge performance problem.

Yes, I noticed (and fixed) that - It was based on the fact that every chunk independently generated its mesh. I adapted the code shortly after posting those screenshots to remove the called “overhead”. The results are really great - Especially for big terrain, it is a loooot of saved vertices.
Thanks for reminding me of Cubes. I don’t have much time to maintain it at the moment or to push the update. I’ll try to publish it after my exams. :slight_smile:

I wanted to tell you the exact same thing about the chunks.Another thing is will there be away to merge chunks from different terrains?For example if I made two terrains next to each other can I remove unnecessary vertices between the two terrains?

No, I don’t think that would make much sense. If you need such a feature, you will most likely have to write a custom block engine or alter the source code to an extent, where it doesn’t really match with the original purpose of Cubes anymore.
… Well, maybe in the future, when I will finally have time to implement growing terrain, there will be a way to create “non-rectangle-shaped” terrains, cause that sounds like what you are trying to achieve.

I am trying to create infinite terrain.I can’t just make the terrain control infinite but I can make a bunch of terrains and only use the ones near the player.The problem is so small though and I will solve the little problems myself like glass between 2 terrains will have a strange look with the culling.

Hey, So I was wondering if you still intend to release the update.