OpenGL: Are VAOs and VBOs practical for large polygon rendering tasks?

坚强是说给别人听的谎言 提交于 2019-12-10 11:27:08

问题


If you wanted to render a large landscape with thousands of polygons in the viewing frustum at a time as well as the user's viewpoint changing constantly, is it practical to use VAOs or VBOs?

I mean, every time the player's position or camera rotation changed, you would have to recompute the vertex data in order to properly cull any vertices or scenes which are no longer seen in order to keep a good FPS count. But in doing this, your FPS count would go down because you are, well, repacking all the buffers constantly.

So is it still beneficial to use these two methods over immediate mode?

My guess is yes because with Immediate Mode, you are also recomputing all the vertices every frame, just in a slightly different way. Sadly, I don't have much background with any of this, and I am confused because the internet has a mixed message on this topic.


回答1:


The answer is yes, VBO's are practical for large polygon rendering tasks. Immediate mode should not be used because it's part of the fixed function pipeline and the FFP is deprecated.

But you should not recompute the landscape every frame and store it in the buffers again. There are some ways to handle such situations but you should avoid to update a VBO each frame because this could lead to resource conflicts.

  • Use some kind of LOD. There are different ways to do this ( Look here to get a image how this could work, but don't have to ). Generally you reduce polygons when the scene has a large distance to the viewer. If you have a 2D Terrain ( No overhanging terrain ) it's very simple. If your terrain is more complex it is harder to handle this but still possible.
  • Keep all the buffers in RAM which may be visible in a few moments ( but don't have to ), this is very memory consuming compared to the LOD approach. If the terrain segment is out of view range remove it.
  • Stream the data and with double buffered VBO's ( This means: For one segment you have 2 VBO's one which is rendering and one which is written to )



回答2:


I mean, every time the player's position or camera rotation changed, you would have to recompute the vertex data

No you don't. In your typical terrain renderer the data is subdivided into tiles. And usually those tiles subdivide again, and again to implement level of detail. What sets the tiles apart are the vertices they reference. So you'd have one large vertex array for the terrain data, and a lot of index arrays for the tiles. By calling glDrawElements with the right index arrays you can select which tiles to draw at which level of detail.



来源:https://stackoverflow.com/questions/14573909/opengl-are-vaos-and-vbos-practical-for-large-polygon-rendering-tasks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!