Difference between revisions of "Material Modding"

From Software Inc.
Jump to navigation Jump to search
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
You can add your own textures to be used as wall and floor materials in the game.
+
You can add your own textures to be used as wall and floor materials in the game, by defining in a [[TyD|TyD]] file.
  
 
The game will take all the default and your supplied textures and put them in 3 huge texture atlasses, which the game then maps walls and floors to. Note that how many materials you can have in the game depends on the maximum size of textures your GPU supports. If your GPU supports 4k textures, you can have a maximum of (4096^2)/(256^2)=256 materials. This also means additional materials only adds to the loading time of the game and won't affect in-game performance, as all building floors and walls are drawn in 1 single draw call (player chosen colors are also mapped to a global color texture).
 
The game will take all the default and your supplied textures and put them in 3 huge texture atlasses, which the game then maps walls and floors to. Note that how many materials you can have in the game depends on the maximum size of textures your GPU supports. If your GPU supports 4k textures, you can have a maximum of (4096^2)/(256^2)=256 materials. This also means additional materials only adds to the loading time of the game and won't affect in-game performance, as all building floors and walls are drawn in 1 single draw call (player chosen colors are also mapped to a global color texture).
Line 7: Line 7:
 
You can add your own materials to the game by creating a new folder inside the Materials folder in the root of the game.
 
You can add your own materials to the game by creating a new folder inside the Materials folder in the root of the game.
  
Inside your new folder you should add a "materials.xml" file and all your textures as 256x256 png files. The root tag of the xml file should be named after the name of your material pack. Each child tag constitutes a new material.
+
Inside your new folder you should add a "materials.tyd" file and all your textures as 256x256 png files. the tyd file should contain a table for each material you want to add.
  
 
== Materials ==
 
== Materials ==
Each material will be named as its tag. The player will never see this name, but the game uses it for serialization purposes, so you should make the name as unique as possible to avoid overlap. If a material is named the same as another one, it will replace it, which you can use to replace in-game materials.
+
Each material will be named after the name of its table. The player will never see this name, but the game uses it for serialization purposes, so you should make the name as unique as possible to avoid overlap. If a material is named the same as another one, it will replace it, which you can use to replace in-game materials.
  
Each material should have sub tags defining its Category, either '''Floor''', '''Interior''', '''Exterior''', '''Roof''' or '''Path''', optional paths to its "Base", "Bump" and "Extra" textures and optionally a Skirting tag which you can use to remove skirtings on interior wall materials using <Skirting>False</Skirting>.
+
Each material should have records defining its Category, either '''Floor''', '''Interior''', '''Exterior''', '''Roof''' or '''Path''', optional paths to its '''Base''', '''Bump''' and '''Extra''' textures and optionally a '''Skirting''' record which you can use to remove skirtings on interior wall materials using '''Skirting False'''.
  
As of Alpha 10.4.4, you can add an optional FloorType tag to floor materials, with the value set to either Wood, Ceramic, Carpet(default) or Concrete, which changes which footstep sound effects to use when employees walk over the floor.
+
You can also add an optional '''FloorType''' record to floor materials, with the value set to either '''Wood''', '''Ceramic''', '''Carpet'''(default) or '''Concrete''', which changes which footstep sound effects to use when employees walk over the floor.
 +
 
 +
You can also add up to 8 color presets, that makes it easier for the player to pick colors. Just add a list of lists of up to 2 colors each, e.g. '''Presets [ [ "#FF0000"; "#00FF00" ]; [ "#0000FF"; "FF00FF" ] ]'''
 +
 
 +
Finally, to control the second color the player can choose you can either add '''SecondaryColorEnabled False''' or '''SecondaryColorEnabled True''' and '''ForcedSecondaryColor #FF00FF'''.
  
 
== Material textures ==
 
== Material textures ==
 
Materials consist of:
 
Materials consist of:
* Base texture, which is a texture that can be colored by the player. This should be grayscale most of the time, as the player chosen color will be applied directly by multiplying it, except as noted for the Extra texture.
+
* Base texture, which is a texture that can be colored by the player.
 +
** The red channel is the first player mapped color
 +
** The green channel is the optional second player mapped color
 +
** The blue channel should be 0 to enable custom player colors, if blue is > 0 then the color will just be output as is, ignoring any player chosen colors. This can be used to add details like gold adornments.
 
* Bump texture, which is the normal map. These are usually purple, signifying a direction pointing along the normal of the surface.
 
* Bump texture, which is the normal map. These are usually purple, signifying a direction pointing along the normal of the surface.
 
* Extra texture. The material uses the 4 color channels of the extra texture to modify the material.  
 
* Extra texture. The material uses the 4 color channels of the extra texture to modify the material.  
 
** The red channel controls occlusion, i.e. how dark a material appears, even in direct light, to simulate crevices.
 
** The red channel controls occlusion, i.e. how dark a material appears, even in direct light, to simulate crevices.
 
** The green channel controls smoothness/specularity, where 100% green means very shiny.
 
** The green channel controls smoothness/specularity, where 100% green means very shiny.
** The blue channel controls color masking, where 100% blue means the player's color will be 100% multiplied with the base texture color and 0% means the material will only use the base texture color. An example of using the blue channel of the Extra texture would be to add gold adornments to a wall that the player can't change the color of.
+
** The blue channel controls metallic, where 100% blue means completely metallic and reflective. Note that the reflectiveness is limited as the game is simulating this based on the player's graphics settings and does not support RTX
** As of Alpha 10.10, the alpha channel of the Extra texture controls snow and rain. 100% alpha means no snow or rain, 50% alpha means 100% snow and about 50% rain and 0% alpha means 100% rain. So from 100% alpha to 0% you get nothing -> fully snowed and a little rain -> completely wet. If you are using Photoshop, it is recommended that you add the alpha channel as a new channel and save your texture using the SuperPNG plugin to avoid alpha channel corruption.
+
** As of Alpha 10.10, the alpha channel of the Extra texture controls snow and rain.
 +
***100% alpha or completely opaque means no snow and rain
 +
***75% alpha means no snow and about 25% rain
 +
***50% alpha means snow in the middle of winter and about 50% rain
 +
***0% alpha means 100% rain and snow at the start of winter.
 +
***If you are using Photoshop, it is recommended that you add the alpha channel as a new channel and save your texture using the SuperPNG plugin to avoid alpha channel corruption.
  
= XML example =
+
= TyD example =
<pre><CoolPack>
+
'''CoredumpingBestWall'''
<CoredumpingBestWall>
+
{
<Category>Interior</Category>
+
'''Category''' <span style="color:blue">Interior</span>
<Base>base.png</Base>
+
'''Base''' <span style="color:blue">base.png</span>
<Bump>bump.png</Bump>
+
'''Bump''' <span style="color:blue">bump.png</span>
<Extra>extra.png</Extra>
+
'''Extra''' <span style="color:blue">extra.png</span>
<Skirting>False</Skirting>
+
'''Skirting''' <span style="color:blue">False</span>
</CoredumpingBestWall>
+
'''SecondaryColorEnabled''' <span style="color:blue">False</span>
<CoredumpingBestFloor>
+
'''ForcedSecondaryColor''' <span style="color:blue">#FF0000</span>
<Category>Floor</Category>
+
}
<Base>base.png</Base>
+
'''CoredumpingBestFloor'''
<Bump>bump.png</Bump>
+
{
<Extra>extra.png</Extra>
+
'''Category''' <span style="color:blue">Floor</span>
<FloorType>Ceramic</FloorType>
+
'''Base''' <span style="color:blue">base.png</span>
</CoredumpingBestFloor>
+
'''Bump''' <span style="color:blue">bump.png</span>
</CoolPack></pre>
+
'''Extra''' <span style="color:blue">extra.png</span>
 +
'''FloorType''' <span style="color:blue">Ceramic</span>
 +
'''SecondaryColorEnabled''' <span style="color:blue">True</span>
 +
'''Presets'''
 +
[
 +
[ <span style="color:blue">"#FF0000"</span>; <span style="color:blue">"#00FF00"</span> ]
 +
[ <span style="color:blue">"#FFFF00"</span>; <span style="color:blue">"#00FFFF"</span> ]
 +
]
 +
}
  
 
= Texture example =
 
= Texture example =
 
== Base texture ==
 
== Base texture ==
The texture is grey scale to allow for colorization by the player. You can add color and set the blue channel of the extra texture to 0 to disallow player colorization of parts of the texture.
+
The texture can be colored using 2 colors by the player, both for the brick and mortar. The blue channel isn't used, since the texture has no parts that the player can't color.
  
[[File:BrickPath.png]]
+
[[File:BrickTexxxxxxx.png]]
  
 
== Bump texture ==
 
== Bump texture ==
Line 54: Line 74:
  
 
== Extra texture ==
 
== Extra texture ==
Note the 100% blue, to allow for player colorization all over the texture, 0% green as this material isn't smooth at all and very low red in the crevices to simulate ambient occlusion.
+
Note the colors:
 +
*Very low red in the crevices to simulate ambient occlusion.
 +
*0% green, as this material isn't smooth at all
 +
*0% blue, as this material isn't metallic/reflective at all
 +
 
  
 
[[File:BrickPathExtra.png]]
 
[[File:BrickPathExtra.png]]
  
 
=== Extra texture alpha ===
 
=== Extra texture alpha ===
Note how the snow gets added the same way you would use threshold in Photoshop, so you should use gradients to control where snow starts to gather in crevices. The wetness/shininess is faded in as the alpha channel moves from 100% to 0%
+
Note how the snow gets added the same way you would use threshold in Photoshop, so you should use gradients to control where snow starts to gather in crevices. The wetness/shininess is faded in as the alpha channel moves from 100% to 0%. The alpha channel never hits 100% as we want it to become wet all over, in rainy conditions, and the crevices are almost completely transparent/black, as snow gathers there initially.
  
 
[[File:BrickPathExtraAlpha.png]]
 
[[File:BrickPathExtraAlpha.png]]

Latest revision as of 17:18, 12 March 2023

You can add your own textures to be used as wall and floor materials in the game, by defining in a TyD file.

The game will take all the default and your supplied textures and put them in 3 huge texture atlasses, which the game then maps walls and floors to. Note that how many materials you can have in the game depends on the maximum size of textures your GPU supports. If your GPU supports 4k textures, you can have a maximum of (4096^2)/(256^2)=256 materials. This also means additional materials only adds to the loading time of the game and won't affect in-game performance, as all building floors and walls are drawn in 1 single draw call (player chosen colors are also mapped to a global color texture).

Material mod structure

Main structure

You can add your own materials to the game by creating a new folder inside the Materials folder in the root of the game.

Inside your new folder you should add a "materials.tyd" file and all your textures as 256x256 png files. the tyd file should contain a table for each material you want to add.

Materials

Each material will be named after the name of its table. The player will never see this name, but the game uses it for serialization purposes, so you should make the name as unique as possible to avoid overlap. If a material is named the same as another one, it will replace it, which you can use to replace in-game materials.

Each material should have records defining its Category, either Floor, Interior, Exterior, Roof or Path, optional paths to its Base, Bump and Extra textures and optionally a Skirting record which you can use to remove skirtings on interior wall materials using Skirting False.

You can also add an optional FloorType record to floor materials, with the value set to either Wood, Ceramic, Carpet(default) or Concrete, which changes which footstep sound effects to use when employees walk over the floor.

You can also add up to 8 color presets, that makes it easier for the player to pick colors. Just add a list of lists of up to 2 colors each, e.g. Presets [ [ "#FF0000"; "#00FF00" ]; [ "#0000FF"; "FF00FF" ] ]

Finally, to control the second color the player can choose you can either add SecondaryColorEnabled False or SecondaryColorEnabled True and ForcedSecondaryColor #FF00FF.

Material textures

Materials consist of:

  • Base texture, which is a texture that can be colored by the player.
    • The red channel is the first player mapped color
    • The green channel is the optional second player mapped color
    • The blue channel should be 0 to enable custom player colors, if blue is > 0 then the color will just be output as is, ignoring any player chosen colors. This can be used to add details like gold adornments.
  • Bump texture, which is the normal map. These are usually purple, signifying a direction pointing along the normal of the surface.
  • Extra texture. The material uses the 4 color channels of the extra texture to modify the material.
    • The red channel controls occlusion, i.e. how dark a material appears, even in direct light, to simulate crevices.
    • The green channel controls smoothness/specularity, where 100% green means very shiny.
    • The blue channel controls metallic, where 100% blue means completely metallic and reflective. Note that the reflectiveness is limited as the game is simulating this based on the player's graphics settings and does not support RTX
    • As of Alpha 10.10, the alpha channel of the Extra texture controls snow and rain.
      • 100% alpha or completely opaque means no snow and rain
      • 75% alpha means no snow and about 25% rain
      • 50% alpha means snow in the middle of winter and about 50% rain
      • 0% alpha means 100% rain and snow at the start of winter.
      • If you are using Photoshop, it is recommended that you add the alpha channel as a new channel and save your texture using the SuperPNG plugin to avoid alpha channel corruption.

TyD example

CoredumpingBestWall
	{
	Category		Interior
	Base			base.png
	Bump			bump.png
	Extra			extra.png
	Skirting		False
	SecondaryColorEnabled	False
	ForcedSecondaryColor	#FF0000
	}
CoredumpingBestFloor
	{
	Category		Floor
	Base			base.png
	Bump			bump.png
	Extra			extra.png
	FloorType		Ceramic
	SecondaryColorEnabled	True
	Presets
		[
			[ "#FF0000"; "#00FF00" ]
			[ "#FFFF00"; "#00FFFF" ]
		] 
	}

Texture example

Base texture

The texture can be colored using 2 colors by the player, both for the brick and mortar. The blue channel isn't used, since the texture has no parts that the player can't color.

BrickTexxxxxxx.png

Bump texture

BrickPathNormal.png

Extra texture

Note the colors:

  • Very low red in the crevices to simulate ambient occlusion.
  • 0% green, as this material isn't smooth at all
  • 0% blue, as this material isn't metallic/reflective at all


BrickPathExtra.png

Extra texture alpha

Note how the snow gets added the same way you would use threshold in Photoshop, so you should use gradients to control where snow starts to gather in crevices. The wetness/shininess is faded in as the alpha channel moves from 100% to 0%. The alpha channel never hits 100% as we want it to become wet all over, in rainy conditions, and the crevices are almost completely transparent/black, as snow gathers there initially.

BrickPathExtraAlpha.png