So Im trying to make a minecraft style voxel game to learn OpenGL, but Im running into performance issues. I found this thread : https://stackoverflow.com/questions/4995652/3d-occlusion-culling where the author says he's drawing 250,000 cubes with an okay framerate. However, I can do about 3000 ish with the same framerates. I found another thread in which someone said that you should combine visible faces into a mesh. Does that mean you put all the vertices into one vertex buffer? If so, how do I pass texture data?
-
\$\begingroup\$ Welcome user, this is a very broad question, too broad for the site. You need to use a profiler and find out which parts of your code are slow. Try to improve those parts, if you're unable to, then come back here with a specific question about that part of your game. Make sure to include what you tried and why it didn't work. \$\endgroup\$– HouseCommented Jul 6, 2013 at 18:38
-
1\$\begingroup\$ @Byte56 I think the question is OK now, even answerable. -> Yeah, you should try to use as many batches as possible, that is, combining the more cubes you can, in the less vertex buffers you can. This is a good resource on the matter: 0fps.wordpress.com/2012/06/30/meshing-in-a-minecraft-game And to use more than one texture, you can use a texture atlas, or even multi-texturing, though atlas will give you the best performance! \$\endgroup\$– Gustavo MacielCommented Jul 6, 2013 at 22:28
-
\$\begingroup\$ @GustavoMaciel All yours. \$\endgroup\$– HouseCommented Jul 6, 2013 at 23:15
1 Answer
Yeah, you should try to batch as much as possible, that is, combining the more cubes you can, in the least amount of vertex buffers you can. This is a good resource on the matter of Voxel Meshing. I recomend you to follow the culling algorithm, even older versions of minecraft used it and stood well at good framerates.
To use more than one texture, you can use a texture atlas to fake that. Some devices might even support multi-texturing in a single batch, which would be easier to work with, though the atlas will give you the best performance!
-
\$\begingroup\$ So I already use the culling method where you check all sides, but the frame rate is still pretty bad \$\endgroup\$ Commented Jul 7, 2013 at 12:32
-
\$\begingroup\$ But you are saving the whole mesh in a single batch? If you render the cubes separately, the framerate will be very low. \$\endgroup\$ Commented Jul 7, 2013 at 15:23
-
\$\begingroup\$ i guess im missing what a mesh is...but when you dynamically combine a mesh, how do you draw the different textures? \$\endgroup\$ Commented Jul 7, 2013 at 20:10
-
\$\begingroup\$ Read the last paragraph. \$\endgroup\$ Commented Jul 8, 2013 at 1:08