Flora is the new detail rendering system by Procedural Worlds. Flora is currently a part of Gaia Pro and is in preview state. Flora allows you to display instanced indirect Terrain Details and Grass across all render pipelines, with rendering features like:
- PBR-based rendering
- multiple LODs per terrain detail item
- dither crossfading
- align to slope
- color variation
Please Note: Flora currently works best in the HD render pipeline. Running Flora in other rendering pipelines will work, but not all rendering features are available across all pipelines. We aim to extend Flora in the other pipelines to push what is possible graphically.
How Flora works
Flora works by looking at terrain splatmap or terrain detail data, and then rendering meshes as a replacement during runtime. This means it is not active during design time (when the scene is not running). During design time, the old terrain details from the unity terrain detail system will still be displayed. During runtime, Flora will kick in and start rendering the configured meshes in place of the old terrain detail system.
Flora "knows" what to render instead of the existing terrain detail configuration by setting up a component on the terrain. This component contains a list of Flora renderers - each of these renderers represent a vegetation / detail item that is rendered by Flora. If an item has multiple LODs (Level of Detail), it will appear in the list multiple times since each LOD is treated as an independent renderer with independent settings. This allows you to e.g. use a very rough grass mesh in the distance to save performance and a more detailed mesh as you come closer.
When you start runtime, Flora will create its own prototypes for instanced indirect rendering as childs of the terrain object. You will find the settings from the terrain tile mirrored in here. These prototypes are then rendered en masse in the scene, using the mesh and material defined in here, and according to the settings for density and so on.
If you decide to use Flora in your project, there are different ways to apply it to the Terrain: You can use the Gaia integration to make the Flora settings a fixed part of your Gaia spawner setup. When editing a terrain detail, you can also define which Flora settings should be used for this terrain detail during runtime.
In this way the Flora settings will be automatically be applied whenever the Gaia spawner is used on a terrain. These settings are then saved together with the spawner and can be applied to other terrains as part of the spawner / biome.
If you do not intend to use Gaia, you can also apply Flora from its own setup windows to an existing terrain. When you click the "Add Flora to Scene" button, Flora will read in the existing terrain detail configuration, and will set up appropriate Flora settings on the terrain.
Last but not least you can add the Flora component completely manually to the terrain and create the configuration without any form of automatism.
The following sections will detail the different methods of adding Flora to your scene.
How to use Flora from within the Gaia Spawner
When using Gaia, you can start by setting up your terrain detail item like you normally would when using the terrain detail system of unity. At the bottom of the resource settings you will find an additional checkbox to activate Flora for this terrain detail item. When activating this checkbox for the first time, this will set up a Flora configuration for the terrain detail item at hand.
The configuration for the Flora settings is saved in so-called "Scriptable Objects" and in regular unity materials in the Gaia User Data folder. The spawner and the flora terrain tile component will reference these scriptable objects & materials to read the settings from them, so you should never delete those!
With the buttons on the right side of the checkbox, you can quickly add or remove Flora to all spawn rules in this spawner, or reset the configuration:
- Enable All: Will enable Flora on all spawn rules that already have a Flora configuration. If there are spawn rules left that do not have a Flora config stored yet, it will offer to create one automatically for these items.
- Disable All: Will disable Flora in all spawn rules. Will also offer to remove the Flora component from the terrain.
- Autocreate Config: Will automatically create a config from the resource settings above to replace the existing configuration. This is the same process that happens when you initially activate the "Enable Flora System" checkbox.
- Reset Config: Will remove all existing config entries and create a new, empty LOD level
Please Note 1: If you were using a flat texture terrain detail before, Flora will set up a cross plane mesh and display this texture on the cross mesh by default as a replacement. While this will look better than the flat texture before, you will get better results when using actual grass model and a PBR texture set made for that purpose.
Here is a typical setup created from a texture terrain detail:
While this looks better than just a flat texture, it loses a lot of potential due to the partial setup. Here is a setup created with a proper grass model and a PBR texture set for comparison:
Much better results due to the more detailed model that can work with light and shadows much better, and the additional effects from the mask map and normal map. This brings us to another important point:
Please Note 2: You do not have to display the same item with Flora than the Unity Terrain Detail system does. Flora does replace the unity terrain detail item during runtime, so you can set up a more detailed model or something else entirely as replacement. You do not have to stick to the autogenerated config either.
If you are unsure about how to set up Flora correctly or you do not have any models ready, you can also use the preset configurations that come with Flora. Please see "Using Flora Presets" below.
Using multiple LODs
Flora allows you to create multiple LODs (Level of Detail) per vegetation item / terrain detail that you want to render. The LODs per spawn rule are displayed in a list that allows you to add / remove / reorder the different LODs:
- "+"-Button: Adds a new LOD below
- "-"-Button: Removes this LOD level
- "^"-Button: Moves this LOD level upwards in the list
- "˅"-Button: Moves this LOD level downwards in the list
You can control the distance at which a certain LOD level is displayed by adjusting the in and out distances of the respective items:
If you have two LODs where you would want LOD A to be visible up to 10 meters from the camera, and then LOD B to be displayed up until 50 meters, you would set up
In Distance 0
Out Distance 10
In Distance 10
Out Distance 50
With the In and Out "Fade" distances you can control how quickly the LOD is faded out. By creating some overlap with the in and out (fade) distances, you can create smooth transitions between LOD levels.
Please Note: From a technical perspective, Flora does not "know" that the LODs are supposed to be LODs - they only behave as such when you set up the rendering distances accordingly so that one LOD is replaced by the other. This means on the one hand that you need to be careful to set up sensible settings, on the other hand you have a lot of creative freedom over the display of the LOD elements, you can e.g. have a large overlap between the two rendering distances, or have increased density for the more detailed LOD etc.
Using Flora presets
Flora comes with readymade configuration presets for vegetation items that you can use in the Gaia spawner. You can find them in the directory
Assets > Procedural Worlds > Flora > Content Resources > Presets
These are readymade presets for Flora which each represent a certain grass / terrain detail item. To apply them to a LOD in your Gaia spawner, simply drag and drop them onto the configuration slot in the Gaia spawner:
Gaia then will prompt you if you want to work with the original settings file, or if you want a copy.
Usually you would want to copy the settings - this would not impact the original settings file so the preset will remain preserved with its original settings. But you can decide to work with the original instead to overwrite the settings if you wish to do so.
If you do not have your own vegetation models, those presets can be a great alternative to improve the default setup that Gaia creates out of texture terrain details - you can use these presets to override what Gaia has created to quickly improve the look of your Flora items.
How to use Flora from the Flora window
If you have an existing terrain that you just want to apply the Flora to without working with the Gaia spawner, you can do so best from the Flora Window. You can open this window via
Windows > Procedural Worlds > Flora > Flora...
The Flora manager window will open with the Setup Tab by default. From here you can add flora to your scene with a single click to the "Add Flora To Scene" button from the Setup Tab. This will add the terrain tile to the scene, but Flora will also offer you to autogenerate configuration entries from the unity terrain details on the terain.
You will also be prompted for shadows on the terrain details (which cost performance, but usually look better when you have proper models for your grass.)
The Global settings section controls a few general settings like the overall density of Flora that apply to all terrain tiles & renderers.
The "Add Flora Wind System" button is required if you have a wind zone in your scene, this will set up an additional component on the wind zone which will feed the information about the wind strength / direction into the Flora shader so the terrain details react to wind correctly. (If you use Gaia to create your wind zone this is not required, as Gaia has a similar system that already feeds the information into the shader)
The "Utils" Tab has additional tools to create your Flora setup:
The "Get Details Only" button will read in the existing detail data from the terrain again to turn them into Flora configurations. "Clean Up Missing Detail Renderers will look for Flora Renderer entries that lost their Flora configuration scriptable object and will remove those from the Flora component.
"Delete User Generated Data" will remove the scriptable object configuration files from the project hierarchy.
The "Drag and Drop Setup" box at the bottom of the window allows you to drag on textures and detail scriptable objects to create the renderer setup on the terrain tile component from it.
The Settings Tab contains all kinds of settings that control how Flora will auto-create its configuration.
If you need help with what a certain setting does, remember to click the help button in the top right corner that will display a description for each setting on the screen.
How to use / set up Flora completely manually
To use Flora on a terrain, simply add the "Flora Terrain Tile" component to the terrain. You can do this as with any other component.
The Source Camera and Terrain need only to be set if different from the current terrain and from the Main Camera. Flora then needs you to configure one Renderer each per Flora Detail Item you want to render.
The terrain cell count determines in how many cells a terrain is subdivided for rendering the items in the renderer list. Eight is a good value to start with, but depending on what items you render you can experiment with different subdivision counts to fine tune performance.
You can set those up manually by creating new Flora Detail Item Configurations in your project hierarchy from the "Create..." menu:
The detail scriptable objects that you created this way can be assigned as Flora Renderers:
Once the Flora Detail items have been configured, the items will be rendered during runtime based on the selected terrain and camera. The position data will be taken either from Splatmap / Texturing Data, or from the existing Unity terrain detail system. You can choose this for each Detail Item and assign the source index:
e.g. if it is set to "Detail" and 0, it would render the Detail Item that is defined in the Detail Scriptable object at the position of all Unity Terrain Details at Index 0, in other words "The first terrain detail on this terrain".
The "Sub Cell Division" is a value that determines how many additional sub-cells will be created for rendering this specific items. 8 Is a good starting point, together with the "Terrain Cell Count" you can experiment to fine tune performance.
Tuning your Flora setup during runtime
Once you have added Flora for with multiple renderers to your scene / terrain, you might find it time consuming to adjust all the settings in the scriptable objects. To quickly tune the settings for the flora renderers in one go, start your scene. Then select the Renderer Prototypes which are childed to your terrain object:
By clicking through them one after another while the scene is running, you can quickly adjust the settings for these renderers while seeing the direct impact in the game view:
The settings that you change this way will persist beyond Play Mode - this means you can go over all flora renderers in one pass, adjusting their settings with direct visual feedback from the game, and you will then keep your settings when you exit runtime.
Tip: To identify which item you are editing at the moment, try to check and uncheck the "Disable" checkbox repeatedly.