Game Design, Programming and running a one-man games business…

Too much stuff on screen

This is a screenshot of GSB2 (click to enlarge). Nothing particularly impressive, but when looking at it, and then stepping into code to see whats going on, it’s clear that the engine is kinda pushing against limits for hardware on laptops etc (This is with graphical detail at maximum, so that will be less of an issue eventually).

screenshot_28-12-2014_13-09-31

I think that ultimately, I’m making too many draw calls, and lesser hardware can’t handle it. because of the nature of the engine, those draw calls are vastly higher than the amount of actual objects on screen, because there is depth, and lightmaps and other trickery that magnifies the effect of, for example, just rendering a single sprite of a fighter ship. That fighter ship probably involves more like a dozen draw calls :(. In the scene shown, we have 915 3D objects (most are not onscreen), 266 depth objects, 648 lightmap objects, 89 ‘splats’, 372 effects and 216 saturated effects. Thats clearly a lot :(

I’ve seen the game do 5,000 or more draw calls in one frame, and thats kinda bad, so the way I see it my approach to optimization could take various paths:

1) degrade some less important stuff when we exceed a certain number of calls / drop below 60 FPS. Not ideal, but a brute force way to fix it.

2) Further optimize some stuff that is currently done in single draw calls, like parts of the GUI, to get the general number of calls down.

3) Slot in a layer between my current engine and DirectX, which caches states yada, and collapses draw calls into fewer calls where the texture/shader/render states are the same.

Theoretically 3) is vastly better than the rest, but I fear that I’m adding another ‘layer’ here which could in fact be slower, and also that I’m keeping poorly optimized code and fixing it after the event. After all, the best solutions to speedups are always algorithmic, not close-to-the-metal; tweaking. However, another benefit of 3) would be that such an abstraction layer makes the job of porting the game slightly easier. I’m considering implementing it anyway, so I can at least see how often such a ‘collapse’ of draw calls can happen. In other words, would this reduce the count by 5% or 90%?

So that means replacing the DrawPrimitve() calls with a macro, maintaining a cache of the render states (or maybe just letting any RS change flush the buffer? and just (for now) initially keeping track of the collapsible draw calls. I’m going to give that a go… Or maybe I should see what the hell all those objects are first…

On programming decent 2D Game Explosions

Getting explosions right is HARD. Explosions are (obviously) a big part of Gratuitous Space Battles 2, and I want the GBS2 ones to be better than GBS1 by a noticeable margin. They already are, but I’m aiming for greater heights. Currently the explosions look like this:

exp1

And this: (smaller ones)

exp2

Which is ‘ok’, but I’d like them to be better, which means spending a lot of time looking at video of space battles (oh the things I have to suffer), freeze framing, stroking my chin and looking at code. There are a number of things people assume about this task which I’ve found not to be true.

Assumption #1: You can do it all on the graphics card. Not so, because different people have different cards, whose capabilities may vary dramatically. I want GSB2 to be playable on a standard laptop, not demand a DX11 driver and card. Plus a lot of these techniques assume Directx11, and you then need a DX9 backup for people who still have windows XP anyway so….

Assumption #2: it’s simply about the number of particles. Not so. I have a fairly efficient particle system that can handle lots, but I have found more does not always equal better. In short, it doesn’t seem to be how many particles you have, but how they interact, what textures they use, and how they move. Render modes (additive vs normal) also factors in a lot.

Generally, my approach has been to have a bunch of particle emitters all clustered together into one explosion. I have some big black clouds that build slowly, some firey small particles that fade out quickly (additive ones), some flame-texture particles that are additive, and some not additive, and I render them in a deliberate order and it looks like the stuff you see above, which is fine, up to a point.

The thing I haven’t managed to really convey is the ‘billowing’ effect of an explosion. Here are some of my reference images…

ex3exp4

This sort of thing is very hard to get right ‘in-motion’ because it involves some 3D movement of frankly millions of particles, so obviously the first question is how on earth to ‘cheat at it’ and get it looking vaguely right. In Gratuitous Stank Battles I tried a complex system where particles had #heat’ assigned to them, and cross-faded between white hot to black smoke (and different textures) over time. it looked ok, but probably not enough difference to warrant a bucket of extra code that was associated with it.

I am starting to think that decent explosions are 90% physics, 10% graphics. What I need is some more complex control over the movement of individual particles, rather than just more of them. With the explosion at the bottom, I’m thinking that there are a bunch of different ‘focal points’ of the explosion, different ‘billow-centers’, if you will. There has obviously been a central ‘bang’ and this has ‘spawned’ a bunch of airborne ‘flame emitters’ which continue to create new burst of flames which are created, balloon up, and then down and dissipate.

Currently I have zero support for such a system. An explosion is a single event, which may have a bunch of timed emitters with it, but it has a single focal point. Secondly, a particle has a single growth variable, which means it either is spawned and gets bigger over time, or it gets smaller over time. What I may need is the capacity to associate a timed sinewave with the size of a particle.

So my latest explosion todo list (fun stuff I do when I’m not busy) is something like this…

Add support to particle configs for a ‘sinewave-based’ growth variable, with starting size, max size and duration.

Create a new class of object called a GUI_SubExplosion, which can be spawned by an explosion and drift off from the central point slowly over time. Have that sub-explosion itself contain a list of particle emitters that it manages.

Should be worth a try anyway… In the meantime here is the latest big pharma blog video. and a nice article on showmethegames about banished.

The joy of building, and treating simulation and strategy games as toys

I had a few negative reactions (not many) to some of my early screenshots and videos of Gratuitous Space Battles 2 Screenshots like this:

dread1

Basically people didn’t like the ship designs and colors. The colors were too gaudy, and they hated any hint of a checkerboard pattern because it makes them think of placeholder textures. This amused me, because actually the designs are based upon the artist chriss foss, who I liked as a kid. He did some really distinctive spaceship designs. Some people may dislike them, but in a world of identikit spaceships, his stood out.

So much for blocky color patterns, but the other criticisms (that the designs were not good) is more relevant, and serious. It is, of course, entirely a matter of personal opinion. For contrast, here is a few ships from GSB1:

gsb1

Some of you may prefer that. So this blog post is here to make you feel better :D.

Firstly, do you know who designed the spaceships in all the GSB2 screenshots and videos? It was ME. ME!!!!! And I don’t have much of an artistic eye, or patience, or time. The basic components are done by the talented GSB1 artist, but then my totally clueless hands have been let lose on them, using an unfinished space ship designer, so this is what comes out. In other words, people with more of a sense of style, more patience, more time, and finished editor…should turn out MUCH nicer stuff. I’m also toying with the idea of actually paying someone to design the initial enemy ships for this very reason, although I’d love to try it myself…

The thing is, I am vastly more of a fan (as a player) of stuff that lets me put my mark on it. Sim City is great, but it’s even better when you have the building design tool. One of the appeals of minecraft is surely building things. People spend a crazy amount of effort just designing their clam logos for Battlefield 4. Give the player a ‘customize’ option, and you will lose them for an hour or ten. Even spore, a game that people rapidly dismissed as bad (despite earlier promise) had a huge number of high quality creature designs. And the ultimate example of people designing awesome spaceships so far is probably galactic civilizations 2, where people have clearly spent hours and hours designing the ultimate space battleship.

Yup, we may not all be experts, but I’ll take a ship I’ve customised over a ‘stock’ ship any day. People like to stand out, they like to create, they like to ‘play’. And this is where I like to think my games often cross the line from what people call ‘games’ into toys. I have never been a fan of scripting in games, or linear experiences. We have books and movies for that. Games give us freedom, freedom to experiment, to define our own rules, to invent, or at least they could…

fpsmap-650x519
FPS Design over the years…

Back when I first started gaming, a lot of games gave you a sandbox experience. It was frankly easier and cheaper than level design, and limits of file sizes mean you simply couldn’t fit 200 hours of RPG backstory onto a floppy disk. This resulted in incredible free-form strategy epics like Lords Of Midnight. I really miss those times, and that encouragement for free-form experimentation. Kids these days do not really ‘play’ games. They ‘compete’ at them, to ‘win’, or to ‘beat’ them. This feels weird to me. I’m always playing to have fun, not to go along with what a designer has decided I will do that day. In the ideal Star Trek MMO, I’d just tend a ferengi bar, but the designer no doubt wants me to go ‘questing’…

Democracy is probably the most free-form of my games so far, but they all have a hint of it in them. Kudos didn’t really have a proper ‘end’ as such. there was no boss to beat or princess to rescue. It was a toolkit, a toy, and bunch of things to play with, woven together as a functional simulation that let you play out ‘what if’ scenarios.

That’s what GSB2 is. It’s a big pretty spaceship battle toolkit for you to have fun with. If anyone complains that they’ve ‘beaten’ it, or Democracy 3, then they haven’t understood the purpose of the product. A game is not a challenge from the designer to the player, but an environment created so the player can experiment and enjoy themselves. That’s why there are customizable spaceships in GSB2. It’s not about the designer, or the artist, but about the player, and I believe in giving the player as much control as possible.

 

 

GSB2 at EGX

I’m too tired and busy to blog properly right now, so enjoy this video of me talking instead. I’ve clearly lost my voice at this point in the day :D

Posted in gsb2 Tagged