Cities: Skylines

Cities: Skylines

Loading Screen Mod
 This topic has been pinned, so it's probably important
thale5  [developer] 27 Aug, 2019 @ 9:12am
Guide for asset creators
Loading Screen Mod speeds up custom asset loading and saves RAM by sharing textures, materials and meshes. This guide describes how asset creators can make the most of this feature.

What is sharing?

Sharing means reusing. The game saves a hash (a unique identifier) with each texture, material and mesh (resources for short). Before loading a resource from disk, LSM checks if its hash is a known one. If yes then the resource is already in memory and there is no need to load and decode it again. Obviously this saves time and memory. The Unity game engine supports shared resources.

How to make sure sharing will work

Identical resource data is required. File names do not matter but file contents must be exactly the same. For materials, in particular, this means that the contained textures must be the same and also other material properties (for example colors) must be exactly the same.

Sharing limitations

Sharing works across almost all boundaries. It works between different asset types, between assets in an asset pack, and between different workshop submissions. Sharing works automatically for identical resources; no special actions are required.

As an example, let's assume Jim published a building asset back in 2016. In 2019, Jane gets permission to reuse a texture from Jim's building in her road asset. Because it is exactly the same texture, sharing will work.

Of course there are some limitations:
  • Sharing does not work for LOD textures. Reloading the texture from disk is not necessary but an in-memory duplicate is created. Curiously, perhaps, sharing DOES work for LOD materials. This is explained below.

  • For textures and materials, the game stores mains and LODs separately, so sharing is not possible across the main-LOD boundary. However, there is no such limitation for meshes.

  • There is no sharing between vanilla prefabs and custom assets. However, sharing across the vanilla-custom boundary does work for LOD materials.

The importance of LOD materials

Asset authors should pay special attention to LOD materials because of how the game is designed.

To speed up rendering, Cities Skylines crams all LOD textures into a large texture called atlas. There is a separate texture atlas for Buildings, Props, Vehicles, and Nets. The maximum size of an atlas is 4096 x 4096. If space runs out, Unity scales down LOD textures until they fit in.

Because of game design, LOD texture sharing is not possible. However, LOD material sharing works and prevents storing the same texture many times in the limited-size atlas. This for sure seems counterintuitive because materials consists of textures but that is how the game works.

For an example, please view the images below. You can see the Net texture atlas in three different scenarios:
  1. Vanilla Net prefabs only.[thale5.github.io]
    No custom assets. The largest vanilla LOD textures are 128 x 128. Atlas size is 2048 x 1024.

  2. Vanilla Net prefabs + one workshop item subscribed.[thale5.github.io]
    Sharing is enabled in Loading Screen Mod. Atlas size is 2048 x 2048.

  3. Vanilla Net prefabs + one workshop item subscribed (the same as above).[thale5.github.io]
    Loading Screen Mod is disabled. Atlas size is 4096 x 4096 (maxed out).

Because of the down-scaling applied in scenario 3, all Net LODs may look blurry.

To avoid scenario 3, keep LOD texture sizes to a minimum and reuse materials as much as possible.

Mesh and texture sizes

I have added an option in Loading Screen Mod to check assets for errors and warnings.

An error is reported if any LOD texture size is not a power of two (16, 32, 64, and so on).
Use power-of-two texture sizes only! Otherwise, sooner or later, you are going to see black textures in-game, thanks to how the above-mentioned LOD texture atlas works.

An error is also reported if an asset has been unsuccessfully edited with a binary file editor in an attempt to avoid duplicate prefab messages. More about duplicates below.

Warnings are issued for:
  • LOD texture is large (512 x 512 or larger).
  • LOD mesh is large (600 triangles or 1000 vertices).

Asset names and the duplicate prefab error

Asset names matter because the game identifies and finds assets by name. It is not possible to have two assets with the same name in-game!

It is important to realize that asset file names do NOT matter at all. Asset name is determined by the Asset Name field in the Save Asset dialog.

The common pitfalls are:
  • Duplicate prefab name errors: this happens when several assets in the same asset pack have the same name. Typically the same trailer name, sub-building name or net pillar or elevation name is used several times in the pack.

  • Asset Name (in the Save Asset dialog) is modified when the asset is updated for the workshop. Because the game finds assets by name, the game considers the updated asset a different one. Users who have placed the asset see it disappear because the old asset name no longer exists.

Many users consider duplicate prefab messages annoying. Authors who create asset packs can easily avoid the messages by making sure that different assets have different names. Loading Screen Mod does NOT issue the message if the identically named assets have identical content (the unmodded game still reports them).

The situation where the identically named assets have different content is harmful and is reported (Consider: two different assets, only one of them can be loaded, which one? The mod or game cannot tell so it must be reported).

Thumbnails and tooltips

The 'Optimize thumbnails' option in Loading Screen Mod speeds up custom asset loading and saves RAM. This feature is not related to resource sharing but is accomplished by storing UI textures more space-efficiently without quality loss. Quite surprisingly, the feature makes a big difference. It is comparable to resource sharing.

The only prerequisite for this feature is that game-default thumbnail and tooltip texture sizes must be used. Some asset authors have used non-standard UI texture sizes. Just stick to the default sizes, which are a bit odd: 109 x 100 for thumbs and 492 x 147 for tooltips.

I write short Guides, too

To support the 'Check assets for errors' feature in Loading Screen Mod, some short Guides are available:

Invalid LOD texture size
Asset naming conclict
Large LOD texture
Large LOD mesh

My old Guide is still current:

Workshop assets must not use private assets
Last edited by thale5; 27 Aug, 2019 @ 11:14pm
< >
Showing 1-15 of 23 comments
leftbehind 27 Aug, 2019 @ 5:45pm 
Great guide!

The only prerequisite for this feature is that game-default thumbnail and tooltip texture sizes must be used. Some asset authors have used non-standard UI texture sizes. Just stick to the default sizes.

What are the default sizes? Would be good to state them so asset authors can check their thumbnails / tooltips.
thale5  [developer] 27 Aug, 2019 @ 11:17pm 
What are the default sizes? Would be good to state them so asset authors can check their thumbnails / tooltips.

Sizes added.
Pewex 28 Aug, 2019 @ 6:36am 
Hi thale5,

Great guide, thank you for writing it. I wanted to ask if you could please clarify what "material" refers to in the guide, thanks.

Kind regards,
PEWEX
thale5  [developer] 28 Aug, 2019 @ 8:31am 
@PEWEX Materials are used to define how 3D objects (like assets) should look like when rendered. In practice, a material consists of a set of textures (diffuse, specular, normal, etc) and possibly some additional properties, like colors.

Another way to look at it: you define a material to group some textures together.

Materials and textures are used in Blender, 3DS Max, Unity, and others.
leftbehind 12 Jan, 2020 @ 5:16pm 
Apparently if the main (non-LOD) mesh has a badly sized (not power of 2) texture it can sometimes cause weird yellow/black effects.

Ronyx69 posted some good info here: https://cslmodding.info/asset/building/#resolution

Also from R69:

i'm not gonna reexplain everything but weird resolutions work fine at first, even on the lod atlas they are packed properly, but it's on the mip maps where they break

when you import stuff in the asset editor, the textures are not part of any atlas, not even for the lod

the yellow stuff is completely explained already lol, it only appears when you have a non-power-of-2 texture which breaks the mip maps and they look like yellow stripes when that happens

Good discord servers for asset creators:

* Ronyx69 discord[discord.gg]
* Terminus
Last edited by leftbehind; 13 Jan, 2020 @ 8:11am
thale5  [developer] 13 Jan, 2020 @ 8:03am 
@aubergine18 I'll add a note about that in my texture size guide. The importance of using power-of-two texture sizes is not yet well known among asset creators.
leftbehind 13 Jan, 2020 @ 8:19am 
A link to wikipedia page would be useful as it has a big list of power of 2:
https://en.wikipedia.org/wiki/Power_of_two#The_0th_through_95th_powers_of_two

Note that R69 found minimum size is 32x32 so anything smaller than 32 should be flagged as invalid.

Also edited previous comment with some extra infos.
Last edited by leftbehind; 13 Jan, 2020 @ 8:19am
thale5  [developer] 20 Jan, 2020 @ 8:22am 
Earlier, I figured out how the LOD atlas is affected. It all depends on how divisible the texture is. Some examples:
- dimension 281 (x or y) breaks the "main" LOD (or mipmap level 0) because 281 is not divisible by two at all
- dimension 282 is better because it is 2 * 141. It breaks mipmap level 1.
- dimension 192 is almost flawless because it is 2^6 * 3. You need to zoom out really far to see the texture problem.

The above is actually logged in output_log.txt if you look carefully.

I'll add the wiki link.
Shindosi 22 May, 2020 @ 9:44pm 
Originally posted by thale5:
@PEWEX Materials are used to define how 3D objects (like assets) should look like when rendered. In practice, a material consists of a set of textures (diffuse, specular, normal, etc) and possibly some additional properties, like colors.

Another way to look at it: you define a material to group some textures together.

Materials and textures are used in Blender, 3DS Max, Unity, and others.

Just wondering if sharing still works if diffuse was only different and other maps (s, n, a) were exactly the same?
Captain Toof 23 May, 2020 @ 2:13am 
Also about sharing: Do I need just exactly same texture/mesh files for everything? And it will work automatically?
Last edited by Captain Toof; 24 May, 2020 @ 2:45pm
Captain Toof 24 May, 2020 @ 2:47pm 
Originally posted by Shindosi:
Just wondering if sharing still works if diffuse was only different and other maps (s, n, a) were exactly the same?
It should share all non-diffuse textures then.
Last edited by Captain Toof; 8 Sep, 2020 @ 2:57am
thale5  [developer] 25 May, 2020 @ 8:13am 
@Shindosi Textures are considered separately so it is OK if diffuse is different and other maps are the same. That is a very common scenario, actually.

If you can make the diffuses identical, too, then sharing is possible at the 'material' level which is even more efficient from a resource sharing and saving viewpoint.

As discussed above, I recommend LOD material sharing, in particular.
thale5  [developer] 25 May, 2020 @ 8:15am 
@Captain Toof Yes, if your textures/materials/meshes are exactly the same, it will work automatically. Hashes are used to detect identical resources.
clus 25 May, 2020 @ 12:28pm 
Hey all. I just wanted to add, that network node lod - textures with a size of 32x16 (w/h) sometimes work (seems a bit random). I've done that multiple times without any issues.
Captain Toof 8 Sep, 2020 @ 2:59am 
About material sharing. Do I need exactly same material names in 3d editor or what? Seems to be I've not very understood it.
Last edited by Captain Toof; 8 Sep, 2020 @ 3:00am
< >
Showing 1-15 of 23 comments
Per page: 1530 50