RTS performance with PlayCanvas

How does playcanvas handle hundreds of low poly units? Is a game like this possible at 60 fps?

There is no reason why an RTS game isn’t possible in PlayCanvas. Graphically, PlayCanvas is limited by the hardware it runs on, in the same way that a PC game is.

Is it possible at 60fps? Absolutely, but like all games it depends on you optimizing your game logic to make sure it will run fast enough. Generally, with Javascript the most important thing is to avoid allocating objects which will trigger the Garbage Collector when they are deleted.

The PlayCanvas Engine is designed to do as little object allocation as possible to prevent these sort of performance problems.

Hi! So if you have 100s of independently moving units in your game, typically, a graphics engine will, by default, render these as individual draw calls. PlayCanvas is no exception. Every draw call will have some CPU overhead, but the engine has been heavily optimised to reduce this cost as much as possible. Obviously, the number of draw calls (or units) you can render at 60FPS will depend on your device. An iPhone 4S will be able to render a fraction of the units a high end Core i7 CPU can handle.

There are techniques to optimise a graphics engine to be able to render many copies of the same geometry in a single draw call. There is a WebGL extension called ANGLE_instanced_arrays that can do just this but, currently, PlayCanvas does not make use of this (you have to remember that this extension is not universally supported anyway). We’ll see if we can leverage this in the future though, and obviously, since the engine is open source, we’d love to see developers come up with cool additions to the engine that make these kinds of optimisations.

Something else that can be done is to write multiple copies of a mesh into a single vertex buffer and a transform per vertex. This means that you can render lots of independent copies of a mesh in a single draw call but works best for meshes with only a small number of vertices. This is often how GPU-based mesh particle systems work. I’m not sure this would be suitable for RTS units though.

I’ll ask the team to see if they have any more thoughts on this… :smile: