GemIslands example

I found that the performance of the GemIslands example project is very poor. What is the reason?

I haven’t tried it, but clearly there can be many reasons. Number of objects in a scene will slow things down. Amount of logic done in the main Update can slow things down. Lots of adding objects dynamically to the scene can slow things down.

There are many things that can be done to speed things up.
streamlining loops, reducing branching logic, looping arrays by walking pointers, convert duplicate divides into multiplies. It is unlikely that a sample project is highly optimized. I’d start with what’s happening in the main update.

Hi dtamade, thank you for your feedback.
I am the author of the game “Gem Islands”. I am just a user of the CGE. I tried using only standard objects using the editor, or code recommended by CGE.

Do you compare the game witch other games, or game engines, or only the frame rate?

My coding can certainly still be improved. I am open to any suggestions for improvement. What I’ve seen is that the animated models (enemies) consume a lot of the performance. I use at the moment Win11 on a Lenovo ThinkPad T580. The game is running with 20 FPS relatively constant. What value did you find?

Perhaps michalis can contribute more on this topic.

20 frames is relatively low… :sweat_smile:
I haven’t used the castle engine in depth yet. I just tried it out and I can’t provide much discussion. Sorry.

Also make sure you are compiling in ‘Release’ mode and not ‘Debug’. For me, ‘Debug’ cuts framerate in half.

From my tests of Gem Islands, I didn’t really look at FPS, but I remember the game played totally smooth – this was on a laptop that is now 6 years old I think (Asus TUF Gaming FX504G).

I don’t have much insight what could be problematic, other than to “test, test, test” :slight_smile: It’s hard / impossible to answer questions “why is there a performance problem” without actually testing (on a hardware where the performance drop is noticeable).

As @edj says, there are many things that could contribute to performance. We have a big manual page listing various things to test: Optimization and profiling | Manual | Castle Game Engine (including the “release” vs “debug” speed difference – it can indeed be large).

@Didi A valid approach is just to look at FPS, and if you have less than your monitor refresh (typically, less than 60) than just try to disable various game / graphic elements, and see what gives most speedup. If you don’t display clearly FPS in the UI, add a debug button to see it – you don’t want to depend on “feels slower / faster”, our eyes may deceive us, it’s definitely better to see the objective numbers.

My first guess would be to disable shadows – dynamic shadows can consume significant time. And, while we can invent various optimizations, the shadows always remain a noticeable performance hog. For lower-end machines, maybe an option in graphic settings to disable shadows makes sense. (But before implementing this, definitely test first, following my first advise! See if shadows really make some noticeable difference for your game. Maybe the shadows are not a bottleneck in this case.)

Using full-screen rendering may also improve performance.

Make sure you have “dedicated GPU” lines in the program ( Dedicated GPU | Manual | Castle Game Engine ) active too.

But, again, I started to speculate above – this is not good :slight_smile: The first order of business should be to test. Don’t believe any “gut feeling” about the performance before you really test it.

@dtamade On the report side, I would encourage to send more details. “Performance is very poor” is not a precise bugreport :slight_smile: We don’t know exactly how many FPS do you see, and we don’t know on how old / new hardware are you testing.

  • Show screenshots with FPS (I really don’t remember now whether “Gem Islands” display FPS – if not then I advice to show them, maybe after pressing some debug key).
  • Specify what system you use (like a laptop model, as you see me and @Didi above specify), what operating system.
  • If you can, a detailed log would actually be helpful. Download Castle Game Engine , open any project, use “Help → System Information” button “Save To File” to generate a log.

Thanks everyone for feedback. I’ve done a few performance runs over various projects (in Castle Game Engine too, e.g. our https://www.unholy-society.com/ had performance issues at one point – some because of game code, some because of unoptimal code in the engine). It was a tiresome process, but also super-rewarding in the end, to fix it all. It is always possible to find the source of performance problem in my experience, and getting to the point “it runs with 60 FPS on every hardware I can find” is very rewarding :slight_smile: If the problem is on the engine side, I’m of course ready to address it (or point to some Roadmap | Manual | Castle Game Engine point that maybe even plans it already).

Okay, on my laptop with 8th generation i7 and 1066 GPU, the running frame rate of the release compiled binary is about 25-30 fps.
So I think it’s very unsatisfactory

Does that framerate interfere with game play? Or are you just saying that because you have heard higher numbers on different games in the past? The world for my city builder runs at 30fps in debug mode… yet movement around is totally smooth. It only gets choppy under around 20fps. But then nobody is shooting at me, that could make a difference in experience. Remember theatrical movies are 24fps. That isn’t slow.

Believe or not there’re a lot of people who can tell the difference between 30FPS and 60FPS. To me what matter more is that more FPS usually mean less input lag, which is especially important if you play competitive games (I am a long time fighting game player so I know what I am talking about)