User Tools

Site Tools

Urban Games

modding:shaders

Shaders

Shaders are small data processing programm snippets that are used by the GPU to calculate what is drawn on the screen. This covers the 3D meshes as well as textures. Beside the lighting and shadowing, atmospheric effects like the reyleigh scattering, light emission and other effects are realized with shaders too.

There are several graphics libraries on the market, that can be used as standardized APIs for graphic visualization. The most common are DirectX® and OpenGL®. Transport Fever 2 uses the OpenGL® 3.2 Version and the shaders are programmed in the OpenGL® Shading Language Version 1.50. As MacOS is discontinuing the support of OpenGL®, the Vulkan® Graphics API was introduced in late 2020. The shaders are still programmed with GLSL 1.50 but use some macros for the definitions of in- and outputs.

Each shader actually is a pipeline of several shader stages. Usually, these are:

  1. Vertex shaders that run once for each vertex of each triangle (where you can do some computation and vertex transformation).
  2. Geometry shaders that compute additional geometry (where the smoke, tree billboards and grass geometry is added).
  3. Fragment shaders that run for each pixel (where you can control stuff like pixel color, lighting etc.).

For Transport Fever 2, the shaders are located in res/shaders/. The vertex shaders .vs, geometry shaders .gs and fragment shaders .fs are compiled by the game on load to be used ingame. To recompile them after some changes, use AltGr + R ingame.

Currently, it is hardcoded which shaders and subshaders exist for Transport Fever 2. A list of existing shaders can be found below. It is possible to override the contents of each shader file with mods by providing a file with the same filename though. Be aware that the inputs and outputs of the shaders are currently not changeable either.

Shaders in Transport Fever 2

There are five groups of shaders:

  • Material shaders for the different material types.
  • Terrain shaders for the terrain textures and grass plants.
  • UI shaders for data layers.
  • HDR shaders for lighting effects.
  • Misc shaders for ambient occlusion and smoke effects.

A list of all shaders and shader files can be found in res/shaders/shaders.txt. Every line is a shader pipeline where the files for the subshader stages can be found listed behind.


modding/shaders.txt · Last modified: 2020/12/14 16:53 by ug