Go to Gallery           Register for MyTrainz | Login to MyTrainz

Crossfade LOD Transitions for Clutter Effects

By Admin, November 09 2017

Crossfade LOD Transitions for Clutter Effects

Making good level of detail ( LOD ) even for a professional artist can be hard work. You’ve got to try and make each LOD transition look very similar to the previous LOD transition while taking into account the distance at which that LOD will be shown on the screen.

The standard LOD system in Trainz simply swaps one mesh for another at certain transition points. Take the following rock asset:

LOD0 mesh has 2k polys and is rendered from 0 to 10 meters.

LOD1 mesh has 1k polys and is rendered from 10 to 20 meters.

LOD2 mesh has 400 polys and is rendered from 20 to 30 meters.

LOD3 mesh has 100 polys and is rendered from 30 to 500 meters.


 

With the standard Trainz LOD system you couldn’t normally be as aggressive with the distances mentioned above, as the change would be too noticeable given the changes in the meshes. For the TRS18 clutter effect, we offer new crossfade LOD transitions which mask any obvious mesh swaps by fading one mesh into the other over a certain distance.


 

From the wiki:

m.clutter is a variation on the m.pbrmetalmasked material. It adds controlled fade distances which are intended to allow cross-fading between LODs.

Cross-fading is expected to increase the cost of each LOD, but improve the visual transitions. The intent is that transitions can occur much closer to the camera, saving performance overall. If your use-case does not allow transitions to occur close to the camera, you may find that this material type is inappropriate for your needs. The typical use case is something which is small and heavily repeated in the scene, which requires high detail (eg. 100-500 polygons) at very close ranges (eg. up to about 10m) after which it can rapidly lose detail (eg. 500->100->10 or 100->25->5).

Cross-fading is implemented by using two different instances of this material per LOD level; one configured to fade out starting at a certain distance, and the other configured to fade in starting at the same distance. The nearer material is considered a higher LOD and should use more polygons. The asset might then be configured as follows:

  • LOD0 - 0 .. 20m - Material A (no fade in, fade out begins at 10m) using 500 polygons. Material B (fade in begins at 10m, no fade out) using 100 polygons. Totals: 2 materials, 600 polygons.
  • LOD1 - 20 .. 50m - Material C (no fade in, fade out begins at 35m) using 100 polygons. Material D (fade in begins at 35m, no fade out) using 20 polygons. Totals: 2 materials, 120 polygons.
  • LOD2 - 50m .. 250m - Material E (no fade in, fade out begins at 200m) using 20 polygons. Totals: 1 material, 20 polygons.

The same asset with a traditional material and no cross-fading might be as follows:

  • LOD0 - 0 .. 50m - Material A using 500 polygon mesh. Totals: 1 material, 1 mesh - 500 polygons.
  • LOD1 - 50m .. 150m - Material A using 100 polygon mesh. Totals: 1 material, 1 mesh - 100 polygons.
  • LOD2 - 150m .. 400m - Material A using 20 polygon mesh. Totals: 1 material, 1 mesh - 20 polygons.

Assuming an object density of one instance per 10m x 10m tile, the two approaches give approximately the following numbers:

  • Cross-faded: 7540 + 7917 + 37699 = 53156 polygons, 5 draw calls (due to 5 materials in use).
  • Traditional: 39270 + 62832 + 86393 = 188495 polygons, 5 draw calls (due to 3 materials in use, two of which require two chunks due to excess vertices).

Please note that this technique requires explicit work by the creator. It's not hard to use, but you do need to provide appropriately configured meshes. It's also only available on the m.clutter material (used for the Clutter Effect Layer) at this time.

For more information on future Trainz development be sure to keep up-to-date at http://trainzportal.com or see all the articles and have your say forums.