每个网格有多个顶点缓冲区
我遇到过这样的情况:网格及其所有顶点和索引的大小大于(最佳)顶点缓冲区对象上限(~8MB)。我想知道是否可以将网格细分到多个顶点缓冲区,并以某种方式保留索引的有效性。即一个三角形,其第一个顶点有一个索引,最后一个顶点有一个索引(即在单独的 VBO 中)。
始终在顶点数组对象中维护这一点。 我的想法是,省去麻烦,对于像这样的网格(混乱:P),只需使用必要的大小(> 8MB)即可;这就是我现在所做的。 但理想情况下,我的缓冲区管理器(wip)目前正在使用最佳大小;那么我可能只需要做一个特殊的情况。
有什么想法吗?
注意:我还在 gamedev 堆栈 上交叉发布了此内容,因为我不确定哪个更合适(部分是设计问题)。
I've run into the situation where the size of my mesh with all its vertices and indices, is larger than the (optimal) vertex buffer object upper limit (~8MB). I was wondering if I can sub-divide the mesh across multiple vertex buffers, and somehow retain validity of the indices. Ie a triangle with a indice at the first vertex, and an indice at the last (ie in seperate VBOs).
All the while maintaining this within Vertex Array Objects.
My thoughts are, save myself the hassle, and for meshes (messes :P) such as this, just use the necessary size (> 8MB); which is what I do at the moment.
But ideally my buffer manager (wip) at the moment is using optimal sizes; I may just have to make a special case then.
Any ideas?
Note: I have also cross-posted this on the gamedev stack, as I was not sure as to which it would be more suitable (its partly a design question).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于单个模型来说,8MB 的顶点数据相当多。我很确定这个模型可以分成单独的网格。分割网格的好地方是锐边,因为沿着这些边的顶点具有不同的法向量,因此不相同并且不能共享。
然而,比 VBO 大小更重要的是传递给 glDrawElements(或 glDrawArrays)的渲染批次的大小。根据我的经验,在缓存压力发挥作用之前,渲染批次的最佳大小在 100 到 2000 个三角形之间。但您应该自己在系统上进行测量。
8MB of vertex data is quite a lot for a single model. I'm pretty sure this model could be split into individual meshes. Good places for splitting a mesh are sharp edges, since vertices along these edges have different normal vectors are thus not identical and cannot be shared.
However more important than the VBO size is the size of the render batch passed to glDrawElements (or glDrawArrays). In my experience the optimal size for render batches are between 100 to 2000 triangles, before cache pressure kicks in. But you should measure that on your system yourself.
据我所知,您只能设置一个 glVertexPointer。因此,您可以将此指针设置为指向您的大数据存储,但这将位于客户端内存中并且没有 VBO。如果您想使用 VBO,一次只能有一个。
但实际上,您可以将所有数据保存为纹理,并使用几何着色器仅从索引重建模型。我的 Radeon 3870HD 上的纹理限制是每个维度 8192 个,但使用超过 1D 纹理时更有可能耗尽内存(我的卡上有 512 mb 内存,完整的 2D RGB 纹理约为 805 mb)。在几何着色器中,您可以根据支持的索引连接顶点并创建网格,但这是相当大的解决方法并且不太实用。
正如前面提到的,做如此精确的模型是相当浪费资源的。在大多数 3D 设计器中,您可以使用修改器来获得更少的多边形而不影响视觉效果,您只需选择过于详细的部分即可。当您想到大多数时候您会看到大约 50% 的模型而其余部分被测试丢弃时,这也会对性能造成巨大影响。
To my knowledge, you can set just one glVertexPointer. So you could set this pointer to your big data storage but that would be in client's memory and without VBO. If you want ot use VBO there can be only one at time.
But actually you could save all your data as texture and use geometry shader to rebuild model just from indices. Texture limit on my Radeon 3870HD is 8192 per dimension, but you are more likely to run out of memory using more than 1D texture (512 mb memory on my card and full 2D RGB texture is around 805 mb). In geometry shader you can connect your vertieces acording to supported indices and create mesh, but it's quite big workaround and not very practical.
As mentioned it's rather waste of resource to do such precise models. In most 3D designers you have modifier to get much less polygons without affecting visuality, you just choose part that is overdetailed. It's also huge performance hit when you think about that most of time you see arround 50% of model and rest is discarded by tests..