Friday Facts #42 - Shadow troubles

Posted by Tomas on 2014-07-11


magical edition of Friday Facts doesn't bring The Answer to the Ultimate Question of Life, the Universe, and Everything, but it does bring news from our studio and development efforts. Kovarex came back from Greece for couple of days before going on another vacation - a small Go camp in Czech republic. Me and Albert we took the opportunity of beatiful weather on Sunday and did a trip to Hazmburk castle ruins not far from Prague. On our way back we stopped at my parents' summer house for relax and loads of home grown fruits :D

Oddly enough the following next two paragraphs have the same titles as in the last edition of Friday Facts :)


The experimental 0.10.3 has been released today alongside with this post. We have spent about 40 % of our time doing the bugfixing with multiplayer works taking the rest. As a result there are still some bugs we would like to fix before making a stable release. Sometimes it really feels like a futile effort with new bugs discovered (and reported) every release. But we take pride in having the game as stable as possible and thus delivering hassle free experience to our players (not always we succeed :)).

One small feature that made it to the 0.10.3 is having a direct input field for some guis which have had only slider until now (for instance smart inserter condition). It turned out to be quite a tricky design problem with couple of solutions suggested on our forums. For now the slider stays and the manual input is a complement to it. We will see how it works and maybe revisit this in the future (the slider could work for full stacks for instance while the input for precise amount).

Multiplayer progress

Regarding the multiplayer, we had a lot of headaches with our clients synchronization logic. But now we are finally in the state when a client instance connects to the serving instance, synchronizes and then properly downloads and starts the map. It is funny how such a simple thing, as seeing two Factorio instances startup, hold for a while, spit out tons of log lines and then display the identical map, can be rewarding :)

The map download turned out to be more tricky than we thought (surprise, surprise). Also because we need to adaptively adjust the upload bitrate - we want it to be as high as possible without causing any congestion. This way the other client doesn't have to wait for the map download too long. At the moment we are using a simple algorithm called AIMD. Basically we keep increasing the amount of packets linearly when things go well and decrease it exponentially when packets get stuck. With a bit of hand tuning we managed to get 1MBps on localhost which is far from spectacular but it is a good base for further work.

Next target: actual coordinated playing.


When working on the graphics for the new gate object we have bumped again to the old problem - the shadows. At the moment the rendered object and its shadow form a single sprite. This is simple to do and to handle in the engine. But it brings quite a few problems (checkout the schema picture below):

  • There are sometimes "double shadow" glitches (for instance with walls)
  • Buildings rendered "over" the shadow make the shadow disappear (because the shadow is part of the another building sprite).
  • We cannot use "flipping" for otherwise symmetrical objects. Instead of rendering a spritesheet for let's say 8 directions for the player, we can have just 5 directions and the rest get by flipping. We do this at the moment anyway and pretend that it is ok to have wrong shadow :)
So we decided to make a mechanism when shadow will be rendered separately for certain objects. In the beginning this will be for walls, gates and the player (profits heavily from the flip optimization). If this goes well we will later on do this for enemy units and trains as well. Both of these will save quite some video memory.

If you have any insights or comments, share them with us at our forums.