Contents
How to store voxels for a voxel engine?
But I don’t think this fits my voxel engine because my voxel cubes/items will all be the exact same size. So another option is to just create an array of 16*16*16 size and have that be one chunk, and you fill it with items. And parts where there aren’t any items will have 0 as value (0 = air).
How to store voxels in a C + + game?
So, in the first iteration you group everything into 2×2 cells, and if a cell only contains tiles of the same type, you drop the tiles and just store the type. After one iteration, our map will look like this: The red lines mark what we store. Each square is just 1 value. This brought the size down from 1024 values to 439, that’s a 57% decrease.
When does it make sense to store voxels in fixed arrays?
It would only make sense to use it over the “storing blocks in fixed arrays” method (the one you described earlier) is when only a quarter of the blocks are solid, and this way you don’t even take any other optimization methods into account.
How many voxels can be stored in one cell?
This reduced the amount of stored values to 367. That’s only 36% of the original size. You obviously need to do this division until every 4 adjacent cell (8 adjacent block in 3d) inside a chunk is stored inside one cell, essentially converting a chunk to one large cell.
How to create a voxel engine in C + +?
To create one, you can either go from tiles and group them together, or go from one huge cell and you divide it until you reach the tiles. I will use the first approach, because it’s easier to visualize.
Is it easy to generate voxels in OpenGL?
Just reading each chunk and sending it to the GPU using OpenGL is easy, but very slow. Generating one mesh per chunk would be better, but that means every time I break one block, I have to rebuild the entire chunk which could take a bit of time causing a minor but noticeable hiccup, which I obviously don’t want either. So that would be harder.