Use of 'Hint=Dynamic' in a .texture.txt file

TrainzDev

New member
A number of content creators are still using .texture.txt files containing the line:

Code:
Hint=Dynamic

This 'hint' value tells Trainz that this texture is expected to be modified in memory while the game is running. This has been used to produce a number of effects in Trainz history, but importantly there has never been a mechanism provided by Trainz for a content creator to make any use of this effect.

However, it does have a number of side effects:
  • It will slow down the rendering cycle. As the game considers that the texture may be modified in memory, it keeps it in shared memory, not in dedicated graphics RAM. The graphics card must then access it from system memory every frame. The impact of this will depend on the texture size, and is worse for large textures.
  • It disables mip-map generation. This is because re-generating mip-maps every time the texture was modified in memory would be impractical.

If you encounter this line in a .texture.txt file while working on an asset, your best course of action is to remove it. In a lot of cases, the line is merely there in the .texture.txt file by accident, having been copied and pasted from a previous file. In a few other cases, the line has been intentionally introduced by a content creator. Either way, it is generally not necessary to replace it with anything else.

If the texture is used as part of a 2D user interface element, you may find that the use of mip-mapping can lead to blurred looking images. If you are experiencing this problem, use this line instead:

Code:
MipFilter=none

This will completely disable the generation of mip-maps, and textures used in the user interface (e.g. "art_icon" images) will remain sharp. However, it doesn't introduce the slowdown that using Hint=Dynamic does.

Disabling mip-mapping for a texture used in the 3D world does work, but results in a poor quality image. You will get poor appearance, with obvious aliasing, moire patterns and also other artefacts.

If this texture config option has been used in the 3D world, it has generally been used in a misguided attempt to increase the "sharpness" of a texture when applied to a plane that is often viewed at an acute angle, e.g. to combat vertical blurring when looking along the side of a rake of carriages. This should instead be improved by increasing the 'Anisotropy' settings using the in-game slider. Trainz defaults to generating sufficient mip-maps for all Anisotropy levels now, so no changes are necessary to .texture.txt files for Anisotropy support; unfortunately the in-game slider still defaults to the lowest level though, so you will need to drag it up to a higher level.

For full documentation on the contents of a .texture.txt file, see the texture file Wiki page which documents all the usable options.
 
Worth noting that in addition to looking worse, disabling mip-mapping can hurt performance because the GPU needs to load and sample the full-resolution texture even for distant objects, whereas when mipmaps are used, the high-detail textures can be selectively ignored or even unloaded.

chris
 
A question for you Chris (and James) - is the Hint=Dynamic problem (as it seems to be) likely to be included as a warning/error in future hotfixes/service packs?

Shane
 
shaneturner12;bt2942 said:
A question for you Chris (and James) - is the Hint=Dynamic problem (as it seems to be) likely to be included as a warning/error in future hotfixes/service packs?

That depends. If content creators stop using it inappropriately, then we don't need to take any further action. On the other hand, if it continues to be abused, then we may have to do something. That something might include the creation of a warning and/or error.
 
You will get poor appearance, with obvious aliasing, moire patterns and also other artefacts.
But we still have aliasing with any alpha-masked textures ! And it makes the edges black of any masked texture!



Main shorcomings of MipFilter=none are:

1) low perfomance
2) patterns
3) flickering

But bad appearance we have with any masked texture.

Also it'll be better to have intermediate stages between MipFilter=linear and MipFilter=none , called "lod bias". May it be in new version :) .
 
TRam__;bt2979 said:
But we still have aliasing with any alpha-masked textures ! And it makes the edges black of any masked texture!


First, try adjusting the size of the texture with the LOD steps so it remains close to one pixel per pixel. This will result in the texture being used closer to full resolution, which will cut down on the black edges.

Note that this is not a general rule - for textures with alphablended textures or no alpha, you are better off using a single texture across all the LOD levels if you can get away with it.

Failing this, you might wish to consider if the use of a different DXT compression algorithm. Content Manager autodetects the right kind of compression based on the texture contents, so it's generally best not to mess with it. But in specific cases, it's worth a try. For a texture with an alpha channel with hard edges, you might wish to try DXT3 instead of the default of DXT1a. To do this, add the following line to the .texture.txt file:

Code:
Compression=DXT3

DXT3 isn't as good at compressing texture as DXT1a is, so the resulting compressed texture will be twice the size. This means somewhat lower performance, particularly if graphics memory is tight. But the DXT3 compressed texture won't suffer the black outlines that DXT1a can exhibit.

 
If it doesn't have a purpose.
there has never been a mechanism provided by Trainz for a content creator to make any use of this effect

Why is it even parsed?

hint=dynamic should have the same effect as hint=foobar....
 
you might wish to consider if the use of a different DXT compression algorithm. Content Manager autodetects the right kind of compression based on the texture contents, so it's generally best not to mess with it. But in specific cases, it's worth a try. For a texture with an alpha channel with hard edges, you might wish to try DXT3 instead of the default of DXT1a. To do this, add the following line to the .texture.txt file
Thanks a lot, TrainzDev, it works :) . I have been struggling it for ages and now it is solved!

 
Last edited:
frogpipe;bt2984 said:
If it doesn't have a purpose.

Why is it even parsed?

hint=dynamic should have the same effect as hint=foobar....

I didn't say it doesn't have a purpose.

I said it doesn't have a purpose that 3rd party content creators have access to. To do anything with this support, native code needs to be added to Trainz to do something with it. Content creators can't do that -- but that's not to say that we haven't made use of it in the past, or won't do so again in the future...
 
Well if it had a purpose before, but doesn't now, shouldn't the current version of Trainz (and which ever other versions don't use this tag) contain the equivalent of:

Code:
if (hint == "dynamic") break;

??
 
frogpipe;bt2992 said:
Well if it had a purpose before, but doesn't now, shouldn't the current version of Trainz (and which ever other versions don't use this tag) contain the equivalent of:

Code:
if (hint == "dynamic") break;

??

Again, I didn't say that there aren't internal N3V uses for it now. Just that 3rd party content creators don't have a way to make any use of it.
 
frogpipe;bt2995 said:
This is what confuses me. A texture is a texture regardless of source, no?

Exactly.

The texture loader is from Jet. It doesn't know about Trainz assets, the Trainz filesystem structure, the contents of a config.txt file, or anything like that. It is just loading a texture. What it can do is parse .texture.txt and .texture formats and load textures into memory. So there is a tag to tell it to enable this very specific case where the application written on top of Jet wants to modify the texture in memory. That tag is the 'Hint' tag.

Trainz has made use of that feature, but only in very limited circumstances. Trainz does not provide a way for third party content creators to use this functionality.

The Jet texture loader has no knowledge of what Trainz may or may not do with the texture later on, so cannot selectively ignore the vast majority of the (ab)uses of this tag, while still allowing a handful of legitimate cases through.

Clearer now?
 
Actually, yes. Thank you for that description. I hadn't considered Jet and Trainz as codependent but separate entities.
 
Back
Top