Texture-Replacement Effect

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m
(Supported Tags)
 
(5 intermediate revisions by 3 users not shown)
Line 4: Line 4:
 
Each texture-replacement subcontainer supports the following tags.  
 
Each texture-replacement subcontainer supports the following tags.  
 
  kind "texture-replacement"
 
  kind "texture-replacement"
name ""
 
 
  texture "<texture name>"
 
  texture "<texture name>"
  
Line 12: Line 11:
 
String. Required. No default.
 
String. Required. No default.
 
"texture-replacement"
 
"texture-replacement"
 
===name===
 
String.  Not required. 
 
This tag provides an accessible name for the container that can be used by scripts.  It may be left blank so that a script can use the tag for temporary storage.
 
  
 
===texture===
 
===texture===
Line 21: Line 16:
 
The name of the texture that is to be replaced. This is the name of the texture file as used in the asset's config.txt, without the .txt extension.  For instance, if the texture to be replaced is identified in the 'load-map.texture.txt' file, then the texture tag in the effect container is "load-map.texture".
 
The name of the texture that is to be replaced. This is the name of the texture file as used in the asset's config.txt, without the .txt extension.  For instance, if the texture to be replaced is identified in the 'load-map.texture.txt' file, then the texture tag in the effect container is "load-map.texture".
  
When the load texture is to be replaced then this texture will be replaced by the texture contained in the product referenced in the current active product queue, as defined by the allowed-categories subcontainer in the queue.  For instance, if a coal hopper loads at an industry asset that produces a bulk-load other than it's default load (eg woodchips at a lumbermill), then the woodchip product texture will replace the default coal product texture.
+
A texture-replacement effect is often used when the texture of an asset should be changed during game play.  For instance, when the load texture is to be replaced then this texture will be replaced by the texture contained in the product referenced in the current active product queue, as defined by the allowed-categories subcontainer in the queue.  For instance, if a coal hopper loads at an industry asset that produces a bulk-load other than its default load (eg woodchips at a lumbermill), then the woodchip product texture will replace the default coal product texture.
 +
 
 +
A texture-replacement effect is also used when an asset is reskinned using an alias.  In this case the texture replacement occurs when the asset is created - the texture of the aliased asset is replaced with a texture from the reskin asset.
  
 
==Example texture-replace subcontainer==
 
==Example texture-replace subcontainer==
Line 30: Line 27:
 
       }
 
       }
 
     }
 
     }
 +
 +
==Performance Considerations==
 +
 +
Texture-replacement can be used by content developers to achieve a range of interesting and novel scripted effects, though there are some considerations that should be noted. Whether performance will be adversely affected is dependant upon numerous variables. When it comes to predicting the performance impact of a particular texture-replacement implementation, the only reliable answer is: test it and see.
 +
 +
===potential issues===
 +
 
 +
* it's likely to load both the original and the replacement textures, so you may pay twice the loading cost and twice the RAM cost.
 +
 +
* in older versions of the game, you might end up with the game freezing while it loads in the replacement texture.
 +
 +
* in newer versions of the game, it shouldn't freeze but it's feasible that you might end up with the old textures visible on screen until the new textures load.
 +
 +
* it likely negates any texture preloading, so you're more likely to end up with low-res textures visible to the user.
 +
 +
* it likely disables a bunch of shared-material optimisations, so if you have multiple copies of the same object around then you'll now be paying one cost per instance rather than one cost per the whole set.
 +
 +
In newer versions some of that can be mitigated:
 +
 +
* as long as all of the textures look fairly similar, swapping from one to another once already visible isn't a major concern as long as it happens at lower LODs, which it generally will during actual game play.
 +
 +
* texture streaming makes it more likely that the double-texture costs will be minimal. You can probably further assist this by using smaller placeholder textures to start with i.e. the textures loaded as part of the mesh are kept to 32x32 or something small like that.
 +
  
 
[[Category:Config Container]]
 
[[Category:Config Container]]

Latest revision as of 04:51, 6 September 2019

The Texture-Replacement effect kind is a named effect container within a "mesh-table" Container. It can be used within the load subcontainer to provide alternative textures for bulk loads in wagons. The following tags are supported:

Contents

[edit] Supported Tags

Each texture-replacement subcontainer supports the following tags.

kind "texture-replacement"
texture "<texture name>"

The name of the texture-replacement effects subcontainer is selected by the content developer. It may be used as a reference in a script file to identify a specific effect.

[edit] kind

String. Required. No default. "texture-replacement"

[edit] texture

String. Required. No default. The name of the texture that is to be replaced. This is the name of the texture file as used in the asset's config.txt, without the .txt extension. For instance, if the texture to be replaced is identified in the 'load-map.texture.txt' file, then the texture tag in the effect container is "load-map.texture".

A texture-replacement effect is often used when the texture of an asset should be changed during game play. For instance, when the load texture is to be replaced then this texture will be replaced by the texture contained in the product referenced in the current active product queue, as defined by the allowed-categories subcontainer in the queue. For instance, if a coal hopper loads at an industry asset that produces a bulk-load other than its default load (eg woodchips at a lumbermill), then the woodchip product texture will replace the default coal product texture.

A texture-replacement effect is also used when an asset is reskinned using an alias. In this case the texture replacement occurs when the asset is created - the texture of the aliased asset is replaced with a texture from the reskin asset.

[edit] Example texture-replace subcontainer

   effects {
     product-texture {
       kind      "texture-replacement"
       texture	  "load_map.texture"
     }
   }

[edit] Performance Considerations

Texture-replacement can be used by content developers to achieve a range of interesting and novel scripted effects, though there are some considerations that should be noted. Whether performance will be adversely affected is dependant upon numerous variables. When it comes to predicting the performance impact of a particular texture-replacement implementation, the only reliable answer is: test it and see.

[edit] potential issues

  • it's likely to load both the original and the replacement textures, so you may pay twice the loading cost and twice the RAM cost.
  • in older versions of the game, you might end up with the game freezing while it loads in the replacement texture.
  • in newer versions of the game, it shouldn't freeze but it's feasible that you might end up with the old textures visible on screen until the new textures load.
  • it likely negates any texture preloading, so you're more likely to end up with low-res textures visible to the user.
  • it likely disables a bunch of shared-material optimisations, so if you have multiple copies of the same object around then you'll now be paying one cost per instance rather than one cost per the whole set.

In newer versions some of that can be mitigated:

  • as long as all of the textures look fairly similar, swapping from one to another once already visible isn't a major concern as long as it happens at lower LODs, which it generally will during actual game play.
  • texture streaming makes it more likely that the double-texture costs will be minimal. You can probably further assist this by using smaller placeholder textures to start with i.e. the textures loaded as part of the mesh are kept to 32x32 or something small like that.
Personal tools