Texture file

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m
(Notes on Image Editors)
 
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{ORP-top}}
 
{{ORP-top}}
'''Scope:''' This guideline applies to each of the following Trainz {{wp|data type|type specifications}}:
+
Trainz '''Texture files''' are ASCII text format specification files describing a single texture. Texture files have a ".texture.txt" name extension, however when a texture file is specified within a [[config.txt file]] or similar, the ".txt" must be omitted (as you are specifying a resource name, not a file path), leaving only the ".texture" extension.
:''[[KIND Texture]], [[KIND Groundtexture]], [[Alpha masking]], [[.texture.txt Files|Miscellaneous.texture.txt Files]], and the [["Thumbnails" container]]''.
+
  
:''Related data types: "Texture-variants" container'' (asset provides alternative material configurations for the texture to display as seasonal variants.)  
+
Texture files (*.texture.txt) should be distinguished from [[image file]]s (*.tga, etc.) and [[material]]s. A material may utilize zero or more texture files, and a texture file may utilize one or more image files. While we often refer to the image data as "a texture", this usage isn't strictly correct as any given texture also has a number of metadata attributes which are not present in the source image. Additionally, a texture may be compressed (at installation time) which may actually lose some of the data originally present in the source image.
  
 +
When importing a [[trainzmesh file]] from an [[FBX file]], any image files referenced in the FBX which do not already have corresponding texture files will have generic texture files created automatically. These files may be suitable for basic purposes, but may need to be customized for more advanced functionality. Once the file has been created (and optionally customised) the importer will not recreate/overwrite it on subsequent runs.
  
;Descripton
+
This page describes [["Trainz-build" number|content format v4.6]].
Trainz '''Texture files''' are ASCII text format specification files describing a single texture. Texture files have a ".texture.txt" name extension, however when a texture file is specified within a [[Config.txt file]] or similar, the ".txt" must be omitted, leaving the ".texture" extension.
+
  
Files with '''*.texture.txt''' suffix and extension are used to configure texture behavior in Trainz. These files may also control how textures are processed by [[Content Manager]].  These files are located in the same folder as the source texture files, typically .bmp, .tga or .jpg, and make reference to them.  These files are generated automatically by the exporter or importer but may be edited by hand when specialization is required.
 
  
 
+
=File format=
==File format==
+
  
 
The user-editable *.texture.txt files are ASCII text formatted key-value pairs with the following options. Please note that this format is not the same (despite some similarities) as other text-based formats used by Trainz. Please be aware of the [[filename character restrictions]] when naming texture and image files.
 
The user-editable *.texture.txt files are ASCII text formatted key-value pairs with the following options. Please note that this format is not the same (despite some similarities) as other text-based formats used by Trainz. Please be aware of the [[filename character restrictions]] when naming texture and image files.
  
 
;Syntax
 
;Syntax
Each token is specified on a new line. There is no white space on either side of the '=' sign. A empty value is sometimes valid. The syntax is:
+
Each key is specified on a new line. There is no white space anywhere in the line. A empty value is sometimes valid. The syntax is:
  
  <token>=<value>
+
  <key>=<value>
  
 
;Example:
 
;Example:
Line 26: Line 23:
 
  Tile=st
 
  Tile=st
 
  AlphaHint=masked
 
  AlphaHint=masked
Anisotropy=16
 
MagFilter=linear
 
MinFilter=linear
 
MipFilter=linear
 
 
''(Example only, not recommended settings)''
 
''(Example only, not recommended settings)''
  
  
===Tokens and Values===
+
==Keys and Values==
  
 
  Primary=diffusemap.bmp
 
  Primary=diffusemap.bmp
Line 43: Line 36:
 
  Alpha=diffusemap.bmp
 
  Alpha=diffusemap.bmp
  
This tag combination specifies the filenames of the image file representing the color (R, G, B) channels of the texture and the image file representing the alpha (A) channel of the texture. The alpha channel image should be grayscale. Neither file should contain an alpha channel.
+
This tag combination specifies the filenames of the image file representing the color (R, G, B) channels of the texture (Primary) and the image file representing the transparency of the texture (Alpha). The Alpha image should be grayscale. Neither file should contain an alpha (A) channel (ie, both images should be 24-bit). The two image files must be of identical size.
  
  
Line 49: Line 42:
 
  Alpha=diffusemap.tga
 
  Alpha=diffusemap.tga
  
This tag combination specifies the filename of a single image file representing the color and alpha (R, G, B, A) channels of the texture. In this case both tags must reference the same filename. The image file must contain an alpha channel.
+
This tag combination specifies the filename of a single image file representing the color and transparency (R, G, B, A) channels of the texture. In this case both tags must reference the same filename. The image file must contain an alpha channel.
  
  
  Compression=dxt1
+
  Compression=dxt3
  
This tag forces the usage of a particular texture compression scheme. If omitted, Trainz will choose an appropriate texture compression scheme based on the contents of the supplied image files. If you don't have a specific effect in mind, don't include this tag. Valid options are 'none', 'dxt1', 'dxt3', 'dxt5'. Refer [[DXT Compression]].  
+
This tag hints the usage of a particular texture compression scheme. If you don't have a specific effect in mind, don't include this tag. Valid options are currently 'none', 'dxt1', 'dxt3', 'dxt5'. Refer [[DXT Compression]].
 +
 
 +
The current selection logic for texture compression is as follows, however it should be noted that this may change between Trainz versions. The first matching rule is used.
 +
 
 +
* Special texture formats (such as HDR) which don't support compression are stored uncompressed.
 +
* "Compression=none" forces no compression. This gives the best visual result for a given input image, but typically yields worse visual results per output texture filesize. It is often better to activate compression and double the image dimensions, rather than disabling compression.
 +
* Images with an "opaque" alpha hint use DXT1 compression.
 +
* "Compression=dxt3" will use DXT3 compression.
 +
* DXT5 compression is used.
  
  
Line 60: Line 61:
  
 
The 'NormalMapHint' tag allows the texture to be specified as a [[normal map]]. By default, Trainz will assume that your texture is a [[diffuse map]] and will apply some processing options which are not appropriate for normal maps. You must specify this option for normal maps. Valid options are 'none' and 'normalmap'.
 
The 'NormalMapHint' tag allows the texture to be specified as a [[normal map]]. By default, Trainz will assume that your texture is a [[diffuse map]] and will apply some processing options which are not appropriate for normal maps. You must specify this option for normal maps. Valid options are 'none' and 'normalmap'.
 +
  
 
  ModifyMap=flipgreen
 
  ModifyMap=flipgreen
  
The 'ModifyMap' option allows a texture's green color channel to be flipped.  Some programs such as 3ds Max create [[normal map]]s with the Y axis facing the opposite way to what is expected by the Trainz shaders.  This option can be used to make the bump effect look correct in Trainz. The option is applied by the [[Content Manager]] upon Commit. Valid options are 'none' and 'flipgreen'.
+
The 'ModifyMap' option allows a texture's green color channel to be flipped.  Some programs such as [[Autodesk 3ds Max]] create [[normal map]]s with the Y axis facing the opposite way to what is expected by the Trainz shaders.  This option can be used to make the bump effect look correct in Trainz. Valid options are 'none' and 'flipgreen'.
  
  
 
  AlphaHint=opaque
 
  AlphaHint=opaque
  
The 'AlphaHint' tag allows you to force a particular alpha mode on the texture. Valid options are 'opaque' (meaning that the alpha channel is unused and effectively pure white), 'semitransparent' (meaning that the alpha channel is a grayscale blend) and 'masked' (meaning that the alpha channel is a pure black&white bitmap.) If omitted, Trainz will supply an appropriate value for this tag based on the Alpha channel. Specifying this option prevents slight discoloration in a mask texture from triggering the blended alpha path.
+
The 'AlphaHint' tag allows you to force a particular alpha mode on the texture. Valid options are 'opaque' (meaning that the alpha channel is overwritten with pure white), 'semitransparent' (meaning that the alpha channel is a grayscale blend) and 'masked' (meaning that the alpha channel is clamped to a pure black&white bitmap based on a 50% threshold.) If omitted, Trainz will supply an appropriate value for this tag based on the actual contents of the Alpha channel.
  
  
Anisotropy=1
 
  
Anisotropic sampling quality. The higher the number, the better the visual quality but at significant performance cost. Where texture quality is needed specify a higher value. Trainz currently defaults to Very High anisotropic filtering, which is then subsequently restricted by the in-game Anisotropy slider.  Valid values are integers
+
  Tile=st
"1" (default) - No anisotropic filtering, "2" - Low, "4" - Medium, "8" - High, and "16" - Very High
+
  
 +
Tiling refers to the ability for texture coordinates outside the range of (0.0 .. 1.0) to be treated as valid coordinates on an infinitely tiled texture. With tiling active, coordinates which pass the right/bottom side of the texture effectively wrap back onto the left/top side, and so on. Valid options include 's' (tile horizontally), 't' (tile vertically), 'st' (tile both horizontally and vertically), and 'none' (do not tile the image).
  
MagFilter=linear
 
  
Controls the filtering style for texel magnification. This is used when a texel is displayed at larger than real size (eg. a single texel is represented with more than a single pixel.) Valid settings for the magnification filter are 'nearest', 'linear', and 'default'. Trainz currently defaults to linear interpolation. Selecting 'nearest' will use a nearest-neighbor filtering mode which results in a "pixelated" output.
+
  MipAlgorithm=no-weight-by-alpha
   
+
  
MinFilter=linear
+
The default [[mipmap]] generation algorithm generally treats the alpha channel as an opacity and prioritizes opaque texels over transparent ones. This can lead to poor results in cases where the alpha channel is used for a different purpose (such as with PBR parameter textures). The "no-weight-by-alpha" hint can be used to ensure that the game will give equal weighting to texels regardless of their alpha channel.
  
Controls the filtering style for texel minification. This is used when a texel is displayed at smaller than real size (eg. a single pixel is represented with more than a single texel.) Valid settings for the minification filter are 'nearest', 'linear', and 'default'. Trainz currently defaults to linear interpolation. Selecting 'nearest' will use a quantized filtering mode which results in a "noisy" output.
+
The value of this key is only relevant where [[Content Manager]] is responsible for producing mipmap images. It is not relevant on any mipmap images provided in the source images.
  
  
  MipFilter=linear
+
  nonpoweroftwo=1
  
Controls the filtering style for texture mipmap selection. Mipmaps are used during minification to help prevent the moire effect pattern. The cost of using mipmaps is that the resultant image will blur slightly. The benefits of using mipmaps are reduced quantization noise and reduced memory footprint (since the higher detail mip levels can be unloaded when not in use.) Valid settings for the mip filter are 'nearest', 'linear', 'default' and 'none'. Trainz currently defaults to trilinear interpolation. Selecting 'nearest' will cause the hardware to select a single mipmap for each pixel, which results in visible banding at mipmap boundaries. Selecting 'none' will disable mipmaps, resulting in lower performance, higher memory usage, and "noisy" output.
+
By default, all textures must have both their width and height as a power of two (eg. 8, 16, 32, 64, 128, 256, 512, 1024, 2048), though they need not be square. Setting the value '1' for the 'nonpoweroftwo' key allows this restriction to be relaxed. This is currently considered experimental and may have unexpected performance, quality, or functionality outcomes. It is not recommended that end-users utilize this format at the current time.
  
 +
Non-power-of-two (NPOT) textures may not support mipmapping and thus may be noticeably affected by the moire effect in addition to having higher overall GPU bandwidth requirements.
  
Tile=st
+
=Texture Formats=
 +
The following texture formats are supported internally by Trainz on desktop platforms.
 +
* R8 G8 B8 A8
 +
* DXT1
 +
* DXT3
 +
* DXT5
 +
* R32F G32F B32F A32F
  
Tiling refers to the ability for texture coordinates outside the range of (0.0 .. 1.0) to be treated as valid coordinates on an infinitely tiled texture. With tiling active, coordinates which pass the right/bottom side of the texture effectively wrap back onto the left/top side, and so on. Valid options include 's' (tile horizontally), 't' (tile vertically), 'st' (tile both horizontally and vertically), and 'none' (do not tile the image).
+
The selection of internal format depends on the source image format and the value of the 'Compression' key.
  
 +
=Texture Size=
 +
Textures must be no more than 4096 pixels in either dimension, although it is strongly recommended that textures are kept below this maximum to avoid performance problems. Small objects should typically use approximately 512x512. Large, highly detailed objects such as train vehicles or ground textures will typically use 2048x2048.
 +
Uniform-color textures (ie. textures in which all [[texel]]s have the same color) should be 8x8, 2x2, or 1x1.
 +
Textures must be a power-of-two size in each dimension (unless the 'nonpoweroftwo' key is activated), but need not be square. Some materials may give unexpected results for non-square textures; consult the material-specific documentation for details.
  
MipAlgorithm=tend-towards-opaque
+
=Source Image Formats=
 +
The following image formats are acceptable as source data for the texture file. Note that these formats are not used at runtime, and that format-specific benefits such as compression will apply to the DLS download size of the content but not to the runtime memory footprint or GPU bandwidth usage.
  
The default [[mipmap]] generation algorithm tends to make semi-transparent dithers (such as chain-link fences or tree leaves) appear more transparent in the distance. This occurs because the multiple texels of alpha in the high-detail source image (100%, 0%, 100%, 0%) are blended to a single pixel in the lower mips (50%.) The net result is that the average opacity level remains the same, but that the maximum value is reduced. Coupled with the fact that overlapping layers of semi-opaque textures do not necessarily increase the output opacity (a rendering limitation relating to performance) the net result is that something which might be quite opaque close-up may become ghostly in the distance. An alternate "tend-towards-opaque" algorithm may be selected for mipmap generation, which defeats this issue by biasing opacity toward the maximum. This increases average opacity for distant objects, and has the side effect of making soft edges become hard and potentially "blocky". It should only be used where the default algorithm gives decidedly sub-optimal results.
+
* Targa (.tga) files. Targa is a lossless image format with optional compression and optional alpha channel. This is a sensible choice where compatibility with older versions of Trainz is desired.
 +
* JPEG (.jpg) files. JPEG is a lossy image compression format with no alpha channel support. This format should generally be avoided since it will typically lead to the image being compressed in a lossy format (JPG), decompressed, recompressed again into another lossy format (DXT1), losing detail at each stage. Worse, if JPEG files are used during the creation of the image, each edit-save-test cycle may result in a loss of image quality.
 +
* Windows Bitmap (.bmp) files. BMP is a lossless image format with no compression and optional alpha channel. This format should generally be avoided since it does not offer compression and has no redeeming benefits.
 +
* HDR (.hdr) files. HDR is a lossless image format with 32 bits of precision per channel. The R32F G32F B32F A32F internal texture format is used, and texture compression is not supported. This is a very expensive format (in terms of memory and performance) and should only be used where absolutely essential. Textures created in this format should be kept as small as possible (eg. 256-512 pixels wide and high) but at least 8x8 pixels wide and high.
 +
* PNG (.png) files. PNG is a lossless compressed image format with alpha channel support. This is the best choice where compatibility with older versions of Trainz is not required.
 +
* DDS (.dds) files. This has very limited support intended for specific internal purposes; it is not recommended that end-users utilize this format at the current time.
  
 +
All images which comprise a given texture must have identical dimensions (width, height).
  
==Comments & Suggestions==
+
Source images should use the SRGB color space except where material-specific documentation indicates otherwise.
The token ''Hint'' is intended for internal use only, but has been used and abused by well meaning people since its discovery.  ''Anisotropy'' should be used to improve texture quality, and ''MipFilter=none'' should be used to disable mip mapping only for ''interface textures''.
+
  
 
+
=Notes on Image Editors=
==Image formats==
+
The following image formats are acceptable as source data for the Texture file:
+
 
+
* Targa (.tga) files. Targa is a lossless image format with optional compression and optional alpha channel.
+
* JPEG (.jpg) files. JPEG is a lossy image compression format with no alpha channel support.
+
* Windows Bitmap (.bmp) files. BMP is a lossless image format with no compression and optional alpha channel.
+
 
+
These images in association with the appropriate *.texture.txt file are used by [[Content Manager]] to create the N3V binary textures that are used in the simulator. The N3V binary textures use [[DXT Compression]] and contain image LOD information.
+
 
+
All built-in content has only N3V binary textures that cannot be opened with normal imaging software.  Appropriate tools to view these can be found on the [[Tools]] page.
+
 
+
Any image larger than 2048x2048 will be resized to that maximum, so there is no point in using images larger than that in the asset. It is preferable to resize your images using your preferred resampling option in your favorite image editing program than to allow [[Content Manager]] to resize the image. In practice, images should be no larger than needed to provide the appropriate level of detail at the closest typical viewing distance. Uniform-color images should be as small as possible - certainly no larger than 16x16.
+
 
+
==Notes on Image Editors==
+
 
* The Targa Exporter plugin shipped with some older versions of Adobe Photoshop is broken and silently corrupts or discards alpha channels; a free update is available which resolves this issue.
 
* The Targa Exporter plugin shipped with some older versions of Adobe Photoshop is broken and silently corrupts or discards alpha channels; a free update is available which resolves this issue.
 
* Some image editors do not support alpha channels on BMP files.
 
* Some image editors do not support alpha channels on BMP files.
 +
* By default, Photoshop does not allow for explicit editing of the alpha channel in PNG images. There is a free plugin called [https://www.fnordware.com/superpng/ SuperPNG] which integrates better PNG support to enable saving and editing of PNG alpha masks.
 +
* [http://www.amnoid.de/ddsview/ ddsview ] is an open source image editor that can properly open all of the texture formats used by Trainz. This is an easy tool to quickly convert between PNG parameters and TGA parameters.
  
 
+
=*.txt File Extension=
==.txt file extension==
+
Texture files have a ".texture.txt" name extension, however when a texture file is specified within a [[config.txt file]] or similar, the ".txt" must be omitted, leaving the ".texture" extension.
Texture files have a ".texture.txt" name extension, however when a texture file is specified within a [[Config.txt file]] or similar, the ".txt" must be omitted, leaving the ".texture" extension.
+
 
For example, a texture file named ''grass.texture.txt'' is specified in a [[KIND Groundtexture]] config file using the syntax ''texture "grass.texture"''.
 
For example, a texture file named ''grass.texture.txt'' is specified in a [[KIND Groundtexture]] config file using the syntax ''texture "grass.texture"''.
  
==Use of image files in place of texture files==
+
=Use of Image Files in Place of Texture Files=
Trainz has historically supported using ''any supported image file'' type in place of a [[Texture file]]. This technique has obvious limitations and <code>is no longer recommended.</code>
+
Trainz previously supported using ''any supported image file'' type in place of a [[Texture file]]. [[TANE]] does not support this technique; a texture.txt file must be used.
  
 
[[Category:File formats]]
 
[[Category:File formats]]
 +
[[Category:Modeling]]
 +
[[Category:Content creation]]
 
{{ORP-bot}}
 
{{ORP-bot}}

Latest revision as of 07:45, 3 July 2020

Trainz Texture files are ASCII text format specification files describing a single texture. Texture files have a ".texture.txt" name extension, however when a texture file is specified within a config.txt file or similar, the ".txt" must be omitted (as you are specifying a resource name, not a file path), leaving only the ".texture" extension.

Texture files (*.texture.txt) should be distinguished from image files (*.tga, etc.) and materials. A material may utilize zero or more texture files, and a texture file may utilize one or more image files. While we often refer to the image data as "a texture", this usage isn't strictly correct as any given texture also has a number of metadata attributes which are not present in the source image. Additionally, a texture may be compressed (at installation time) which may actually lose some of the data originally present in the source image.

When importing a trainzmesh file from an FBX file, any image files referenced in the FBX which do not already have corresponding texture files will have generic texture files created automatically. These files may be suitable for basic purposes, but may need to be customized for more advanced functionality. Once the file has been created (and optionally customised) the importer will not recreate/overwrite it on subsequent runs.

This page describes content format v4.6.


Contents

[edit] File format

The user-editable *.texture.txt files are ASCII text formatted key-value pairs with the following options. Please note that this format is not the same (despite some similarities) as other text-based formats used by Trainz. Please be aware of the filename character restrictions when naming texture and image files.

Syntax

Each key is specified on a new line. There is no white space anywhere in the line. A empty value is sometimes valid. The syntax is:

<key>=<value>
Example
Primary=WayCoolTexture.tga
Alpha=WayCoolTexture.tga
Tile=st
AlphaHint=masked

(Example only, not recommended settings)


[edit] Keys and Values

Primary=diffusemap.bmp

This tag specifies the filename of the image file representing the color (R, G, B) channels of the texture. Any alpha channel in the image file is ignored. The resultant texture will have a pure white (100%) alpha channel.


Primary=diffusemap.jpg
Alpha=diffusemap.bmp

This tag combination specifies the filenames of the image file representing the color (R, G, B) channels of the texture (Primary) and the image file representing the transparency of the texture (Alpha). The Alpha image should be grayscale. Neither file should contain an alpha (A) channel (ie, both images should be 24-bit). The two image files must be of identical size.


Primary=diffusemap.tga
Alpha=diffusemap.tga

This tag combination specifies the filename of a single image file representing the color and transparency (R, G, B, A) channels of the texture. In this case both tags must reference the same filename. The image file must contain an alpha channel.


Compression=dxt3

This tag hints the usage of a particular texture compression scheme. If you don't have a specific effect in mind, don't include this tag. Valid options are currently 'none', 'dxt1', 'dxt3', 'dxt5'. Refer DXT Compression.

The current selection logic for texture compression is as follows, however it should be noted that this may change between Trainz versions. The first matching rule is used.

  • Special texture formats (such as HDR) which don't support compression are stored uncompressed.
  • "Compression=none" forces no compression. This gives the best visual result for a given input image, but typically yields worse visual results per output texture filesize. It is often better to activate compression and double the image dimensions, rather than disabling compression.
  • Images with an "opaque" alpha hint use DXT1 compression.
  • "Compression=dxt3" will use DXT3 compression.
  • DXT5 compression is used.


NormalMapHint=normalmap

The 'NormalMapHint' tag allows the texture to be specified as a normal map. By default, Trainz will assume that your texture is a diffuse map and will apply some processing options which are not appropriate for normal maps. You must specify this option for normal maps. Valid options are 'none' and 'normalmap'.


ModifyMap=flipgreen

The 'ModifyMap' option allows a texture's green color channel to be flipped. Some programs such as Autodesk 3ds Max create normal maps with the Y axis facing the opposite way to what is expected by the Trainz shaders. This option can be used to make the bump effect look correct in Trainz. Valid options are 'none' and 'flipgreen'.


AlphaHint=opaque

The 'AlphaHint' tag allows you to force a particular alpha mode on the texture. Valid options are 'opaque' (meaning that the alpha channel is overwritten with pure white), 'semitransparent' (meaning that the alpha channel is a grayscale blend) and 'masked' (meaning that the alpha channel is clamped to a pure black&white bitmap based on a 50% threshold.) If omitted, Trainz will supply an appropriate value for this tag based on the actual contents of the Alpha channel.


Tile=st

Tiling refers to the ability for texture coordinates outside the range of (0.0 .. 1.0) to be treated as valid coordinates on an infinitely tiled texture. With tiling active, coordinates which pass the right/bottom side of the texture effectively wrap back onto the left/top side, and so on. Valid options include 's' (tile horizontally), 't' (tile vertically), 'st' (tile both horizontally and vertically), and 'none' (do not tile the image).


MipAlgorithm=no-weight-by-alpha

The default mipmap generation algorithm generally treats the alpha channel as an opacity and prioritizes opaque texels over transparent ones. This can lead to poor results in cases where the alpha channel is used for a different purpose (such as with PBR parameter textures). The "no-weight-by-alpha" hint can be used to ensure that the game will give equal weighting to texels regardless of their alpha channel.

The value of this key is only relevant where Content Manager is responsible for producing mipmap images. It is not relevant on any mipmap images provided in the source images.


nonpoweroftwo=1

By default, all textures must have both their width and height as a power of two (eg. 8, 16, 32, 64, 128, 256, 512, 1024, 2048), though they need not be square. Setting the value '1' for the 'nonpoweroftwo' key allows this restriction to be relaxed. This is currently considered experimental and may have unexpected performance, quality, or functionality outcomes. It is not recommended that end-users utilize this format at the current time.

Non-power-of-two (NPOT) textures may not support mipmapping and thus may be noticeably affected by the moire effect in addition to having higher overall GPU bandwidth requirements.

[edit] Texture Formats

The following texture formats are supported internally by Trainz on desktop platforms.

  • R8 G8 B8 A8
  • DXT1
  • DXT3
  • DXT5
  • R32F G32F B32F A32F

The selection of internal format depends on the source image format and the value of the 'Compression' key.

[edit] Texture Size

Textures must be no more than 4096 pixels in either dimension, although it is strongly recommended that textures are kept below this maximum to avoid performance problems. Small objects should typically use approximately 512x512. Large, highly detailed objects such as train vehicles or ground textures will typically use 2048x2048. Uniform-color textures (ie. textures in which all texels have the same color) should be 8x8, 2x2, or 1x1. Textures must be a power-of-two size in each dimension (unless the 'nonpoweroftwo' key is activated), but need not be square. Some materials may give unexpected results for non-square textures; consult the material-specific documentation for details.

[edit] Source Image Formats

The following image formats are acceptable as source data for the texture file. Note that these formats are not used at runtime, and that format-specific benefits such as compression will apply to the DLS download size of the content but not to the runtime memory footprint or GPU bandwidth usage.

  • Targa (.tga) files. Targa is a lossless image format with optional compression and optional alpha channel. This is a sensible choice where compatibility with older versions of Trainz is desired.
  • JPEG (.jpg) files. JPEG is a lossy image compression format with no alpha channel support. This format should generally be avoided since it will typically lead to the image being compressed in a lossy format (JPG), decompressed, recompressed again into another lossy format (DXT1), losing detail at each stage. Worse, if JPEG files are used during the creation of the image, each edit-save-test cycle may result in a loss of image quality.
  • Windows Bitmap (.bmp) files. BMP is a lossless image format with no compression and optional alpha channel. This format should generally be avoided since it does not offer compression and has no redeeming benefits.
  • HDR (.hdr) files. HDR is a lossless image format with 32 bits of precision per channel. The R32F G32F B32F A32F internal texture format is used, and texture compression is not supported. This is a very expensive format (in terms of memory and performance) and should only be used where absolutely essential. Textures created in this format should be kept as small as possible (eg. 256-512 pixels wide and high) but at least 8x8 pixels wide and high.
  • PNG (.png) files. PNG is a lossless compressed image format with alpha channel support. This is the best choice where compatibility with older versions of Trainz is not required.
  • DDS (.dds) files. This has very limited support intended for specific internal purposes; it is not recommended that end-users utilize this format at the current time.

All images which comprise a given texture must have identical dimensions (width, height).

Source images should use the SRGB color space except where material-specific documentation indicates otherwise.

[edit] Notes on Image Editors

  • The Targa Exporter plugin shipped with some older versions of Adobe Photoshop is broken and silently corrupts or discards alpha channels; a free update is available which resolves this issue.
  • Some image editors do not support alpha channels on BMP files.
  • By default, Photoshop does not allow for explicit editing of the alpha channel in PNG images. There is a free plugin called SuperPNG which integrates better PNG support to enable saving and editing of PNG alpha masks.
  • ddsview is an open source image editor that can properly open all of the texture formats used by Trainz. This is an easy tool to quickly convert between PNG parameters and TGA parameters.

[edit] *.txt File Extension

Texture files have a ".texture.txt" name extension, however when a texture file is specified within a config.txt file or similar, the ".txt" must be omitted, leaving the ".texture" extension. For example, a texture file named grass.texture.txt is specified in a KIND Groundtexture config file using the syntax texture "grass.texture".

[edit] Use of Image Files in Place of Texture Files

Trainz previously supported using any supported image file type in place of a Texture file. TANE does not support this technique; a texture.txt file must be used.

Personal tools