1. Factorio
  2. News

Factorio News

Friday Facts #322 - New Particle system

Read this post on our website

Release plans (Klonan)

This week we released version 0.17.79, and marked it stable. Internally we have been calling this 'Stable 3', and the main feature was the new tooltips we showed in FFF-318.

There is one constraint we put on ourselves when we started this more swift feature release schedule: We want to avoid breaking mods. This is easy enough in principle, don't start renaming things, don't remove API features, etc. However as we develop further, there are certain features and improvements that we can't realistically do in a way that won't break mods, such as the new Character GUI (FFF-289) and color correction (FFF-320).

It is for this reason that we are going to accumulate some of these mod breaking changes, and release them all at once. Since it will definitely be breaking mods, we will bump the major version number, so it will be 0.18.0.

We have already internally started merging in these 0.18 features into our master branch, so we will not be doing any more 0.17 releases (unless something absolutely catastrophic is discovered).

The problem with particles (Klonan)

Particles have been in the game for as long as anyone can remember, and they are pretty simple all things considered. They are a small mostly decorative entity, that we use to add a bit of visual gratuity to the death and dying of bugs and machines.

For instance, Biters are full of blood, so when they die, they make quite a splash. Lets try to count how many particles we spawn in a typical dying explosion.

https://cdn.factorio.com/assets/img/blog/fff-322-biter-die.mp4
In this clip, the blood particle sprite has been replaced with a debug visualisation, to make counting easier

So it's quite a few. The Biter spawned 427 particles, and the Spawner 749. Well they don't persist very long, and they're only decorative, so it's all fine right?

One key word I would like to highlight in the previous description, is that they are an entity. When kovarex and slpwnd started making Factorio, they made a robust system for managing game objects and their interactions - the entity system - and everything that has a physical representation in the game world was built on top of this system. As the game grew bigger, it became obvious, the entity system is too heavy weight for some things, and we can get better performance by creating more specialized systems. This led to removing items on belts from the entity system in 0.12, and doing the same for smoke and terrain decoratives in later versions. Despite most other games or game engines having very efficient particle systems from the early stages of development, particles in Factorio are still piggybacking off the entity system in 0.17.

This means that particles are registered on the game surface in the same generic way as everything else. This also means, that they are iterated through when doing entity searches. So what sort of engine actions do entity searches?
  • Area trigger effects - such as grenade, flamethrower stream damage, atomic bomb, poison capsule.
  • Pathfinding - To check if a path can traverse a given tile.
  • Movement collision checks - such as Characters, Units, Projectiles.
  • And many others...


As you can imagine, having thousands of extra entities to iterate through every tick, can start slowing down the simulation. The worst case these days is defending your walls with flamethrowers. In the image below, all entities are highlighted with a debug visualization.



If you lost count, this scene contains 15,689 entities

Flamethrowers vs Biters are pretty much the perfect example of the problem:
  • The biters need to check every tick when they move if they collide with anything.
  • When the flamethrower streams land, they do splash damage, which is an area trigger effect.
  • The flamethrower stream also creates the fire on the ground, which does a collision check.
  • Every 10 ticks, the Fire on the ground do damage with an area trigger effect.
  • The flamethrowers kill biters very efficiently, so a lot of particles spawn in a very short amount of time.
This combination leads to some significant slowdowns later in the game when big groups come knocking. Also, since we improved the pathfinding, the problem is even worse in the latest versions of 0.17.

So how do we solve it?
Particle Optimization - Technical (Rseding)

When Posila first talked to me about doing a re-work of how Particles function in the game I had a lot of ideas. Not all of them worked out in the end but they sounded nice:
  • They wouldn't be entities.
  • They would work like smoke does (stored in contiguous blocks of memory).
  • They wouldn't need to be updated each tick if they didn't effect the game state.


In the end I found that it wasn't worth the added complexity to make #3 work.

The process
Particles needed to not be entities. Something being an entity has a lot of memory and performance overhead that particles just didn't need. Unfortunately when I implemented artillery I made the manual-targeting marker a particle. The reasons why don't matter any more, but it meant I had to add migrations to handle that and then migrations to handle removing all of the entity particles.

I stripped out all of the extra data/logic from particles that they no longer needed - reducing the size of each particle in memory from 224 bytes to 64 bytes. As a side effect of making them not entities it also reduces the amount of information that has to be saved in the save file. However, in most cases particles don't exist long enough to end up in the save file so that didn't really matter.

I needed some place to store/work with the particles runtime as they are created, exist for some short amount of time, and go away. Most stuff in the game ends up being stored on a given chunk (a 32x32 area of the world). In the case of particles I didn't care at all about any of the other stuff on a given chunk so I didn't want to stick them there. Instead, I made a separate thing that functions very closely to chunks and called it "particle chunk". The key differences being: they only exist when there are particles to update on them and the only data they hold are particles. That meant when the game needs to go over each particle to update them, all it has to do is go over all of the "particle chunks" that exist and run update. Additionally since I had full control of these new particle chunks I can recycle them in memory as needed to avoid spending extra time allocating and de-allocating memory as particles come and go.

The end result is a nice performance boost, reduced memory usage, and simplification of the logic around how particles work. A simple unscientific test we performed was nuking the same biter base in the old system and the new system, and recording what the max update tick time was.



The circular ring of entities around the edge are the 'Atomic bomb wave' projectiles.

Old system:
  • Max Entity update = 7ms.
  • Entity count (Excluding projectiles) = 7769


New system:
  • Max Entity update = 2.4ms.
  • Max Particle update = 1.7ms
  • Entity count (Excluding projectiles) = 786


This is not very scientific or highly controlled, but just to give an idea of the scale of the improvement. A 10x reduction in the number of created entities, and about a 40% reduction in max update time. Having the new optimized particle system also means the GFX team can go a bit more crazy with particle effects in the future...

As always, let us know what you think on our forum.

Version 0.17.79 released

Bugfixes


  • Fixed that the infinity pipe mode could sometimes reset when changing other infinity pipe settings. more
  • Fixed that electric energy interfaces didn't consume power correctly. more
  • Fixed market GUI not showing price in the tooltips of modifiers. more
  • Fixed market GUI showing empty price property in the tooltips when no price is set.
  • Fixed lights render quality slider in graphics settings missing tooltip. more


You can get experimental releases by selecting the 'experimental' beta branch under Factorio's properties in Steam.

Factorio version 0.17.78

Bugfixes


  • Fixed a desync related to biter pathfinding. more

Friday Facts #321 - Countdown

Read this post on our website.

1.0 date (kovarex)

Hello,
we feel that the Factorio development is taking way too long. The approach "It is done when it is done" was serving us well to deliver a high quality product, but if we continued this way, we would be doing it basically forever. A lot of us don't have any problem working on Factorio for some more time, but the main problem is, that we would like to introduce new features and content instead of just polishing parts that are already present in the game. We also considered, that the game is quite polished now, and if we just pushed the button to release 1.0, it wouldn't be a catastrophe. From our perspective, a lot of things wouldn't be finished, but from the perspective of a new player, the things we are working on now are mainly nitpicks.

With this in mind, we decided to just specify a 1.0 release date publicly, so we have to stick with it. We will just focus on the most important aspects as we approach the date, and we just do whatever we have time to do. Once the 1.0 happens, we can have some rest and after that, we can finally focus on the content and features again.

The date is 25th September 2020.

Version 1.0 does not mean that development on the game will end, or that Factorio is 100% finished. When we have a better idea of what we will be working on after the 1.0 release, we will let you know.

GDS 2019 (Klonan)
Game Developers Session 2019 is happening in a few weeks, Friday 29th and Saturday 30th of November. This year, like last, we are silver sponsors of the event, so you will see our banners around the venue if you attend.

This year we are happy to have two of our team doing talks at the conference:
  • Albert - "Developing the Visual Style of Factorio".
  • Vaclav - "Technical Side of Creating Factorio Graphics".
You can read a bit more about our talks and others on the speakers page.

Other than our two speakers, a lot of the team will be attending the conference, so if you see anybody sporting a Factorio t-shirt, it could be one of us (don't be afraid to come talk to us).

We also took the opportunity to do some updates to our cover art.



The Factorio team must grow (Klonan)

We have been on a bit of a hiring spree lately, trying to fill gaps in the team where we can identify them. We are happy to say, we have continued our team growth, with two new additions to the team.

Ian is a sound designer from the UK, who has moved to Prague quite recently. He will be working with us full-time here in the office, and with the help of Rseding for engine features, will be developing the soundscape of the game as we narrow in on the 1.0 release.

Next up is Allaizn. You might remember a few of our team mentioned him in past Friday Facts, and he is infamous for his experiments with cars on belts. He has had source access to the game for a long time, and in the past has made some good contributions through the program, so he has been able to get up to speed with us very quickly. For now he is reinforcing Posila in the Graphics backend department.

For some more details on our new colleagues and the rest of the team, we have short bios for everyone on our Team page.

As always, let us know what you think on our forum.

Version 0.17.77 released

Changes


  • When a team loses in PvP, all their characters will die.
  • Technology GUI shows saved progress of partially-researched technologies.
Bugfixes


  • Fixed a crash when when loading modded saves that had construction robots working on modded entities.
  • Fixed that 'corpses' and 'dying_explosion' wouldn't be created on the correct force. more
  • Fixed that LuaEntity::get_fuel_inventory() didn't work on burner pumps. more
  • Fixed ammo turret tooltip not showing the damage bonus correctly. more
  • Fixed fluid name and amount not being shown when the tooltip is on the side. more
  • Show how module energy consumption is applied more clearly in the tooltips. more
  • Fixed several issues related to modded reactors set to use electric energy. more
  • Fixed spitters were not able to destroy trees and rocks. more
  • Fixed that shift+click recipes in cheat mode wasn't able to handle recipes that included fluids but still only produced 1 item result. more
  • Fixed a difference in map editor paused vs unpaused game ticking related to enabled/disabled train stops. more
  • Fixed that produce item per hour achievements could not be progressed. more
  • Fixed an issue with reading localised strings in Lua. more
  • Fixed that right clicking to add 1 item to assembling machines had no limit. more
  • Fixed that teleporting players/cars between surfaces would invalidate lua references to them.
  • Fixed a crash with trains that had wheels.direction_count = 0. more
  • Fixed statistics not counting items correctly on large intervals when a large number of items are produced/consumed. more
  • Fixed Beacon ghost tooltip missing some information. more
  • Fixed ghost tooltips not showing correct max energy consumption.
  • Fixed tooltips for tile creating items showing wrong title. more
  • Fixed blueprint strings not saving empty values for some circuit network settings. more
  • Fixed PvP config import would always append the default item and equipment lists. more
  • Fixed that creating infinity chests with logistic_mode set would ignore request filters. more
Scripting


  • Added LuaEntity::command, LuaEntity::distraction_command, LuaUnitGroup::command, and LuaUnitGroup::distraction_command reads.
  • Added LuaUnitGroup::is_script_driven read.
Modding


  • Changed RollingStockPrototype::wheels to be optional.
You can get experimental releases by selecting the 'experimental' beta branch under Factorio's properties in Steam.