我正在构思一种在 OpenGL 中通过一次绘制调用渲染尽可能多的不连贯几何体的好方法,而当每一 block 都具有不同的平移和旋转时,我所面对的墙是最好的方法,因为您没有在单个对象绘制之间更新模型 View 制服的奢侈。我在这里和其他地方读过其他一些问题,似乎人们所指出的方向是多种多样的。最好列出执行此操作的主要方法并尝试隔离最常见或推荐的方法。以下是我考虑过的想法:
[编辑:删除了对实例化的提及,因为它在这里并不真正适用]
除了这些还有其他常用的方法吗?
作为一个学术问题,我很好奇以上所有内容是否可行且“可以接受”,或者其中一个是否明显胜过其他?如果我要专门使用桌面 GL,实例化是实现这一目标的主要方式吗?
最佳答案
两个考虑:
Generally speaking, if you have multiple objects, with each object using independent transforms, you use multiple draw calls. That's what they're there for. The old NVIDIA "Batch Batch Batch" presentation cited between 10,000 and 40,000 draw calls per-frame (in D3D. More in GL) for a 1GHz GPU. Nowadays, you're looking at rather more than that. So unless you're dealing with tens of thousands of individual objects, all of them being different (so no instancing), odds are good that you'll be fine.
另一个想法:
Take the modelview matrix calculations out of the shader entirely and just pass the vertices after multiplication. This allows a single draw call for many objects in different orientations and translations. The cost just comes at all the CPU calculations, but I suppose if that bottleneck is not as big as the bottleneck of multiple draw calls, it would be worth it.
(取自here。)
关于opengl - 具有不同转换的批量绘图对象的最佳实践是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16128808/