SpeedTree 8 for Unity is now available as a subscription, indie, and full games license, bringing PBR goodness and advanced features to Unity 2018.3.  By default, SpeedTree will export with a material set up for the Standard pipeline, but still faces some challenges for those who want to use the beta High Definition Render Pipeline (HDRP) or Lightweight Render Pipeline (LWRP) pipeline.

Unity’s HDRP and LWRP bifurcate the engine into two preset scriptable render pipelines (SRP) and offer greater flexibility in customizing the Unity engine to fit your needs. While this solution provides many much-needed features, it’s not without its challenges. Each render pipeline requires a different material setup and these materials are still very much in development.

While we have plans for SpeedTree models to work with the Shader Graph, we do not currently have the ability to apply our vertex animated SpeedTree wind, hue variation, or smooth LOD transitions in any SRP, while the “Standard 3D” pipeline into Unity works generally as expected.  

We’re working with Unity to continue to develop the Unity Integration and hope to have a stable solution soon.

But don’t panic, we have a few tricks for getting a SpeedTree up and running in HDRP right now. A few important notes first:

Texture Changes

1. HDRP Mask Texture:  HDRP uses a different mask than our standard Unity packing option (read more here).

2. Thickness Map: Transmission (used for thin translucent objects) in HDRP uses a thickness map to evaluate depth on flat planes.  To output a thickness map, we simply export our subsurface as a grayscale texture (read more here).

Alternate Packing

1. We made an additional packing option that can be dropped your installation folder (SpeedTree Games 8.3 -> texture_packing).  

2. On export, be sure to select Unity HDRP for the texture packing type.

Download new packing option: Untiy(HDRP).zip

Importing the SpeedTree

Either export the SpeedTree Model directly into your Unity project’s asset folder or copy the files into the project folder once complete.

The first step to prep the tree for HDRP is to make sure that your textures are the right file type.  While Unity will automatically detect and offer to fix the normal maps, mask and thickness need a few quick adjustments.

For thickness, we export a single channel subsurface map that can be used for thickness.

Thickness Map (labeled subsurface)

  1. Set to “single channel”.
  2. Set channel to “red”.
  3. Apply changes.

Mask Map:

  1. Uncheck SRGB.
  2. Apply changes.

Converting the Materials

  1. Select the SpeedTree model and export the materials.
    • Once selected, switch to the “materials” tab in the inspector window.
    • Export the materials into the folder of your choice.  The same folder as your textures seems like a good place for it.
  2. Select all the materials and switch them to “standard” this will most of the texture connections and save you a few steps.  
  3. Select Edit-> Render Pipeline -> Upgrade selected materials to high definition materials.
  4. Hey, now there’s a tree!
  5. By default, it will extract one material per LOD.  You can delete the extra LOD materials and reassign the remaining under “remapped materials”.

Setting up Bark and Branches

  1. Select the bark material.
  2. Add the mask texture to “mask map”.
  3. From here, you may need to adjust the remapping of smoothness, AO, and thickness to get the absolute best results.

Setting up Leaves and Billboards

  1. Select the leaf/billboard material and apply the following settings:
    • Enable alpha cutoff.
      • Set the alpha cutoff to 0.333.
      • Check “double-sided”.
    • For normal mode choose “mirror”.
    • Change the material type to “translucent”.
  2. Add the mask texture to “mask map”.
  3. Add the thickness map and set the diffusion profile to “foliage”.
  4. Although from here, you may need to adjust the remapping of smoothness, AO, and thickness to get the absolute best results.

Adjusting the SSS Diffusion Profile

Unity employs a lightweight subsurface and transmission technique (outlined here) that relies on diffusion profile settings to control the lighting parameters.  

You can grab the diffusion profile from the Book of the Dead asset, or create one from scratch by right-clicking in the project window and selecting create -> rendering -> diffusion profile settings.

Then connect the diffusion profile to your HD render pipeline asset.

The sample diffusion profile that comes with an HDRP with extras project includes sample foliage and skin profiles.  We made a few tweaks but ended up some with a setting fairly close to the one used in the Book of the Dead.

Important notes:

  1. The Book of the Dead shader has some custom scripts to add direct/indirect scale. If you notice it missing in your settings, that’s why. I recommend reading more about the development on the Unity blog.
  2. With how Unity handles diffusion, barks in your atlas may show some subsurface even if it’s blocked out.  If you’re using one draw call trees it’s important to keep this in mind when setting subsurface on your materials.
  3. Remap your materials to match your lighting.  Depending on your project some assets may require a bit more lighting, especially grass assets.  As pointed out in the Book of the Dead project, sometimes what looks correct is not physically correct. Don’t be afraid to tweak and play with the settings.

SpeedTree 7 Library Assets

The method outlined above will work for any SpeedTree 7 assets that have been opened and re-exported in with the SpeedTree 8 modeler.  However, be aware that these assets don’t have PBR materials by default, although you can certainly add additional textures yourself.