Alien Blitz 3d: performance, engine issue, brightness, random bug


I made a few tests on PC with vsync disabled, 720p, MSAA 2x, and max FPS, here’s what I got:

  • Laptop, Linux, Intel card: 120 fps (needs vblank_mode=0 to disable vsync)
  • Laptop, Linux, Nvidia card (GTX 660M): 250 fps
  • Laptop, Win 7, Intel card: 140 fps
  • Laptop, Win 7, Nvidia card (GTX 660M): 650 fps
  • Old computer, Win 7, Nvidia card (GTX 280): 1 000 fps
  • Netbook eee Pc, Win Xp, Nvidia card (ION): 60 fps (maybe an hardware limit, not sure)
  • Mac mini, Mac OS, Intel card: 20 fps

These results are quite interesting:

  • I didn’t expect my old computer to have such an high framerate (the card was good when I bought it, but it’s at least 6 years old now)
  • Alien Blitz is working on my eee pc… I really didn’t expect that, it can hardly play a 720p video and yet Alien Blitz works at 60fps
  • Results between different cards/OS can’t be compared, when running at an higher framerate than the screen refresh rate fps does not mean anything (but fps can be used to compare performance between two game versions on the same card/OS)
  • It is not playable on my Mac mini, but it is so slow to do anything that it doesn’t surprise me. It’s not meant for playing game (it’s not even OpenGL 1.2 compatible apparently)

This is good news as it means the game works smoothly on a 6 years old computer and even on netbooks. Minimum requirement is something supporting OpenGL 1.2 I guess, dual core or more is preferable.


Engine issue

Alien Blitz is the first game I made seriously and it has a major issue since the beginning: it can only run at a fixed framerate.

Usually when developing a game the engine will run at a variable rate and all calculations are based on a delta time (time between last frame and current). In Alien Blitz the physics can run with a delta time but not the AI and some other calculations.

So the engine can only run at fixed rate of 15hz, 30hz, or 60hz

On mobile the engine runs at 15hz and uses position interpolation to render at 30fps, on PC the engine runs at 30hz and uses position interpolation to render at 60 fps.

Problem appears with multi core (separating engine & rendering):

  • Mono core: engine & rendering are synced, engine is run every 2 frames, if frame rates drops the engine will also slow down
  • Multi core: engine & rendering are not synced, if frame rates drops engine will still run smoothly (preventing slow mode), rendering issues can appear because a frame might be rendered while calculation is in progress.

The major problem with multi core appears on the mecca model as it’s the one the camera follows, it makes some strange movements every few frames. To solve this problem I exported a few engine stuff (camera & player movement) on the rendering engine some time ago.
Basically what you see on screen is the “supposed” position of the player, it’s virtual until the engine really computes it and checks if it is valid (you can see that when colliding walls, when you release movement key player will be sent back a bit farther from the wall)

Up to now it was working nicely in 2d on mobile as usually the lag will either affect fps and engine or just the engine. So everything will slow down, or just the monsters (making it a bit easier for player, so it’s ok this way).

In 3d and on PC (where framerate is higher) the engine usually runs at a very stable 30hz and the framerate might eventually slightly vary (if lots of effects on screen, or anything else). So it means player movements might slow down a little while monsters remain at correct speed, which is of course a problem.

So to avoid that I made a few changes to the engine, camera & player movements now use a dynamic framerate (using delta times), and voilĂ  ! everything is working fine, and it also means I can let the user decide framerate in the option file. Acceptable values are between 30 and 60fps, more than 60fps is useless as engine won’t make calculations for these extra frames (and it will even be worse than 60fps), and below 30fps it will look bad. I might at some point make the interpolation delta dependent to get 120fps, but it’s not a priority.

It works ok but it’s just a workaround, my next engine (based on current one, voxel terrain and classic models) will be using dynamic framerate from the beginning.



Brightness option is back, but it will only be available for 3d mode

(50%, 100% and 200%)

capture_2014-07-26_16-35-01_0827_Alien_Blitz_ capture_2014-07-26_16-33-50_0212_Alien_Blitz_ capture_2014-07-26_16-35-25_0354_Alien_Blitz_

It can be changed at any time in the options.


Random bug

There is a random bug that seems to appear more on some levels. The problem is that it’s completely random and there’s absolutely no log displayed. The JVM will just stop, no exception thrown, no throwable, no core dump, nothing. It’s exactly as if a System.exit() was called, except the only ones that can be called in my game are surrounded by log entries so I know it’s not them.

It’s very hard to debug it as it’s random, yesterday it happened 5 times in a row on the same map, but didn’t happen anymore after restarting eclipse. I don’t think it’s an eclipse problem because I would get some logs at some points… I’m lost, I even tried switching from Java 6 to Java 7, but no luck.

I also checked memory and graphical memory but both are stable @ around 100mb each, so it’s definitely not the problem.

One strange thing is that this bug appeared after I upgraded my system (xubuntu 13.10 to 14.04, I did a fresh install), it might just be a coincidence though.

Comments are closed.