From Unify Community Wiki
Jump to: navigation, search


Here is the basic tree shading package to get you going. Download it!

It contains 2 shaders & a controller. First of all add the Tree Shading/Controller prefab to your scene. Then, assign and use the shaders:

Soft Occlusion Bark - This is a normal vertexlit shader with ambient occlusion on the vertices, so the trunk will darken as it disappears into the foilage.

Soft Occlusion Leaves - This is a softly self-occluding vertexlit shader. Use it as you would use the normal vegetation 2-pass.

Note: These are a work-in-progress and should not really be put to production use. The shader requires precomputed ambient occlusion, at the moment this is done either when you select the Controller in the scene or when you enter playmode. You will notice a long load time when the ambient occlursion needs to be recomputed.

When loading the scene in edit mode your trees might have wrong shading, this is because ambient occlusion has not been calculated. You can select the controller in the scene to fix this or simply enter playmode.

Detailed instructions

The shaders contain a few new properties for controlling the shading:

Baselight - How much basic self-illumination the material has.

Amb. Occlusion - How much leaves are darkened by being in the center of the tree.

Dir Occlusion - How much leaves are lightened by being on the side of the tree facing the light.

The shader handles 4 directional vertex lights, but has a few problems if lights get disabled. Use them to see what is going on when making the meshes / textures. Don't put them in a huge scene with lots of point lights. It'll look weird.

Sometimes, when reimporting a mesh, the automatic preprocessing will not update. To force it, select the Controller prefab and select "RecalcAll" from its context menu.

Personal tools