Effect Layer Assets

From TrainzOnline
Revision as of 21:10, 18 December 2018 by N3vpolsen (Talk | contribs)

Jump to: navigation, search

Contents

Creating TurfFX Assets

Surveyor

Find out how to use Turf Effects (turffx) in surveyor


Asset Files

This section provides help with setup of your individual turf asset (config.txt and textures).

Turfassetfiles.jpg


Asset Textures

Turf requires an albedo, normal and parameters set of texture files.


Albedo Texture

RGB: The albedo map defines the base color of each texel. The sRGB color space is used.

A: The alpha channel provides a "black and white" masked alpha channel. Black indicates full transparency, meaning that the fragment is discarded. White indicates full opacity. Transparency will always cost more performance than a full opaque blade of turf so where possible try and reduce the amount of transparency in your texture.

Turfassetalbedo.jpg Turfsubtexturealbedo.jpg

NOTE: the texture will be divided into 4 even sized sub-textures within the texture atlas. For example, if you have a 512x512 texture then the turf system will use 4 x 256x256 textures. If the texture atlas is 256x32 then the 4 sub-textures will be 128x16.


Normal Texture

RGB: Surface normal map. This defines which way the surface is facing, relative to the interpolated vertex normals. Since this is an XYZ format rather than color data, it should never be modified in Photoshop. Using Photoshop to add a fourth channel or copy/paste smaller textures into a texture atlas is acceptable. Per-pixel manipulation or use of filters on the "RGB" channels is not acceptable.

A: Average Ground Color Tinting. 0.0 avoids any color tinting from the minimap, while 1.0 tints each blade of grass with whatever ground texture minimap color it is positioned on top of.

Turfgroundcolor.jpg

Turfassetnormal.jpg Turfsubtexturenormal.jpg

NOTE: the texture will be divided into 4 even sized sub-textures within the texture atlas. For example, if you have a 512x512 texture then the turf system will use 4 x 256x256 textures. If the texture atlas is 256x32 then the 4 sub-textures will be 128x16.


Parameters Texture

This texture is the same as any other parameters texture in the new PBR materials format. See m.clutter or m.pbrmetal for an example of a parameters texture.

Turfassetparameters.jpg Turfsubtextureparameters.jpg

NOTE: the texture will be divided into 4 even sized sub-textures within the texture atlas. For example, if you have a 512x512 texture then the turf system will use 4 x 256x256 textures. If the texture atlas is 256x32 then the 4 sub-textures will be 128x16.


Asset Config.txt

 kuid                                    <KUID>
 kind                                    "turffx"
 username                                "NAME"
 trainz-build                            4.6
 category-class                          "FF"
    
 season-turffx
 {
   0
   {
     albedo-texture                      "summer_albedo.texture"
     normal-texture                      "summer_normal.texture"
     parameters-texture                  "summer_parameters.texture"
     num-control-points-per-blade        3
     density-clamp-far                   500
     density-clamp-near                  0
     density-compensation-max            2
     density-falloff-power               6
     edge-offset-far                     0,0,0,0
     edge-offset-minimum                 0.004
     edge-offset-near                    0,0,0,0
     smoothness-clamp-far                20
     smoothness-clamp-near               0
     smoothness-falloff-power            2
     tessellation-level-far              1
     tessellation-level-near             16
         
     blade-control-points
     {
       0                                 0.02,0.7,0.1
       1                                 0.63,1.25,0.6
       2                                 1.1,1.15,0.95
     }
   }
    
   1
   {
     albedo-texture                      "winter_albedo.texture"
     normal-texture                      "summer_normal.texture"
     parameters-texture                  "summer_parameters.texture"
     num-control-points-per-blade        3
     density-clamp-far                   500
     density-clamp-near                  0
     density-compensation-max            2
     density-falloff-power               6
     edge-offset-far                     0,0,0,0
     edge-offset-minimum                 0.004
     edge-offset-near                    0,0,0,0
     smoothness-clamp-far                20
     smoothness-clamp-near               0
     smoothness-falloff-power            2
     tessellation-level-far              1
     tessellation-level-near             16
         
     blade-control-points
     {
       0                                 0.02,0.7,0.1
       1                                 0.63,1.25,0.6
       2                                 1.1,1.15,0.95
     }
   }
       
   2
   {
     albedo-texture                      "winter_albedo.texture"
     normal-texture                      "summer_normal.texture"
     parameters-texture                  "summer_parameters.texture"
     num-control-points-per-blade        3
     density-clamp-far                   500
     density-clamp-near                  0
     density-compensation-max            2
     density-falloff-power               6
     edge-offset-far                     0,0,0,0
     edge-offset-minimum                 0.004
     edge-offset-near                    0,0,0,0
     smoothness-clamp-far                20
     smoothness-clamp-near               0
     smoothness-falloff-power            2
     tessellation-level-far              1
     tessellation-level-near             16
   
     blade-control-points
     {
       0                                 0.02,0.7,0.1
       1                                 0.63,1.25,0.6
       2                                 1.1,1.15,0.95
     }
   }
 }
    
 season-selector
 {
   above-snow-line                       1
   
   branch-true
   {
     output-season                       2
   }
   
   branch-false
   {
     season-range                        0.25,0.75
   
     branch-true
     {
       output-season                     1
     }
   
     branch-false
     {
       output-season                     0
     }
   }
 }
    
 thumbnails
 {
   0
   {
     image                               "screenshot.jpg"
     width                               240
     height                              180
   }
 }
    
 kuid-table
 {
   0                                     <KUID>
 }


Asset Config.txt Breakdown

Let's break it all up and step through it line by line:

First declare the normal config.txt tags. You must use a "turffx" kind and the trainz-build number must be 4.6 or above.

 kuid                                    <KUID>
 kind                                    "turffx"
 username                                "NAME"
 trainz-build                            4.6
 category-class                          "FF"


Next you will want to start the main season-turffx container. This container provides a lot of configuration for your turf asset.

 season-turffx
 {


Container "0" is for the season summer in this example. (see the "season-selector" below for clarification on this). We will also use container "1" for winter and "2" for above the snowline.

   0
   {


We declare our summer textures here.

     albedo-texture                      "summer_albedo.texture"
     normal-texture                      "summer_normal.texture"
     parameters-texture                  "summer_parameters.texture"


You now need to determine if you will be using 2 or 3 control points to generate your turf blades. We will define a set of control point values to generate blades from in the "blade-control-points" container below. For further explanation of 2 vs 3 control points scroll down to "blade-control-points" to see an image that explains this further.

     num-control-points-per-blade        3



Turfedges.jpg

Edge profile offset relative to strand shape (m).

Defines edge offset along the normal in meters relative to the center of the grass blade.

So basically, you can add a crease in the center of each blade. You can control root, mid low, mid high, tip.

4-component vector.

Per grass zone.

     edge-offset-near                    0,0,0,0

Edge profile offset relative to strand shape (m).

4-component vector.

Per grass zone.

     edge-offset-far                     0,0,0,0

If edge profile is lower than this, it would be zero.

If an absolute interpolated edge offset value is less than a minimal threshold, edge offset would be zero. Offset threshold should be used to simplify the blade at a distance where edge offset doesn't affect visuals.

In other words, use this to turn off crease rendering in the distance to save polygons.

Per grass zone.

     edge-offset-minimum                 0.004



Smoothness = pow(max(1.0 - clampedDistance / smoothnessClampFar, 0), smoothnessFalloffPower)

Smoothness falloff is used for a linear interpolation between near and far per-blade parameters. Near value would be chosen for smoothness = 1, far for smoothness = 0.

Per grass zone.

     smoothness-clamp-near               0


Per grass zone.

     smoothness-clamp-far                20


Per grass zone.

     smoothness-falloff-power            2



Turftessellation.jpg

"Number of subdivisions along the strand"

Tessellation controls subdivision along the blade. Valid values should lie in the interval [1, 64].

Per grass zone.

     tessellation-level-near             16


Per grass zone.

     tessellation-level-far              1




This is an array of (2x or 3x (3-component-vector)) depending on what you defined in your "num-control-points-per-blade" tag.

Control points define the global shape variation for a particular grass type. Currently there are only two options: grass blades with 2 and 3 user-defined control points. For example with 2 user- defined points there is a root point and 2 extra points (with coordinates relative to root) which form each blade. An asset stores an array of those 3d control points where each pair corresponds to a separate grass blade(they are assigned in round- robin manner) . Also there is no need to vary the rotations as those are automatically added by the library. You can start with a single blade and later add as many as needed to create a variety of shapes."

Per grass zone.

     blade-control-points
     {
       0                                 0.02,0.7,0.1
       1                                 0.63,1.25,0.6
       2                                 1.1,1.15,0.95
     }

Turfpointcontrol.jpg


   }
 }


Container "1" and "2" are seasonal containers.

1 = winter

2 = above snowline

in this example asset. You can use the same tag values that are declared in container "0" or you can create new values for the other seasonal containers. You'll most likely want to change the textures (at least the Albedo) if anything like we have done in this example.

   1
   {
     enable-high-lod                     0
     albedo-texture                      "winter_albedo.texture"
     normal-texture                      "summer_normal.texture"
     parameters-texture                  "summer_parameters.texture"
     num-control-points-per-blade        3
     density-clamp-far                   500
     density-clamp-near                  0
     density-compensation-max            2
     density-falloff-power               6
     edge-offset-far                     0,0,0,0
     edge-offset-minimum                 0.004
     edge-offset-near                    0,0,0,0
     smoothness-clamp-far                20
     smoothness-clamp-near               0
     smoothness-falloff-power            2
     tessellation-level-far              1
     tessellation-level-near             16
         
     blade-control-points
     {
       0                                 0.02,0.7,0.1
       1                                 0.63,1.25,0.6
       2                                 1.1,1.15,0.95
     }
   }
   
   2
   {
     enable-high-lod                     0
     albedo-texture                      "winter_albedo.texture"
     normal-texture                      "summer_normal.texture"
     parameters-texture                  "summer_parameters.texture"
     num-control-points-per-blade        3
     density-clamp-far                   500
     density-clamp-near                  0
     density-compensation-max            2
     density-falloff-power               6
     edge-offset-far                     0,0,0,0
     edge-offset-minimum                 0.004
     edge-offset-near                    0,0,0,0
     smoothness-clamp-far                20
     smoothness-clamp-near               0
     smoothness-falloff-power            2
     tessellation-level-far              1
     tessellation-level-near             16
     
     blade-control-points
     {
       0                                 0.02,0.7,0.1
       1                                 0.63,1.25,0.6
       2                                 1.1,1.15,0.95
     }
   }


We then add a "Season-selector" container so we can declare what contain 0, 1 and 2 represent.

 season-selector
 {
   above-snow-line                       1
   
   branch-true
   {
     output-season                       2
   }
   
   branch-false
   {
     season-range                        0.25,0.75
   
     branch-true
     {
       output-season                     1
     }
   
     branch-false
     {
       output-season                     0
     }
   }
 }


We need a thumbnail for this asset so we add that.

 thumbnails
 {
   0
   {
     image                               "screenshot.jpg"
     width                               240
     height                              180
   }
 }


Finally, we add the kuid-table and the clutter-asset kuid(s).

 kuid-table
 {
   0                                     <KUID>
 }

Example Assets

Short Straight Grass: Download Asset

Long Curved Grass: Download Asset


Opaque Grass: Download Asset (CDP)

Opaque Grass: Download Asset (ZIP)


Alpha Masked Grass: Download Asset (CDP)

Alpha Masked Grass: Download Asset (ZIP)

Hardware Limitations

TurfFX is developed by NVIDIA and is designed to takes advantage of high-end GPU's with substantial amounts of VRAM.

1. TurfFX is currently supported only for Windows.

2. Whereas Trainz will typically run (albeit slowly, or at reduced settings) on below-spec computers, TurfFX will need to be disabled entirely if the GPU is insufficient. We expect the minimum of a GeForce GTX 750 to get reasonable performance.

3. With TurfFX disabled, the Effect Layers are ignored entirely, and there is no performance penalty for those objects that are disabled.

See Also

Clutter_Effect_Layer

Back to Effect_Layer

Personal tools