I am working on a voxel engine. Currently my cubes are rendered as vbos. I thought, it may be better to load only the cooridinates of voxels to the shader and make it draw a cube itself. Can someone tell me, if thats possible, and if so, how?
1 Answer
I am currently working on a voxel engine as well. And I have found a few interesting conclusions:
- Have 6 different vbo's one for each side (each vbo has contains the vertices of all the blocks which you want to render). A vbo has 4 vertices (connect them to form triangles with an index buffer) per block which contains color information and possibly also lightning information.
- You can subdivide your world into different
chunks
and generate a vbo per chunk each time that a chunk is changed. Or you can generate your vbo per frame and just add everything which is visible to the camera. - Greedy mesh generation resulted (for me) into a 80% performance boost (I generate my vbo's each frame (for now)).
In a question of mine is my code for generating the meshes, this might also help you understand how I render my voxels. I´m not implying that my method is the best method, but this has worked for me (so far).
Here are a few of my sources (which I used to come to these conclusions):
- How can I optimise a Minecraft-esque voxel world?
- http://bytebash.com/2012/03/opengl-volume-rendering/
- http://0fps.net/2012/07/07/meshing-minecraft-part-2/
PS: This is not really an answer to the question you asked, but a suggestion. It is what I think is a better alternative.