Jump to content

Mass Warfare Implementation



There have been a lot of lessons learned now that I’m finishing my first large project. RTS games continually push the limit on unit and structure counts and with the latest OpenGL features I would argue it’s now possible to have hundreds of thousands of units.


The strategy is simple, the implementation can get tricky. Keep all movement and calculations on the GPU and use textures as data structures (optional). The concept borrows a similar idea of a lot of modern particle systems in that each unit is treated like a particle.


The limitation is communication between units. An example would be one unit firing upon another or a unit searching for the nearest unit. This can be timely and may require multiple draw commands or shader logic updates.


A rough high level overview looks something like this –

Create the following textures to represent the corresponding data.




Use the textures RGB values to represent xyz and Yaw, Roll, and Pitch.


Pass1 update each objects position and rotation to get nearer to the destination and store each units new location in the textures.


Use OpenGL’s glDrawElementsInstanced command to draw lots of units very quickly, using gl_InstanceId to represent each units information in the textures.


If you strictly plan on deploying to a PC you can disable the Rasterizer in the pipeline, use transform feedback, as well as texture buffers to improve performance even further.


Using these technologies can be tricky but exemplifies a strategy for computing mass warfare. My intel laptop with a Passmark benchmark score of 340 can update and render about 50k units. The GTX 780 with a score of 7,952 theoretically could handle 1.1 million units. (Units were pyramids consisting of 4 vertexes, no textures and nothing else drawn or updated)


Recommended Comments

There are no comments to display.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...