More sounds

Was working on more sounds today and made this Sawmill video:

There are 8 separate saw sounds that get uniquely combined each time.

Posted in Live progress, Video | 2 Comments

Sounds

I have a perfectionist bit in me that always tends to halt whatever is being made in favor of “making it perfect”. All in all “making it perfect” is a great idea, but it very often means that nothing is being made at all. So yesterday I said “Enough!” and went on a SFX spree – picking whatever free sounds are good enough for the game. It was not easy – I was still heavily nitpicking and tweaking sounds. In the end I put whole 4,5 (four and a half) most frequently used sounds (placeholders, cos I they don’t fit) into Knights Province. Why going for placeholders rather than fitting sound? – because placeholders are better than nothing, which is usually the case when “making it perfect” is involved.

TL;DR – Knights Province Alpha 7 is going to be less of a “silence room”.

Bonus chat – name 4,5 sounds that I have added. They are ones of the most frequently used sounds in the game, missing in Alpha 6.

Posted in Live progress | 7 Comments

More dirt and grass and sand

textures

Posted in Sidenotes | 2 Comments

Parallelization

With more content in the game (units, houses, terrain textures) the game loading got noticeably slower. Being able to launch the game and check the changes as quickly as possible is critical for early development. It disrupts the workflow a lot when I need to restart the game to check out changes made in code, dozen of times in a row. Optimizations had to be applied.

loading

There are hundreds of places that could be optimized in Alpha version of a game. Many of those optimizations are going to improve the performance just a bit, many will take a lot of time and complicate the code. The aim is to find the “best” optimization – one that takes least time to implement, desirably simplifies the code (yes, that is possible) and brings best performance improvement.

Proper way of dealing with this case is to profile the game. But since we talking only about the initial loading time, we can get with a much simpler approach – logging. For that the game is instrumented with functions to write each loading step timestamp into log.

  • Cursors resources loaded – timestamp.
  • Fonts resources loaded – timestamp.
  • Houses resources loaded – timestamp.
  • you get the idea

It revealed that on average full game loading from exe launch to playable mission takes 13.4 seconds. 8 seconds of which are spent loading PNG textures for units, houses and terrain (total of 95 images with loading time raging from 5 to 1800 msec). This is the target now.

I have little control over PNG library that loads the textures, so switching to another one could be a thing top try, but PNGs are known to be slow, so I did not spend time on that. There are several viable options still:

  1. Change textures format to one that does not require lengthy unpacking and could be loaded on to GPU quicker.
  2. PNG takes a lot of time to unpack. It’s advantageous to use all available CPU cores and parallelize loading to run in several threads.
  3. Make a special build with much smaller textures.

First option is best for release version of the game. It takes time to convert textures and they can not be changed easily after that. Loading times are best.

Third option is obviously worst alternative, since it breaks the game art. It could be used for simulation runs probably (e.g. runs where AI gets tested).

I chose second option because it does not make working with textures any different that it is now. Also it is an interesting task (multithreading) that I have little experience with. It will be possible to apply to other tasks (mainly keeping models loading in mind, but other applications are viable too).

Keeping generic requirements in mind (that designed class should work for textures, models and other yet unknown applications with minimal changes) I came to the following simple layout:

  • The game is loading resources by domain (houses, units, tiles, etc) instead of being split into types (models, textures, animations, etc.). Textures get collected from each step into a list as the game parts are loaded.
  • Once it’s done, there is a flag choosing between old approach (load everything in the main thread one-by-one, or a new multi-threaded way). This way I can safely implement new algorithm while always being able to switch back to the old one if anything goes wrong or needs checking. Also compare loading times precisely.
  • Then there is a worker thread. A thread that requests a piece of work by reporting to its owner, if there’s no work – it destroys itself. One worker loads one texture at a time.
  • And there is a pool thread. A thread that keeps a list of tasks to do and workers to take them. Pool thread gets CPU cores count from OS and makes this many worker threads.

Why making the pool in a separate thread? It allows to run it in the background, for example reloading textures on-the-fly without freezing the game (not tested yet).

Once implemented, this cut down textures loading time from 8 sec down to 2.6 sec. Quite nice if you ask me. But of course I plan to add more and more models and textures and other kinds of content, worsening loading times with that. So at some point in time I will have to repeat the process and find another “best” optimization 🙂

Posted in How things work | 2 Comments

Grass is coming

First look at terrain textures in game:

2016-04 Grass

2016-04 Grass

Posted in Sidenotes | 7 Comments

Terrain textures

Past two weeks I have been experimenting with terrain textures for Alpha 7.

I have a special tool to preview just one terrain tile – it makes experimenting and tweaking much simpler and faster. For example I have taken 4 distinct textures (Shown textures are placeholders and used for testing purposes. They belong to respective authors.).

This is how trivial blending would look like – gradual change between textures:

2016-03-20 terrain blending 1

Plain gradient blending

Knights Province can do better than that. Lets add weights, so that each tiles corner could be made smaller or bigger, giving more artistic freedom to mapmaker:

2016-03-20 terrain blending 2

Weighted gradient blending

Those transitions are functional – terrain areas can be changed, but they have another problem – they look not very inspiring. So let’s make something fancier – I know just the right tech:

2016-03-20 terrain blending 4

Custom blending texture

And now boring transitions become detailed:

2016-03-20 terrain blending 5

Resulting blend

Now I’m busy adding this tech into existing terrain render pipe and optimizing render performance.

Posted in How things work, Live progress | 2 Comments

Town Tutorial challenge

Thimo has posted a challenge on the forum – who can beat his time in Town Tutorial: topic

STZbRjY

Posted in Events | 10 Comments

Alpha 6.3 bugfixes

Thank you for reporting bugs!

alpha-6.3

Following bugs have been fixed:

  • Crash on startup caused by terrain shaders (“const vec2 poissonDisk[16] = vec2[](“)
  • Fixed Cidermakers and Brewery offsets
  • Crash on ending missions with captured wagons
  • Sorting SP maps by title and locations is the other way round
  • Location for Ciders on Town Tutorial did not match new house shape
  • Several big memory leaks (r3575)

Download: Knights Province Alpha 6.3

Posted in Downloads, News | 18 Comments

Alpha 6.2 bugfixes

List of bugfixes in Alpha 6.2:

  • Crash when placing Fishermans near right/bottom edge of the map
  • Crash when entering selected wagon into Camp
  • Selecting Wagon in MapEd caused a crash
  • Builders won’t repair damaged houses
  • Fighting Back mission victory condition did not work
  • Small buttons were missing arrows on them

Download Alpha 6.3:  Knights Province Alpha 6.3
Old download Alpha 6.2: [Download not found]

Posted in Downloads, News | 10 Comments

Alpha 6 is out – shadows and skirmish!

I’m happy to announce that Alpha 6 is out!

Alpha 6 features improvements both in graphics and gameplay. Along with usual expansion of graphics content, the game has got quality improvement – dynamic shadows. Gameplay got improved with introduction of skirmish mode.

2016-03-10-skirmish-setup

Skirmish setup

A few words about skirmish – this is single-player mode against AI, much alike multiplayer games where everyone starts in the same conditions. Everyone’s goal is to defeat enemies.

2016-03-10 crossing

Crossing – 4-player skirmish map

New features in Alpha 6:

  • Shadows
  • Skirmish mode
  • New and updated skirmish maps – Crossing, Rivals, Volcano Island
  • New unit models (Brewer, Butcher, Breeder, Smith, Metallurg, Miner)
  • New unit animations (Woodcutter, Fisherman, Farmer, Militia, Swordsman)
  • Victory and Defeat graphics
  • Warriors icons for Fort/Barracks
  • Repaired and improved AI functions for skirmish
  • Reworked main menu navigation
  • Improved Town Tutorial map
  • Nerfed Fighting Back map
  • Skirmish map setup is simplified with a special button in MapEd
  • Adjoined SP/MP results screens
  • Show mining ranges for houses
  • Allowed to block units in missions
  • And as always – a bunch of smaller improvements and minor bugfixes.

Along with new features come new bugs, so if you encounter one – please let me know!

Download Alpha 6.3: Knights Province Alpha 6.3
Old download for Alpha 6.2: [Download not found]
Old download for Alpha 6.1: [Download not found]
Old download for Alpha 6: Knights Province Alpha 6

Posted in Downloads, News | 4 Comments