SpeedTree
    Show / Hide Table of Contents

    Leaf collision

    When a tree is generated procedurally, it may end up with leaves "colliding," or intersecting, with other leaves and branches. The SpeedTree Modeler has features to detect these collisions and remove them.

    An example of leaf collision on a model. A branch appears to go through a leaf while two leaves intersect unrealistically.

    Removing collisions

    Leaf collision removal is enabled in the Post section of the Tree Window toolbar. You have a few options for the kind of collision tests performed:

    Property Description
    None No action.
    Low Most leaf-leaf collisions are eliminated. Leaf-branch collisions are ignored (fastest).
    Medium All collisions are eliminated by a rough intersection test (intermediate speed, but this option can remove too many leaves).
    High All collisions are eliminated by an exact intersection test (slowest).

    Collision removal works as a background process to prevent you from having to wait to continue editing your tree. Once it is finished, the results will pop in. Every time the leaves are changed, collision removal will re-run automatically. An example of the results of leaf collision removal are shown below:

    The leaves before removal are densely packed together on the branch and have many unrealistic points of intersection. After removal, there are fewer leaves on the branch and they have no intersections.

    When using clusters

    On real-time trees that use Clusters, collision detection becomes a little trickier. Cluster geometry, such as that made with the Cutout Editor, often contains a lot of transparent parts, since the map includes many leaves and twigs. Exact tests on this geometry may remove a lot more leaves than you would want, since parts of the geometry that are touching may not matter so much.

    In this case you can enable "Use spherical tests on leaves." This will replace the exact geometry tests with a spherical test. It will be faster, and it will leave behind more leaves. You can adjust the size of the spheres that are tested by changing the Sphere threshold property on the leaf generators.

    When making clusters

    Similarly, when making the clusters, a different type of collision detection is warranted. Cluster maps often work better on a tree if they have fewer overlapping leaves.

    The collision detection options listed in the "Cluster plane overlapping" submenu are similar to the main options. However, they apply only to intersection tests done in the top-down (XY) plane. In this way, you can be sure your cluster maps have few overlapping leaves.

    Refining collision behavior

    To further refine the results of leaf collision removal, you can edit the Post/Collision properties of individual generators such as the Leaf mesh generator and Batched leaf generator.

    • Collision properties influence which leaves "win" in a collision fight, which leaves are tested against which other leaves, and what happens to leaves when they lose.
    • Additional shared properties in the Post group let you control what happens with the parent nodes (and any children nodes) of the leaves that are removed following collision computation results.
    Copyright © 2023 Unity Technologies
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX.