InfraSpace Modding Tutorial: Adding new assets

This tutorial covers how to add anything that might have a 3D object representation in game. At the time of writing, this category is Buildings.

For adding a new building you can find an example setup in the ISModKitUnity project contained in the ISModKit . If you’re unsure how to use any of the tools or how it’s supposed to be set up, have a look at that and see how it’s done there.

Example Walkthrough on how to make buildings

1. Make a folder for your asset(s)

In order to use your assets, we will use the Unity ISModKit to compile your 3D models, materials, textures and icons into one .isasset file. For this purpose create a folder in the Resources folder in Unity. One folder will be compiled to one .isasset file, no matter what’s in there. This way, you can organize your assets however you like.

image

2. Make a 3D model

Use blender or any other tool to make a 3D model of your idea. For inspiration and templates, you can have a look at Sketchfab or other places where you can get assets. Make sure to not violate any licenses.

Put your model in the Resources/MyBuildingAsset folder. For this example I’ll be using a model of a Salt Mine created by one of Dionic Software’s artists for this very tutorial.

3. Set up materials

Simply create a new Unity material using the Unity Standard Shader or any Shader in the Custom category.
For many people, the Standard Shader workflow is the easiest way of coloring your object, because it’s what they’re used to.

We devs use the “Masked” shader from the Custom shader category to save some space on textures and add a cohesive look to the building materials. It is based on the Standard Shader so if you use that instead, your building will look just as nice. Do note that the Masked shader requires two custom textures:

  • Albedo (RGB)/EmissionMask(A) - This texture contains the albedo, colour texture in the RGB channels and an emission texture in the alpha channel
  • Metallic/Mask/AO/Smoothness (RGBA) - This texture contains the metallic texture in the red, mask texture in the green, ambient occlusion in the blue and the smoothness texture in the alpha channel

We don’t recommend this workflow to newcomers and people used to working with the Standard Material. If you do want to know more about it, let me know.

4. Make Icons

Your buildings will need an icon in order to be visible in the selection panel:

  • yourBuildingNameIcon.png - make sure the image is of square proportion

You can use any tool you want to make these Icons. We provide a setup to ease the creation process. In the SampleScene the camera is set up in a way that it angles close to how our original icons were created. The scene also contains the post processing setup of the in-game scene to make sure your building is lit and presented in a similar way to that of the gameplay representation. To make it even easier, you can use the skybox material from the “Scenes/SampleScene_Profiles” folder. There is a greenscreen skybox that you can just drag and drop onto your scene to make it easier to do the cutout later.

5. Add a drop shadow to the icons

Most icons in InfraSpace have a black drop shadow. For most people it’s easiest to just open GIMP and add a black drop shadow themselves. You can use any image editing software of your choice.

Finally, copy your icon over to your asset folder and check if the settings in Unity are set correctly:

6. Animating your buildings

You can add animations to your buildings that will automatically be configured once you enter the game. This means, if the animation is set up right, it will play only when the building is active and its speed will vary on how productive the building is.

You have to make sure is that your building has an animator on it, and its animation controller has the default animation state set to the animation you want to play. For the salt mine the animation has been created in Unity and is called “idle”. Also don’t forget to set the animation to loop correctly.

7. Compile the .isasset file

First, make sure that all of these necessary files are in your Resources/MyBuildingAsset folder:

  • The 3D objects you want to include
  • Any accompaning materials and textures
  • The icons, properly named

Next, select this folder in the Unity Hierarchy Panel - not in the tree view, but in the big panel.
Right click on the folder and click “Build Asset Bundle”.

In the folder ISModKit/BuiltAssetBundles the tool has now created a MyBuildingAsset.isasset file. This is the compiled version of all the work. Copy this folder in your mod folder and the game automatically has access to all the assets contained in it!

8. Configure your buildings.json file

In order to use any new building in the game, you need to tell InfraSpace about it. This is done by writing json files. In this example, we create a configuration file for our new building. Put a file called buildings.json in your mod folder.

For guidance on how to configure your building, check the example building in the SaltMine example mod contained in the ModKit. Link to online version here.

For more examples, check the game’s own configuration files. They can be exported from the Mods menu.

9. Add a name and description for your object

Check example localization.json file in the SaltMine example mod to find out how to add the necessary text for your object. If you want, you can even support different languages.

10. Add your building to the menu

Your building is ready but it needs to be added to the building menu at the bottom. You can do so by creating a new configuration file for the constructionCategories.json. In here you can select what category you want you building to fall under. At the time of writing the available selections are:

  • Roads
  • Mines
  • Large Mines
  • Refinement
  • Production
  • Science
  • Liquids
  • Miscellaneous
  • Life Support
  • Habitats
  • Services
  • Power

But you can see the up-to-date categories by exporting the json files and checking the constructionCategories.json for yourself. You can create your own constructionCategories.json and add your own building to an already existing category as seen in the SaltMine example mod:

{
	"Mines": [
		"saltMine"
	]
}

10. Test your object in the game!

Now it’s finally time to test your new object in the game! Once the buildings.json and MyBuildingAsset.isasset files are in your mods folder, you can start a new game and have a look in the build menu. Depending on the value set in constructionCategories you can find it in different places in your build menu.

Check if eveything works as intended. If it does, celebrate! Congrats! You made it!

In case anything went wrong…

  • check the console output for any errors
  • check if you kept your naming consistent. If your 3D model is called aSpecificName, you will need to call it aSpecificName in the buildings.json file and icons need to be called aSpecificNameIcon.png for the game to find them.
  • double check this tutorial if you forgot anything
  • check the Example Mod to see if your items are set up the same way
  • ask the community and the devs if they might be able to help you out
1 Like

my building shows white icon and cant place it
i tried compiling original salt mine assets and adding it but still same

white icon: the game can not find the icon sprite

can’t place it: there should be an error in the log

in the log it just says Unknown Resource: gravel

that means you need to add gravel to resources.json

i have added gravel to it and i also added gravel mine to buildings.json
still dosnt work

what does the log say now?

i send you the whole log it says something about it

I am trying to add new assets but have the problem that they are all way too bright. I tried several things and asked google but I am running out of things to try. @Daniel I even downloaded the current version of ISModKit, built the salt mine asset and put it into the game to see if it has the same problem and it does. In the screenshot there’s the salt mine and my own asset. They have very little contrast and are almost pure white, even if I use a very dark material (and different settings for metalness, smoothness etc.).

The salt mine used to work for me in older versions when I first tried this tutorial, and even when using the standard shader instead of the masked one. So I suspect something in your Unity project changed. It seems there are tons of reasons why this can happen, but this is all very difficult to check without access to the IS Unity project. Most likely candidates are light from the skybox, light sources in general or fog settings, things like that.
The models that come with the game itself are working fine.

Any insight what is going wrong?

One more piece of information that came up multiple times during my online research: Changing the Unity version had effects on lighting similar to the one I’m facing (stuff became brighter). I used 2020.3.3f1 to build the asset bundles, same as the ISModKit. Did you happen to change the Unity version of the game maybe so there’s sort of compatibility issue now between the assets of 2020 and the game itself?


It was indeed the Unity version. You are using 2021.03.30f1 for the game. I upgraded my own editor to 2021.03.34f1 (was simpler to download than finding 30f) and the models are starting to work. Now I need to up my modeling skills :rofl:

It’s time to admit that I’m stuck. I spent way too much time debugging this and I’m starting to run out of things to try.

I want to add a new car model.

I got the model to work, the instanced renderer are ok, I got my main texture (albedo color) and mask texture (metallic, smoothness, mask, ambient occlusion). However, I can’t use both textures at the same time. In that case the mask texture only applies the mask channel (which I found out is the blue channel?). The rest of the model is just black. I know that the main texture is fine because if I use the original mask texture from car_aluminium then I can see my main texture shining through in places where there’s no mask color. So I’m guessing that I am using the wrong values for the metallic, smoothness and ambient occlusion channels. I can’t read the original texture (Cars_Substance_Habitat_MetallicSmoothness) because you disabled reading resources, which is understandable. So what values do I need to use for these channels? And what is the assignment of each channel to each function. Above you are writing:

Metallic/Mask/AO/Smoothness (RGBA) - This texture contains the metallic texture in the red, mask texture in the green, ambient occlusion in the blue and the smoothness texture in the alpha channel

But I find mask is in blue, so I guess the car shader uses a different mapping?

Also I thought maybe the texture format has some problems, but I can’t find any problem here either. The texture Cars_Substance_Habitat_MetallicSmoothness is a UnityEngine.Texture2D and has graphics type RGBA_DXT5_SRGB. My own texture has the same type.

This is probably a fringe problem because cars were obviously not intended to be modded at this point. I have the feeling I’m just a tiny hint away from the solution though :smiley:


Here is my current progress with the black cars but working mask. Those are sand and sulfur trucks:

The model looks fine in Unity. Since I don’t have the shader available in unity I am copying car_aluminium to create my own material in code, copying the textures from the material I prepared in Unity over to the copied material.

Hey. From a super quick look I don’t know what’s wrong, but I uploaded the current car shader + some textures for you.

Maybe this can help you get it working.

Dropbox - carShaderFiles.zip - Simplify your life

Thanks for the lightning-fast help! That solved it for me:

Your description of the mask texture was correct. Red is metallic, green is mask, blue is ambient occlusion and alpha is smoothess. My problem was that I made two mistakes at the same time: I expected a high value in the mask channel to make the mask color shine through, but a low value means use mask color whereas a high value means you main texture. And the second problem was with ambient occlusion. I thought a high value means lots of occlusion, but in reality a high value means less occlusion (= brighter). From a mathematical and physical point of view that actually makes sense, just the name is confusing. I guess ambient unocclusion isn’t really a word though :joy:

Now I can work some more on the models and textures.


Edit: Good enough for my (current) standards :smiley:

1 Like

For just looking at the buildings this is correct. However the Masked shader has the “tint” property and the standard shader does not. Tint is used in InfraSpace though, for example to highlight selected buildings or show that they are colliding with something. It is pretty important. It took me quite a while to figure out why my standard shader material asset wasn’t working in that regard. I changed my material to the masked shader and now the tint also works in-game. (Still have a couple of other problems, probably not related to the masked shader).