Finished Vulkan tutorial, how should I render multiple objects? For a voxel game

In the tutorial, there is a single vertex buffer and a single index buffer, do I just add all of the mesh data from all the models in the scene to them? Or do I need to create multiple buffers for each model? I want to make voxels, so every "model" will use the same texture.

And what if I need to both create models during runtime and delete them? Do I just clear the model buffers every frame and completely fill them up with the updated data? That doesn't seem very efficient.

I think these lines in the createCommandBuffers() method are important here:

        VkBuffer vertexBuffers[] = { vertexBuffer };
        VkDeviceSize offsets[] = { 0 };
        vkCmdBindVertexBuffers(commandBuffers[i], 0, 1, vertexBuffers, offsets);

        vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT32);

It appears that it takes the vertexBuffer and adds it to an array of vertex buffers, though it doesn't do this with the index buffer.

I figured out how to draw a textured cube by loading in my own vertex data upon startup, so I guess it would be nice if doing multiple objects were essentially the same but it seems inefficient, the reason you have chunks in voxel games is so when the player destroys a voxel, or places one for that matter, you don't have to update the entire world just to destroy that one voxel, you only update the entire chunk.

And before anyone wastes time I have successfully made voxel games (demos) before and I am quite versed in the theorys, I've made both a voxel raycaster using a compute shader and a rasterized voxels thing which used a compute shader to generate the noise. The only thing is these were both in Unity so I have no idea what the actual rendering process looked like. In Unity, I would just describe the vertices of the mesh, the normals, the indices, and the uv texture coordinates in a Unity class called Mesh. Then you just call Graphics.DrawMesh(Mesh) each frame for every mesh.



from Recent Questions - Stack Overflow https://ift.tt/2QFNbzb
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation