Table of Contents

Environments

Environments define the sun light, atmosphere, water coloring and skybox. The configuration is done in .lua files, which lay in the res/config/environment/ folder. They basically look like this:

function data()
  return {
 
    light = {...},
 
    atmosphere = {...},
 
    water = {...},
 
    skyBox = {...},
    skyRotation = .0,
  }
end

Light

The light block consists of several properties:

Atmosphere

In the real world, the atmosphere usually has a blue sky at daylight and some red colors in the morning and evening at dawn and sunset. This is caused by the rayleigh scattering phenomena. The atmosphere block contains several properties which are used to simulate a similar effect in the game:

It is recommended to use the ingame debug tools to experiment with the values.

Water


less and more intense waves

The water effects are adjusted with the properties in the water block:

Most of the properties for water effects can be controlled with the ingame debug tools too.

Sky

There are two further properties to control the sky that is shown as a background of the game world. The skyBox.texture property is a reference to the skybox hdr dds texture. This may either be a single file or six seperate files for the six sides of the box with the suffixes _1 to _6. With skyRotation, it is possible to rotate the skybox from -180 to 180 degrees. This turns around shadow drop too.

To get a lighting setup that matches the skybox, the provided EnvironmentMapConverter tool can be used. Use an HDR image file with an equirectangular projection of a skybox with an aspect ratio of 2:1. Make sure the hdr file has a high dynamic range (Multi EV) that is unclipped. The upper half 1 should contain the sky. Normally the portion above the horizon 2 is visible ingame. The other half of the skybox is visible when the player looks from above onto the map and the map edges are visible in the viewport. Therefore terrain 3 in the HDR file should be replaced by sky as well. Follow the steps below to setup the skybox:

  1. Drag the file onto the bat to execute the tool once. It will generate a skybox.dds, sun.dds and shadow.dds file next to the hdr file. Additionally the console output tells you the values for the sun direction, color and reference brightness.
  2. Put the dds files into your mod and adjust the references and values in your environment config if needed.
  3. Start the game with your mod loaded.
  4. Position the camera approximately 50 meters above ground in an urban area.
  5. Use the Camera Tool to generate a environment cube map with the skybox loaded. You can find the generated files in the screenshot folder in your userdata directory.
  6. Drag these 6 files onto the bat file to execute the second run.
  7. Put only the sun.dds and shadow.dds file into your mod and keep the skybox.dds from the first run.
  8. Repeat the last 5 steps until you have a satisfying result.

The skybox conversion tool is only available for Windows. You can download it here: EnvironmentMapConverter.zip.

Unpack the zip archive to the installation directory of Transport Fever 2 so that the environment_map_converter folder is next to the model_editor folder.

To use the tool, drag the hdr files onto the generate_testing.bat to generate a skybox with low resolution for testing purposes. To generate high resolution skyboxes, use the generate_production.bat instead. Be aware that it needs way longer to process the high resolution files.

Be aware that the results of the skybox tool may not be satisfying if the sun is hidden behind clouds or is too dark in general. This might result in missing shadows.