Texture file

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(Image formats)
(anisotropy added)
Line 1: Line 1:
 
[[Texture file]]s are ASCII text format 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.
 
[[Texture file]]s are ASCII text format 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.
  
'''TODO: Merge [[.texture.txt Files]] page into this page.'''
+
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.
  
  
Line 43: Line 43:
  
 
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 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.
 +
 +
 +
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 No anisotropic filtering.  Valid values are integers
 +
"1" (default) - No anisotropic filtering, "2" - Low, "4" - Medium, "8" - High, and "16" - Very High
  
  
Line 63: Line 69:
  
 
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).
 
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).
 +
 +
 +
==Comments & Suggestions==
 +
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''.
 +
  
 
==Image formats==
 
==Image formats==

Revision as of 01:02, 23 August 2012

Texture files are ASCII text format 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.


Contents

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.


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 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.


Primary=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.


Compression=dxt1

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.


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 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. The option is applied by the Content Manager upon Commit. 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 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.


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 No anisotropic filtering. Valid values are integers "1" (default) - No anisotropic filtering, "2" - Low, "4" - Medium, "8" - High, and "16" - Very High


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.


MinFilter=linear

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.


MipFilter=linear

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.


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).


Comments & Suggestions

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.


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.

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.


.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".

Use of image files in place of texture files

Trainz has historically supported using any supported image file in place of a Texture file. This technique has obvious limitations and is no longer recommended.

Personal tools