Rendering large numbers of moving objects

Started by
1 comment, last by onnel 21 years, 7 months ago
I\ve implemented batch rendering using vertex and index buffers to render multiple objects with the same texture simultaneously. the problem with this (or at least with my implementation) is that it only works for objects that aren''t moving. I have all of the vertices defined in world coordinates and can simply pass the vertices in to the VertexBuffer without translating them. The problem is, this won''t work with objects that move (and therefore have their vertices in local coordinates and an overall translation/rotation as well). I suppose I could take the overall translation/rotation and use that to convert all vertices in to world coordinates and then use my generic batch rendering for the objects, but this sounds _slow_. Alternatively, every time I''m sure this is pretty standard stuff (unfortunately, search is down right now), so I''m sure there''s an easy answer. Can someone give me an idea of the optimal solution for this? Onnel
Advertisement
Hm, I don''t know of any "standard answers", but you could use vertex shaders for this - Assign each moving group (model) a number, and pass that number to every vertex in the source stream. Then, use a constant (or two, if you''re rotating) for every group to do the movement. You select which constant to use from the group ID in the vertex stream data. I believe version 1.1 of the DirectX vertex shader specification has a "constant pointer" to let you do this.
It''s just an idea, I don''t know how well it works, I''ve certainly never tried it myself, nor heard of anyone else using it, so don''t quote me on it.

- JQ
Full Speed Games. Coming soon.
~phil
JonnyQuest is on the right track. You can use a similar system, as it is used on hardware accelerated skeletal animation. Each vertex gets an index ID, which is supplied in the vertex stream. A vertex shader uses that index to select a transformation matrix from constant memory and multiplies the vertex with it.

As mentioned, a similar (even more complex) system is commonly used for weighted skeletal animation, and it works very well.

But keep in mind, that this system will only work on 3D cards with hardware vertex shader support, on will miserably fail on others (fallback to software transformation).

/ Yann

[edited by - Yann L on September 9, 2002 11:13:46 AM]

This topic is closed to new replies.

Advertisement