A set of replacement shaders for Unity's Nature/Tree Creator shaders that supports dithered crossfade in LOD Groups.
This project makes use of Unity built-in shader source, see license.txt for copyright and licensing details.
The Tree Creator Bark and Tree Creator Leaves shaders (as well as the Fast variant) are not intended to be used directly, they are intended to be used with the Tree Creator, as it generates materials using the Optimized versions of these shaders. Nevertheless I still added support for dithered crossfade to these base shaders.
- Create a new material with the
Nature/Tree Creator Bark Crossfade
shader. - Create another material with the
Nature/Tree Creator Leaves Crossfade
shader. - Create a new tree, and assign the bark material to the branches, and the leaves material to the leaves.
- Create a new GameObject and give it a LOD Group component.
- Add the tree GameObject as a child to the LOD GameObject.
- Set the LOD Group's Fade Mode to Crossfade.
- Set the LOD Group's Object Size to (roughly) the same as the height of the tree.
- Remove LOD1 and LOD2 from the LOD Group.
- Select LOD0 and add a new renderer to the Renderers list, and then assign the tree GameObject to this.
- Set LOD0's Transition to something appropriate, (e.g. 50).
- Set LOD0's Fade Transition Width to something appropriate, (e.g. 0.5).
The tree will now fade in and out as the camera moves closer or further away from it.