Tweeted twitter.com/StackGameDev/status/1136060075313958912
2 spelling and grammar
source | link

I am trying to write a little voxel engine because it's fun, but struggle to find the best way to store the actual voxels. I'm aware I will need chunks of some sort so I don't need to have the entire world in memory, and I'm am aware I need render them with reasonable performance.

I read about octree'soctrees and from what I understand it starts with 1 cube, and in that cube can be 8 more cubes, and in all those 8 cubes can be another 8 cubes etc. But I don't think this fit'sfits my voxel engine because all my voxel cubes/items will all be the exact same size.

So another option is to just create aan 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). But I'm afraid this is going to waste a lot of memory and won't be very fast.

Then another option is a vector for each chunk, and fill it with cubes. And the cube the holds it'sits position in the chunk. This saves memory  (no air blocks), but makes looking for a cube at a specific location a lot slower.

So I can't really find a good solution, and I'm hoping someone can help me with that. So what would you use and why?

But another problem is rendering, just. 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 everytimeevery time I break one block, I have to rebuild the entire chunk which could take a bit of time causing a minor but noticable hickupnoticeable hiccup, which I obviously don't want either. So that would be harder. So how would I render the cubes? Just create all the cubes in one verticesvertex buffer per chunk and render that and maybe try to put that in another thread, or is there another way?

Thanks!

I am trying to write a little voxel engine because it's fun, but struggle to find the best way to store the actual voxels. I'm aware I will need chunks of some sort so I don't need to have the entire world in memory, and I'm am aware I need render them with reasonable performance.

I read about octree's and from what I understand it starts with 1 cube, and in that cube can be 8 more cubes, and in all those 8 cubes can be another 8 cubes etc. But I don't think this fit's my voxel engine because all my voxel cubes/items will all be the exact same size.

So another option is to just create a 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). But I'm afraid this is going to waste a lot of memory and won't be very fast.

Then another option is a vector for each chunk, and fill it with cubes. And the cube the holds it's position in the chunk. This saves memory(no air blocks), but makes looking for a cube at a specific location a lot slower.

So I can't really find a good solution, and I'm hoping someone can help me with that. So what would you use and why?

But another problem is rendering, 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 everytime I break one block, I have to rebuild the entire chunk which could take a bit of time causing a minor but noticable hickup, which I obviously don't want either. So that would be harder. So how would I render the cubes? Just create all the cubes in one vertices buffer per chunk and render that and maybe try to put that in another thread, or is there another way?

Thanks!

I am trying to write a little voxel engine because it's fun, but struggle to find the best way to store the actual voxels. I'm aware I will need chunks of some sort so I don't need to have the entire world in memory, and I'm am aware I need render them with reasonable performance.

I read about octrees and from what I understand it starts with 1 cube, and in that cube can be 8 more cubes, and in all those 8 cubes can be another 8 cubes etc. 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). But I'm afraid this is going to waste a lot of memory and won't be very fast.

Then another option is a vector for each chunk, and fill it with cubes. And the cube holds its position in the chunk. This saves memory  (no air blocks), but makes looking for a cube at a specific location a lot slower.

So I can't really find a good solution, and I'm hoping someone can help me with that. So what would you use and why?

But another problem is rendering. 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. So how would I render the cubes? Just create all the cubes in one vertex buffer per chunk and render that and maybe try to put that in another thread, or is there another way?

Thanks!

    Became Hot Network Question
1
source | link

Storing voxels for a voxel Engine in C++

I am trying to write a little voxel engine because it's fun, but struggle to find the best way to store the actual voxels. I'm aware I will need chunks of some sort so I don't need to have the entire world in memory, and I'm am aware I need render them with reasonable performance.

I read about octree's and from what I understand it starts with 1 cube, and in that cube can be 8 more cubes, and in all those 8 cubes can be another 8 cubes etc. But I don't think this fit's my voxel engine because all my voxel cubes/items will all be the exact same size.

So another option is to just create a 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). But I'm afraid this is going to waste a lot of memory and won't be very fast.

Then another option is a vector for each chunk, and fill it with cubes. And the cube the holds it's position in the chunk. This saves memory(no air blocks), but makes looking for a cube at a specific location a lot slower.

So I can't really find a good solution, and I'm hoping someone can help me with that. So what would you use and why?

But another problem is rendering, 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 everytime I break one block, I have to rebuild the entire chunk which could take a bit of time causing a minor but noticable hickup, which I obviously don't want either. So that would be harder. So how would I render the cubes? Just create all the cubes in one vertices buffer per chunk and render that and maybe try to put that in another thread, or is there another way?

Thanks!