Is it possible to combat the speed of a library that you don’t control?

As mentioned in Welcome to The RainEngine, I’m using the ASGE (AwesomeSauceGameEngine) for my 2D engine (which will be taking up roughly 80% of my time on the assignment, but I believe it’s worth it). The engine is extremely basic and isn’t optimized, that means that it can be slow when faced with a load it wasn’t explicitly designed for.

Take one million objects for example.

With 1m objects, the engine’s speed decreases to around .25 frames per second. This can be combated by running the built program in Release mode instead of Debug mode (where that increases to 43 frames per second, which is workable) but of course that means that it’s not possible to (easily) debug the program.

The problem lies in the engine’s renderer, specifically a loop in the render API function override where I loop over all 1m objects and tell the engine to render. This isn’t something that can easily be fixed on my side as utilizing threading wouldn’t work as it would require cross-thread communication, and detaching the thread from the main thread so that the slowness of the renderer (which will happen regardless) doesn’t slow the pre-render down. That also means that other techniques such as CUDA are out of the question.

That doesn’t rule-out the use of these techniques to speed-up other parts of the program, such as the simulation of each rain particle. I’m considering using Nvidia CUDA for that, but that would also mean that RE wouldn’t be able to run on computers not equipped with a Nvidia GPU.

For now I’ll settle with the 43FPS for production (showing off the engine) and I’ll simply have to decrease the amount of particles when working in Debug mode…


Welcome to The RainEngine

For a university assignment on game systems I’ve chosen to do regular good ‘ol rain… with a twist. The assignment calls for creation of one of four systems (rain, sand, sound, text-based game) to be implemented in at least two game engines (I’m using one 2D and one 3D).

In the 2D game engine, ASGE, I’m having to create everything from scratch as it is primarily a rendering engine and does not have anything else such as a particle or physics system. Thus RainEngine is born: a particle system for rain, where each rain particle is contained in a group and this group is controlled with parameters that links it to the wider system.

Simulating rainfall isn’t too difficult; render the particles, adjust their angle and slide them down the screen, and perhaps add a small variable bounce effect when the rain hits an object (such as the ground). I intend to do that but I also intend to add some liquid dynamics by allowing the rain to flow down objects, such as sloped surfaces.

I also intend to add environmental attributes to allow the rain to adjust to the environment, for example:

  • Weather will affect size and density of the rain, which will affect its physics (i.e. its “splash physics”)
  • Temperature will affect the physical parameters of the rain at a molecular level (aka, turning into ice, snow, etc.). Each rain particle group will have its own temperature that will determine what the particles in that group are, and how it transforms.
  • Humidity- high humidity combined with a desert environment will result in a violent rainstorm with large dense raindrops.