Foliage Surface
Main MonoBehaviour component.
You can have many surfaces on scene, but in most cases you will have one, main surface for entire environment.
To create new surface, simply add new, empty game object at the middle of your 3D scene and add Foliage Surface component.
Its inspector is divided into tabs.
Storage
Every surface instance needs its own storage asset.
When you create new surface, you will be prompted here to create new storage asset.
Storage asset is used to store all textures used by surface - baked heightmaps, density and plant maps.
If, by any chance, you lost reference to this asset or you want to make kind of copy - you will have to manually reassign it through inspector debug mode.
- Instantiate Storage On Awake - when enabled, surface creates a temporal copy of storage asset when you enter play mode and then automatically destroys it. If you disable this, surface will use storage asset in its original form - this will result in faster initialization, but all changes made to surface while in playmode will be saved and may potentially cause irreversible damage to your data!
- Texture size - texture size used in storage. The higher value the more detailed maps will be. Changing it to lower value will result in downsampling all current maps, resulting in quality loss that you can revert only by using older version of storage asset or undoing changes with ctrl+z.
Area
Volume Edit Mode
When you enable Volume Edit Mode, you will be able to edit boundaries of area.
In scene view you will see visualisation of previous and new area.
After you adjust area, you have two options to apply changes:
- Resize - simple texture resize, it will scale entire area with existing plants.
- Crop/Extend - it will, as it says, try to extend or crop existing textures to keep placement of existing plants.
Heightmap Baking
While in volume edit mode, you will also be able to bake heightmap which is a required step to display your foliage properly.
This process works by casting rays from top to bottom of your volume.
It means that you have to make sure you have properly configured:
- Volume Raycast Mask - layer mask for colliders to block raycasts during baking proccess. It is recommended to have all your static environment on separate layers and use only these layers to avoid artiffacts caused by other, objects, that are not part of environment.
To verify your baking process, go to next step - LOD Plane.
LOD Plane
Level of Detail is rendered on special plane that is aligned to baked height map.
In this section you can configure how LOD plane mesh is generated and rendered.
By enabling Preview LOD Plane you can visualize this plane on your scene. In this mode you can also verify baked heightmap.
- Area/Tile/Inner subdivisions - mesh generation parameters. To visualise how they work, observe vertices summary in panel below and enable wireframe mode in your scene view.
- Camera Offset - slightly moves plane towards camera to reduce glitches like z-fighting.
- Y Offset - similar to option above, used to adjust plane in Y axis.
- Height Normals - by default, entire LOD plane is rendered as flat, what may not look well on complex scenes. With this option and its parameters you can reconstruct normals from baked height map. If your scene is rather flat, you can keep it disabled to save performance.
Layers
Here you define actual layers that will be processed and rendered on surface.
You can have as many layers as you want, but each new layer generates additonal pass, so you will want to use as few as possible.
In most cases you will stick with one or two layers.
In simple words, layer works by placing foliage meshes procedurarlly on surface according to plant configuration in definition asset and layer paremeters.
- Enabled - master toggle to turn layer on/off.
- Definition - each layer must have assigned definition - read more: Layer Definition.
- Density Offset - average distance between each mesh instance - lower means more dense foliage, but much more instances. Huge performance impact.
- Distance - maximum distance meshes will be placed from camera origin. Huge performance impact.
- Blend - distance multiplier that defines start distance above which density will be gradually lowered until maximum distance. The higher maximum distance, the higher performance impact for blend. Recommended to keep it at least 0.2-0.3 to avoid glitches near camera.
- Adaptive Density (experimental feature) - works by reducing visibility distance and density for plant instances, that are at your camera level when it's inside foliage - highest chance that more instances will be occluded by others so there is no need to overdraw them. You can configure distance multipliers and size (strength of adaptivity). Works best on rather flat surfaces.
- Render LOD - toggle LOD rendering. LOD is rendered on LOD Plane above maximum distance, but starts blending accordingly to distance blend defined above.
- Cast Shadows - toggle shadows on/off. Medium performance impact.
- Frustum Culling - if enabled, all instances will be culled with camera view frustum. Recommended to have it always enabled because of huge performance impact on large, dense areas but may be questionable if there is almost no grass because of small but constant extra overhead.
- Radius - average plant size to test against camera frustum. Increase if you notice glitches on screen edges but try to keep it as low as possible.
- Sway - Allow Wind - if disabled, global wind will not be processed on this layer.
- Sway - Allow Interaction - if disabled, interactions will not be processed on this layer.
Editor
Here you can enable scene edit tool.
Simply, select layer, plant, brush type, size and strength and follow instructions shown in inspector.
It's simillar to built-in terrain editor.
You can add custom brush textures in Dragon Foliage Config window.
Mass Tools
Here you have also access to a few common tools that may be sometimes helpful.
- Fill/Replace/Override - find specific plant painted on entire surface with given density (optional) and replace it with another one.
- Plant Index Offset - useful after you modify plant order in Layer Definition to offset all painted plant indices.
- Eraser - remove painted plant below given treshold
Sway
Global Wind
- Noise Texture - if you don't have one, assign Global Wind Noise texture which is included with package.
- Noise Size - noise texture size.
- Interaction Influence - the higher value, the futher wind will be applied to interacted foliage. The lower value, the wind will sooner stop affecting foliage on interacted area.
- Force - wind force.
- Speed - wind speed.
Interactions
Read more: Interactions