meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
impunity [2021/03/16 10:59] croftimpunity [2023/04/14 13:44] (current) steph.jorgensen
Line 1: Line 1:
 ======Importing into Unity====== ======Importing into Unity======
  
-SpeedTrees are supported in the [[https://unity.com/|Unity game engine]]. The .ST files exported by SpeedTree 9 can be imported with Unity 2018.3 or later. +SpeedTrees are supported in the [[https://unity.com/|Unity game engine]]. The .st files exported by SpeedTree 9 can be imported with Unity 2018.3 or later. 
  
-SpeedTrees work in the standard rendering pipeline, and shaders can be switched to work in the High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP). +SpeedTrees work in the standard rendering pipeline, and shaders can be switched to work in the High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP).
  
 +===== Version compatibility =====
  
-=====Exporting for Unity=====+^**SpeedTree Modeler version** ^ **Unity version** ^ **SpeedTree model file type** ^  
 +| 9.x | Unity 2018.3 and later (1) | .st | 
 +| 8.x | Unity 2018.3 and later (1) | .st | 
 +| 7.x | Unity 5.0 to Unity 2018.2.21 | .spm | 
 +<WRAP indent> **Notes:** </WRAP> 
 +  - Shader functionality improves substantially in Unity 2021.2.0a17 and later. See [[impunity#HDRP and URP|HDRP and URP]]. 
 + 
 +=====Pipeline to Unity===== 
 + 
 +{{ ::prefab.png?direct&200|}}
  
 Before exporting a tree for Unity, be sure that your tree is set up for real-time use by using [[kcgameslod|LOD]]. Also ensure that wind is correctly set for Unity by setting the fan to [[windlegacy|Legacy UE4/Unity mode]] and tuning the wind effects, if necessary. Before exporting a tree for Unity, be sure that your tree is set up for real-time use by using [[kcgameslod|LOD]]. Also ensure that wind is correctly set for Unity by setting the fan to [[windlegacy|Legacy UE4/Unity mode]] and tuning the wind effects, if necessary.
  
-If this is the first time exporting to Unity, be sure to pick one of the Unity presets in the [[expgame|export mesh dialog]], to ensure all the export settings are correct for Unity. Export an .ST file directly into the Assets directory of your Unity project. Be sure to wait until the export process is complete before switching back to Unity for the import. You can also export it to another directory and copy it into your Unity assets, but be sure to copy the mesh and all of the textures at the same time before switching back into Unity. Otherwise, the importer will not be able to find the textures. You may be prompted to fix normal maps after import, so select “Fix now” and the import process will continue.+If this is the first time exporting to Unity, be sure to pick one of the Unity presets in the [[expgame|export mesh dialog]], to ensure all the export settings are correct for Unity. Export an .st file directly into the Assets directory of your Unity project. Be sure to wait until the export process is complete before switching back to Unity for the import. You can also export it to another directory and copy it into your Unity assets, but be sure to copy the mesh and all of the textures at the same time before switching back into Unity. Otherwise, the importer will not be able to find the textures. You may be prompted to fix normal maps after import, so select “Fix now” and the import process will continue.
  
->**Note**: Do not simply choose import and pick the .st file from a different location. Unity will not be able to find the needed texture files.+Unity will create a SpeedTree prefab you can use as a GameObject, on the terrain, or in other places inside Unity. 
 + 
 +>**Note**: Do not simply choose import and pick the .st file from a location outside your assets. Unity will not be able to find the needed texture files.
  
  
 =====Placement===== =====Placement=====
-==Manual== 
-Adding models to the scene manually 
-To add models one at a time, simply drag the SpeedTree object from the “Asset browser” in Unity and drop it in the scene. The model can then be transformed like any other object in Unity. 
  
-It is important to note that rotating an instance of the asset is fineThe billboard shader will take the rotation into account when selecting the appropriate angle from the 360-degree billboard atlas.\\+The prefab created after import can be dragged into the scene and transformed like any other GameObject. While you probably want to keep the scaling uniform, it should be noted that rotating the object is allowedWind, LOD, and billboard facing will still work correctly on a rotated SpeedTree. 
 + 
 +SpeedTrees can also be painted on terrains similar to other mesh objects. On the tree tab of the terrain and click “Edit Trees”. Add the SpeedTree asset you wish to paint in the resulting dialog, and it will then show up in the “Trees” section. See [[https://docs.unity3d.com/Manual/SpeedTree.html|Unity's documentation on terrain SpeedTrees]] for more information. 
 + 
 +>**Note**: Grass SpeedTree assets are also painted using the "tree" tab, not with the Unity grass system. 
  
-==Painting models== +=====Wind=====
-SpeedTrees can be painted on terrains similar to other mesh objects. Go to the tree tab on the terrain and click “Edit Trees”. Add the tree asset you wish to paint in the resulting add tree dialog, and it will then show up in the “Trees” section. Grass assets are also painted in the "tree" tab, not with the Unity grass system.+
  
-After selecting the tree you wish to paint, you can adjust the painting tools with the parameters below it“Tree height” lets you control the scaling of the tree when paintedWith SpeedTrees, you most likely want to enable “Lock width to height” and “random tree rotation” for the best results (these are enabled by default).+Wind behavior is tuned inside of the SpeedTree Modeler. To see the animation in Unity, you must add a [[https://docs.unity3d.com/Manual/class-WindZone.html|Wind Zone]] to the scene to provide the wind sourceYou can add a Wind Zone as an individual objector as a component on another object. The wind zone allows you to edit the strength and direction of the wind effect.
  
-You can adjust the switch from 3D tree to a billboard with the “billboard start” and “fade length” parameters on the settings tab of the terrain.+>**Note**: You'll probably want to turn down the strength since the default is 1.0 (high wind)
  
-=====Adding a wind zone:===== 
-Wind behavior is tuned inside of the SpeedTree Modeler. To see the wind animation in Unity, you must add a 'Wind Zone' object to the scene. Use this object to set the strength and direction of the wind.\\ 
  
-To create a Wind Zone GameObject directly, go to Unity’s top menu and go to GameObject +=====LOD=====
- > 3D Object +
- > Wind Zone +
-. You can add the Wind Zone component to any suitable GameObject already in the Scene +
- (menu: Component +
- > Miscellaneous > Wind Zone). The Inspector for the Wind Zone has a number of settings to control its behavior. +
-Since the SpeedTree has been set with Unity wind before import, the tree will now interact.  +
->**Note**: You'll probably want to turn down the wind object to a moderate level since the default is 1.0 (high wind). +
  
-For additional help check out Unity's documentation. https://docs.unity3d.com/Manual/class-WindZone.html +Your [[kcgameslod|LOD behavior]] is set in the SpeedTree Modeler, but you can adjust when the LOD changes occur inside of Unity. The SpeedTree prefab includes a [[https://docs.unity3d.com/Manual/class-LODGroup.html|LOD Group]] with which you can adjust the LOD distances.
-\\ +
-=====Changing the LOD===== +
-Your LOD is set and written into the exported SpeedTree mesh, but you an adjust your assets LODs by using the "object inspector".Use this control to edit where the LOD transitions will occur by dragging the borders between LODs left and right.\\+
  
-For additional help check out Unity's documentation. https://docs.unity3d.com/Manual/LevelOfDetail.html 
  
 =====HDRP and URP===== =====HDRP and URP=====
  
-After import, the SpeedTree meshes will have materials attached to them for the standard rendering pipeline. They will appear pink (ie shader error) when using the HDRP or URP.+When using the Universal Render Pipeline (URP), there is a built-in shader for SpeedTrees that should work automatically as in the standard pipeline, though it is missing features like subsurface. With the High Definition Render Pipeline (HDRP), the SpeedTree meshes will have materials attached to them for the standard rendering pipeline. They will appear pink (ie shader error). You can switch to the standard Lit shader, or make your own in Shader Graph, though wind will no longer work
  
-Starting in Unity 2021, new shaders are available for SpeedTrees. Using the GUI on the SpeedTree prefab, extract the materials, and switch them to the new shaders: SpeedTree/HDRPLit and SpeedTree/HDRPLit_Billboard for HDRP or SpeedTree/PBRLit and SpeedTree/PBRLitBillboard for URP.+Starting in Unity 2021.2.0a17, new shaders are available for SpeedTrees. Using the GUI on the SpeedTree prefab, extract the materials, and switch them to the new shaders: SpeedTree/HDRPLit and SpeedTree/HDRPLit_Billboard for HDRP or SpeedTree/PBRLit and SpeedTree/PBRLitBillboard for URP.
  
 These new shaders are created in Unity's Shader Graph, so they will work in all aspects of those pipeline, even in areas that were troublesome before like subsurface. Being written in shader graph, they are also very easy to edit. If you wish to change the SpeedTree shaders, you can change the base shader graph to apply to all trees, or duplicate it for a new shader with your own modifications. These new shaders are created in Unity's Shader Graph, so they will work in all aspects of those pipeline, even in areas that were troublesome before like subsurface. Being written in shader graph, they are also very easy to edit. If you wish to change the SpeedTree shaders, you can change the base shader graph to apply to all trees, or duplicate it for a new shader with your own modifications.