Developer diary

Alien Blitz: balance, help

Balance

Some more modifications on balance:

  • Lowered ammo capacity for all weapons
  • Added free ammo for shotgun on maps 1 & 2 (time for player to understand he mustn’t waste them)
  • Previously you were getting more ammo depending on your level, now it depends on the map level (helps if you are under-level, more consistent if you are not)
  • Lowered ammo from boxes & life from medkits on hard/nightmare

 

Help

I’ve changed help screens, they are now popup with image & description. You must close them by touching screen / pressing a gamepad button / pressing a key.

They can be turned off in the options, but they are just in the first 3 maps anyway and are only blocking once (after viewing them there will just be the small non blocking tooltip)

capture_2015-02-18_19-16-54_0393_Alien_Blitz_ capture_2015-02-18_19-18-59_0299_Alien_Blitz_

 

 

Read more

Alien Blitz: z-fighting on nexus 10, mobile version

Z-fighting on nexus 10

I had some craziness happening only on my Nexus 10, some kind of z-fighting / image flickering

2015-02-17 13.43.25

I could somewhat reduce it by increasing camera near, and reducing far, but not completely remove it (at least now camera near/far is dynamically computed to get best values).

It appears I had to change the float resolution in the shaders

precision highp float;

What I don’t get is that it is working fine on other devices with mediump, and that it was working fine with previous version…

So I guess I’ll use highp from now on, and hope it doesn’t reduce framerate too much (doesn’t seem to change anything so far).

 

Mobile version

Most of the updates lately were targeted at the PC version of Alien Blitz, and I should update the trailer/screenshots soon.

But as I worked quite a lot on the engine and some other stuff I need to release a new mobile (Android/iOS) version too:

  • Small bugs/glitches correction
    • misplaced textures
    • some rare bug correction
    • achievements sometimes not displayed
    • bad check conditions for no damage achievements
  • Reduced video memory consumption
  • Small performance upgrade
  • Small graphical changes
    • Fade out at end of level
    • New item pick up effect
    • Sprite border in high quality (advanced options)
  • New advanced option screen
  • New end of level screen

I am currently testing it, if everything goes well (and assuming I don’t add anything new) there should be an update by the end of the month.

At the moment I just played one level on all my test devices (nexus 7, nexus 10, galaxy s3, ipod touch) and it seems fine, but it needs more testing of course.

Read more

Alien Blitz: total destruction, random levels

Total destruction

Total destruction mod is back! I removed it as I was having some issues with 3d voxels and total destruction, but they are solved now.

Total destruction is a game mod that allows almost all blocks/walls to be destroyed, it can be activated only after completing the game, and you won’t get any xp/money/… when using it (like other mods). It can only be activated after completing the game.

Like other game mods it will only be available on PC.

capture_2015-02-13_11-10-14_0911_Alien_Blitz_

For “historical” reasons some blocks are not fully considered blocks in the engine, and they can not be destroyed.

Most of the time it makes the map unplayable, and always break gameplay, but it’s fun to try once in a while.

 

Random levels

I wanted to try to test some random levels generation for quite some time, so I am currently trying a few things.

Basically a lot of level generator are dungeon generator, usually for D&D or other rpg. They work fine for this kind of game, but couldn’t work on Alien Blitz. These level generators usually generate rooms then corridors, and in the end try to get a workflow working with that.
It’s not what I want for Alien Blitz, in Alien Blitz I want a workflow to be generated first, then rooms and corridors.

Basically here is a test diagram I made quickly

AB - level generation

There are corridors that need something to be passed (keys, switches, monster killed,…) and rooms with multiple links (labyrinth). This diagram is simplified, but the idea is that the red key door could be anywhere in the “no condition” zone, not especially in the last room.

And difficulty of the rooms (green=easy, blue=medium, red=difficult) will be used to determine which monsters to place and such.

It’s interesting to try to come up with an algorithm, I don’t know if it will make anything good or if I will use it, but testing that is fun 🙂

At the moment I can generate a very basic diagram, empty rooms and corridors. Most of the work that had to be done was to generate a level that the game could load from a simple model, problem is that Alien Blitz has come a long way, and level is a very old code. If I was to redo that now I would just use json thanks to LibGdx.

Here is an example of a workflow diagram (very basic, needs improvements)

AB -test

(draw.io diagram, very nice to work with as it can import/export a simple xml format to work with in any language)

And the resulting “level”

capture_2015-02-16_11-29-22_0160_Level_editor_

The player starts on the bottom right, some rooms are not connected as the algorithm could not find a way to create a corridor, so it’s supposed to use teleporters.
And there will also be some small rooms dynamically created in the long corridors.

Of course it’s just a really basic start of a prototype as of now, but it’s interesting for me.

Read more

Alien Blitz: animated lava/poison, video memory usage, pick up effect, flawless victory achievement

Animated lava/poison

I’m really improving my shader skills lately, it’s quite enjoyable 🙂

Just a small addition with animated lava & poison they will get a brightness boost for a few milliseconds every now and then.

capture_2015-02-11_21-34-49_0211_Alien_Blitz_ capture_2015-02-11_21-34-50_0959_Alien_Blitz_

It doesn’t add that much, but it’s nice.

I tried something similar with water but brightness boost isn’t nice, I can easily move the texture, but problem is that I can’t really set a moving direction, so it doesn’t feel nice (water can move away from the coast).

 

Video memory usage

After a full play through I noticed the video memory usage was a bit high, it was using 350mb video memory instead of something around 100-150mb. Of course it’s not that high considering most video cards have more than 512mb and people won’t usually do full play through but still it’s not good.

The “memory leak” was not easy to spot, my usual tests (launching all maps individually, killing all monsters and activating everything each time) did not really help. There was indeed something like 50mb too much used memory, but in this case it was so small that it could have been anything (cache, other application,…).

So instead of going through all the code I preferred checking if textures were correctly disposed after finalize, basically:

  • create a com.badlogic.gdx.graphics package in your project
  • copy the Texture class from libgdx to this package. It will override default Texture
  • Add a finalize() method that checks whether glHandle is equal to zero or not, if it is not it means the texture was not disposed before finalize
  • (you could also change Libgdx source and recompile it, but I think this method is a lot easier)

And there were indeed a few instances where textures where not disposed properly:

  • A texture used for drawing rectangles (<1kb, too small to do anything bad)
  • A texture used by a few sprites (same)
  • The texture used for “floating messages” (hit points, power up name display,…), this was the real culprit, this is a very small texture but a lot of them are created during a normal playthrough (my tests generate a few, but a lot less than a normal player playing a lot)

All these points have been corrected, and there doesn’t seem to be any video memory leak now.

 

Pick up effect

The old pick up effect when picking up ammo, keys and such as been removed, it was using the 2d version of sprites which was kinda weird.

Instead it is now replaced with a nicer effect, the sprite will just slowly fade and also will be sent a bit into the air before falling into the void.

capture_2015-02-12_15-45-10_0261_Alien_Blitz_

 

Flawless victory achievement

My bad, the flawless victories achievements could only be obtained with 100% kill, this has been corrected, you just need to complete a level without taking any damage, even with 0% kill.

Read more

Alien Blitz: end screen, small graphical changes, option screen, camera

End screen

I’ve redesigned the end screen:

capture_2015-02-10_13-36-59_0580_Alien_Blitz_

There are more information, but I think it’s easier to read now, there are checkboxes indicating if the objective has been met. When completing the level the checkboxes will be checked one after another, with a sound to indicate if the objective is met or not.

Completed bonuses are now visible, they were still taken into account before but not displayed, I’ve also added new bonus, there are now 7 bonuses:

  • 100% kill
  • 100% secrets
  • 100% boxes
  • All 100% completed
  • No damage taken
  • No checkpoint activated
  • Pacifist (no damage to a monster by one of the player weapon)

It’s theoretically possible to get all 7 bonuses, but it’s quite hard (mixing pacifist and 100% kill means all monsters must be killed by infighting, or indirect kills such as barrels or falling into lava/poison)

When a mine is captured it will now be displayed (it was just hidden before, but they were still generating money).

 

Small graphical changes

Smooth black borders on the edge of the maps

capture_2015-02-10_13-44-52_0711_Alien_Blitz_

It’s a bit better for immersion.

Fire/poison/death effect

They are now handled by a shader, previously it was a texture applied on top of the screen, but it was a bit laggy.

End of level effect

When completing a level the screen will slowly fade to black.

 

Option screen

Option screen now has tabs to group different options.

capture_2015-02-10_13-48-20_0586_Alien_Blitz_

And the quality settings have been added

capture_2015-02-10_13-48-26_0126_Alien_Blitz_

 

Camera

Camera will less change its zoom settings, it was a bit harsh sometimes when moving in rooms with pillars as it was continuously adapting zoom. Now the zoom setting will be more stable and only change when really needed.

Read more

Alien Blitz: camera, borders, limited vision, hit vision, performance

Camera

Camera is now farther away on PC, usually on PC screens are bigger than phones, so it’s best to have a bigger field of view. So on PC the camera will always be more zoomed out than mobile (= we can see farther away).

 

Borders

Borders around sprites are a bit bigger, they were 1px before but because of MSAA they were sometimes disappearing behind the sprite itself. So now they are 2px and never disappear.

 

Limited vision

Continuing work on the limited vision..

Sprites are now impacted by vision (you can’t see sprites that are not in the field of view), but the health bar are still visible, so I just make them invisible after a few seconds now.

The terrain used for the vision is really modified now, at first I was using the real one:

capture_2015-02-06_19-11-27_0318_Alien_Blitz_

Problem is it doesn’t look so good, even if player should not be able to see what is behind those small grass it doesn’t feel nice.

capture_2015-02-06_19-11-53_0426_Alien_Blitz_

So now when checking vision there is virtually no ground, only walls big enough can block the view.

It’s really nice to play with limited vision, it’s crazy how quickly we can loose track of where we are and what rooms we have already visited are like. Of course in my case I have already completed levels 100+ times, so I kinda remember them.
And opening a door to an open area after being in small rooms for minutes feel nice.

 

Hit vision

While playing with limited vision I decided to try to change the far value of the camera if the player has been hit recently.

Minimum far + fire damage:

capture_2015-02-07_12-05-03_0983_Alien_Blitz_

Normal far:

capture_2015-02-07_11-50-54_0460_Alien_Blitz_

The minimum value can only be reached if the player looses half his life (after armor reduction) in a few seconds, so only after being hit a lot. The far slowly goes back to normal after a few seconds or after taking a medkit.

This combined with red borders is very stressful, I like that 🙂

 

Performance

Performance wise this new vision is ok:

  • Laptop, integrated card, MSAA 2x, 512px depth map : 50-60FPS (95% of the time it’s 60FPS, just a few drops barely noticeable sometimes)
  • Laptop, integrated card, MSAA disabled, 512px depth map : 60+ FPS
  • Laptop, integrated card, MSAA 2x, 256px depth map : 60+ FPS
  • Laptop, nvidia GTX 660M, MSAA 2x, 512px depth map : 60+FPS
  • Computer, nvidia GTX 280, MSAA 2x, 512px depth map : 60+FPS
  • EeePC, nvidia ion, MSAA disabled, 256px depth map : 20-30FPS
  • EeePC, nvidia ion, low quality : 50-60FPS

These tests with the integrated card are just to simulate a low end PC, in this case I think players will understand they could just lower quality a bit. And again, playing in high quality is ok, I would not have noticed the frame drop if FPS wasn’t displayed on screen.

Maybe I’ll just add a new quality slide : lowest / low / medium / high / highest. And an advanced option where you can individually select quality options (MSAA, depth map, lighting quality,…)

  • Lowest : no MSAA, no dynamic lights, no shadow mapping,… basically it’s the mobile version
  • Low : no MSAA, but full lights, shadow mapping with 256px depth map
  • Medium : same as low + MSAA 2x
  • High (default) : same as medium + 512px depth map
  • Highest : same as high + MSAA 4x + 1024px depth map

On the EeePC of course it’s still not playable, but that’s what the low quality option is for (in lowest quality it’s fine)

Read more

Alien blitz: gap on the mesh, limited view

Gap on the mesh

I came around some problems with previous optimizations:

capture_2015-02-05_12-08-42_0328_Alien_Blitz_

You can see some black dot on the upper-left of the room. Those appear randomly when camera moves. When switching to the new terrain mesh it appears there are some very small gaps between the faces, and they get accentuated when rendering shadows.

I can’t find why those gaps exist, they aren’t there when using the full/complex mesh. I checked the mesh but all points are correctly connected, and there’s no precision problems (I even cast everything to int, and those ints are too small to come across float precision problems).

And furthermore they don’t appear on vertex but on faces edge, on this screenshot you can see the black dot is in a middle of a segment between two faces:

capture_2015-02-05_12-47-42_0261_Alien_Blitz_

I think it’s some sort of precision problem when the GPU tries to connect the faces after applying camera transformations. With the complex mesh this problem does not appear as faces are a lot smaller.

So I checked if this new mesh was really useful, and it appears it just improves performance by something like less than 5%… It’s crazy as it reduce vertex count by a very huge factor (around 100x-200x)…
Another crazy stuff is that when removing duplicated vertex in the complex mesh it reduces vertex count by a small factor (2x-3x) but improves performance by around 25%… There’s really something I don’t quite get happening here.

And correcting this gap “manually” (basically by removing filtering on the shadow map + checking in the final render if value is too different + applying PCF on final render) might just kill the small performance gain.

So I don’t know what to think, maybe I’ll drop this new mesh for the moment…

 

Limited view

Currently I don’t think Alien Blitz needs shadow mapping, I’m mainly trying that for a next engine, and if it could fit on Alien Blitz then why not. But it’s too much work in my opinion, and not really needed.

But another thing that shadow mapping could be good for is to limit field of view. From the beginning this game was supposed to have a limited view, so that only what the mecha can see should be visible, here’s a very old screenshot of this concept:

Capture du 2012-05-21 14:04:52

But in isometric if was way too costly. And in 2d/3d I just added a fog above terrain.

But now with shadow mapping I can just put a camera on the mecha to know what it can see.

First I tried with a directional light:

capture_2015-02-06_16-22-56_0708_Alien_Blitz_

Problem is the mecha moves way too much (avoiding bullets, or just walking through the level) so it makes it horrible.

So I tried with a point light:

capture_2015-02-06_17-39-02_0334_Alien_Blitz_

We loose some realism as the mecha can now see behind himself, but it’s way better.

You can still see sprites as shadow is not applied on them yet, but it seems quite good, it needs more testing but it seems ok performance wise and from a game design point of view it should be good too.

What is sure is that if it is included in Alien Blitz it will be a PC only feature.

Read more

Alien Blitz: shadows, borders, cache, optimizations, performance, PC demo, Android

Shadows

I had the idea to remove terrain from shadow calculation, sadly it can not work as terrain needs to be rendered in order to stop shadow from propagating through walls. So now terrain is rendered in depth map calculations, but terrain itself won’t cast shadows.

So visually the result is as expected, but it takes a lot longer to render lights (terrain has a very high voxel/vertices count, and is quite hard to optimize without a lot of work on the engine).

Old shadows (circle on the ground) are back, but will be displayed only when jumping (if shadow mapping is activated). It helps player guess where his mecha is when mid-air.

capture_2015-02-04_12-54-01_0850_Alien_Blitz_

Sun won’t cast shadow, it is too costly (sun is a bit tricky in Alien Blitz, it’s a lot of lights that have an almost infinite far, so a very big scene needs to be rendered for each “sun” on the map, they were not created with 3d in mind, hence this trick…). Thankfully there aren’t that many suns in maps, so it doesn’t really matter.

 

Borders

Edge on terrain has been removed, it doesn’t suit very well the graphical style of the game. But borders on sprites have been improved, only pickable items, player & monsters have a border now. I tried giving them different colors but it wasn’t looking nice.

The good thing is that these borders are visible when behind a wall, I like that.

capture_2015-02-04_12-53-16_0326_Alien_Blitz_

 

Cache

Adding cache means whenever a sprite moves it must check the surrounding lights and force them to update. Same happen when the terrain is modified (door open or wall destroyed)

Problem is that lights still need lots of updates, there are always things moving around (monsters, turning sprites, player,…) and the game was never build with shadow mapping in mind, so there are LOTS of lights in the levels, way too much for forward rendering in my opinion. Combine that with the high vertex count and you have a hell of a problem.

 

Optimizations

So now time for some optimizations, first thing that can easily be done is to decrease vertex count (not faces, just vertex) by removing useless/duplicate ones. I didn’t think it would boost performance as the face count is the same, but it does increase shadow mapping speed by ~20% which is nice. It might also slightly improve performance on mobile, but not that much.

Another thing that can be optimized is the terrain mesh sent for shadow mapping, basically terrain is currently a big mesh containing lighting information, texture positions, normals,…. With shadow mapping we don’t care about all these stuffs, we just need to know the global shape of the terrain… and so we can send a really simplified version of the terrain to the rendering passes.

Given this terrain:

capture_2015-02-04_19-51-20_0339_Alien_Blitz_

If we apply some sort of wireframe (it’s not real wireframe, just some basic render I used to check voxels) we can see the voxels on the terrain:

capture_2015-02-04_19-50-33_0710_Alien_Blitz_

The idea is to optimize the terrain in order to get that:

capture_2015-02-04_19-53-05_0438_Alien_Blitz_

Of course all texture/lighting/… information are lost in the process, so this can only be used for internal rendering (depth maps,…), but it works fine (what you can still see now are the chunks, the biggest partition of the terrain).

Problem is that it increases loading time, it’s still acceptable though  (5 seconds in worst case)

 

Cache and performance

Some performance tests (map with lots of lights, min-max FPS while playing):

  • Laptop, Intel integrated graphics: 30-120 FPS
  • Laptop, Nvidia card (GTX 660M): 50-120 FPS
  • Computer, Nvidia card (GTX 280): 100-200 FPS
  • EeePC, Nvidia card (ION): 5-30 FPS

Again, it’s crazy how my 6 years old computer is better than my 2 years old “gaming” laptop… but the GTX 280 was an high end graphical card if I remember correctly. I have included the EeePC in the test for fun, the game can run on it without shadows, but with shadows it’s just impossible.

In conclusion results are not too bad, problem is that when there are lots of light updates we can sense that the game slows down on my laptop (because FPS is averaged, it’s the number of frames in one second, so there could be for example 49 frames in 0.5 seconds, and 1 frame in the next 0.5 second, the average in one second is 50FPS, but there have been too many frame lost), especially when vsync is turned on.

I will continue trying to optimize that, depending on results I will decide whether or not shadow mapping will be enabled by default. Given current results it should be disabled by default, but selectable in the options.

 

PC Demo

I will release a PC demo soon, for testing and to send to some websites that might be interested. It will just include a few levels (I don’t know, 4 or 5), enough to have an idea of what the game is (not the starting levels as they don’t have enough content, it will start with a fixed mid-game save that will be reverted every time the game is restarted)

I will also work on this **** press release that I keep reporting, and send it to some websites.

 

Android

I will maybe also release a new mobile version soon, I think it will include sprite borders. Depending on performances it might be disabled by default though.

Read more

Alien Blitz: shadow mapping, edge & border

Shadow mapping

I’ve cleaned up the code for shadow mapping, it was really a mess before that.

And I also made lots of tests, trying lots of different ways to render shadows, soften them,… I’ve finally concluded that I really like current (mobile) lighting technique, it’s colorful and very soft, problem is that shadows only apply to terrain.
So I’ve decided to try and generate shadows just for sprites and I think it could be ok.

Performance are a lot higher (still not using a cache system, lights are recalculated each frame) so I also tried enabling shadows for particles (bullets)

capture_2015-02-03_19-58-47_0593_Alien_Blitz_

I am not sure I will keep shadows on particles (too much updates), but definitely I think I will add shadows on sprites, it’s a lot nicer. These shadows will only be available on PC, mobile devices can’t really handle them.

I’ve also virtually set the lights higher to the ground, to get smaller shadows.

 

Edge & border

I’ve also made some more tests on edges, it gave me some good ideas for some cool low poly rendering, but it would be for another game.

First adding borders around sprites

capture_2015-02-03_20-22-32_0798_Alien_Blitz_

And mixing that with edge on terrain

capture_2015-02-03_20-24-48_0458_Alien_Blitz_

I definitely like borders around sprites, it would of course require some work (no borders for decoration sprites, maybe different colors for monsters or power ups,…). Not sure about the terrain stuff, maybe it needs some more work first.

To add borders around sprites I have just added a new render phase that just renders some basic color where sprites are supposed to be, and I use this texture in the final render to add borders.

screenshot_bordermap_992

I have some more stuff to play with 🙂

Read more

Alien Blitz: edge detection

I was just wondering if edge detection could render something nice for Alien Blitz, and now that I understand better how the multi pass work I can easily add an edge detection pass.

(screenshots are: soft edge, stronger edge, no edge; only terrain edge is displayed atm)

capture_2015-02-02_12-54-10_0209_Alien_Blitz_ capture_2015-02-02_12-54-36_0000_Alien_Blitz_ capture_2015-02-02_12-54-57_0619_Alien_Blitz_

(I also need to correct shadows, this shader is a bit old, I should use the one from the tutorial)

Basically this new pass renders the scene saving only normals (rgb) and depth (alpha) information, then in the final render I check if there is a significant difference in these informations.

screenshot41

 

Read more