3

我有一个粒子系统,其中位置和各种属性存储在顶点缓冲区对象中。这些值由 CUDA 内核不断更新。目前我只是使用 GL_POINTS 将它们渲染为平面圆圈。我感兴趣的是渲染这些粒子更复杂,比如 3d 动画鸟类模型。我试图找出最好的方法是什么。为了便于交谈,假设鸟类模型的动画由 3 帧组成(翅膀的位置和其他)

我可以看到将模型加载到显示列表中,并在平移、旋转等矩阵中循环遍历所有粒子,然后调用显示列表。这似乎不是一个理想的方法,因为它需要将所有粒子数据从 gpu 传送到主机,只是为了进行矩阵运算以推回 GPU(除非我可以从 cuda 内核调用绘图函数?? ?)

我对着色器不太了解,他们能处理这样的事情吗?

在这一点上,我主要是在寻找有关追求什么途径的建议,但是如果您知道任何涉及该主题的文章或教程,请多多支持。


我正在使用 c++ 在 Windows 7 64bit 上本地使用 OpenGL。我没有使用过剩

4

2 回答 2

4

您可能想使用:EXT_draw_instanced。我从未真正使用过 Instancing,但大多数现代 GPU(我认为是 GF6 及更高版本)允许您向 GPU 提供模型和点列表,并让它在每个点绘制模型。

我会在谷歌上搜索更多信息,看看我想出了什么......

好吧,这是官方规范,看起来他们有关于它的教程。

http://www.opengl.org/registry/specs/ARB/draw_instanced.txt

于 2010-02-18T18:09:43.617 回答
0

You'll need to get creative to do something like that. If you used CUDA to compute a position and rotation into 2 3 component float textures and then fired an "index" along with each vertex and incrementing by 1 per geometry instance then you could write a shader that loads the textures and then uses vertex shader texture lookup to select the relevant pixel from the 2 textures and build a transformation matrix. You then transform the verts of the mesh by the transform matrix you have built.

于 2010-02-18T18:26:52.597 回答