Physically Based Rendering

From TrainzOnline
Jump to: navigation, search



Physically Based Rendering (PBR) is a collection of guiding principles under which a fragment shading pipeline should operate to provide current-generation lighting results. Many guides exist online which explain the concept in far more detail than this document. Simplified to the extreme, this can be summarised as follows:

  • Conservation of Energy. The maximum level of light output may not exceed the level of light input. Material inputs and lighting equations must be defined in terms which do not violate this principle.
  • Lighting calculations are performed in linear space, but inputs and outputs are defined in sRGB space.

PBR is not a singular technique or equation. There are some common approaches which are seen across many renderers, but the exact details may differ. PBR materials are typically heavily parametric at the per-pixel level, and require less tuning at the per-material level, but specific effects still require specific shaders. We are not at the stage where a single shader can achieve every desirable outcome. TRS19 implements a metal-roughness workflow.

Note: The final conversion from linear to sRGB space is currently performed by our tone-mapping post-process shaders. Since this step is effectively essential, TRS19 no longer offers the ability to fully disable post-processing. Higher-end post-processing effects may still be disabled at the expense of visual quality.


  • Trainz prior to TRS2004 offered fixed-function per-vertex lighting.
  • Trainz prior to TANE offered per-vertex lighting with basic shader support for normal mapping etc.
  • TANE offered per-pixel HDR lighting which directly emulated the lighting techniques of earlier versions.
  • TRS19 offers PBR lighting equations, which require different inputs and produce different outputs from the earlier techniques.

As such, TRS19 will not look identical to the earlier products given the same inputs. In most cases, it should look somewhat similar, but there will be differences in the details. Specular lighting will be more pronounced and better looking. Overall lighting should be more balanced. The scene will most likely be more contrasty by default but no particular element should stand out as being out-of-place.

For existing materials which do not offer the necessary inputs to the PBR lighting equations, we make educated guesses as to appropriate values. These are tuned based on what we think looks good in a wide range of scenarios, not necessarily what looks best in a single scenario. If a content author does not like the outcome of the automatic upgrade, they should update their models to use PBR materials and tune them appropriately.

PBR materials are not available to IM files. trainzmesh files (via the FBX file format) should be used for any models which are to utilise PBR materials.

Content format v4.6 is required for PBR material support.

Additional Reading

The following online references offer a good start in understanding PBR and the metallicity-roughness workflow.

Material Types

Trainz offers a number of different PBR material types. m.pbrmetal is the most common and is a sensible starting place for new creations. Other material types offer custom functionality which may be useful in specific cases.

Personal tools