Combining Layers Using Direct Blend Trees

Original page: https://notes.sleightly.dev/dbt-combining/

Due to the high performance impact of Animator Layers in an Animator Controller, it is often a lot better to combine things such as toggles and radial menus into a single Animator Layer by using a Direct Blend Tree.

Due to the high performance impact of Animator Layers in an Animator Controller, it is often a lot better to combine things such as toggles and radial menus into a single Animator Layer by using a Direct Blend Tree.

Understanding Direct Blend Trees

Direct Blend Trees allow you to assign a parameter directly to each Animation or Blend Tree child, instead of blending between them. This allows you to animate more than one thing at the same time in the same Blend Tree.

For VRChat, we can abuse this behaviour to create multiple toggles and radial puppets within a single Direct Blend Tree, similar to how we would in separate Animator Layers.

The structure and functionality of a Direct Blend Tree is very similar to that of an Animator Controller, so it might be easier to understand them if you look at them as if they were Animator Controllers. This is a very simplified way to look at and understand Direct Blend Trees, so it should be noted that while they are very similar to Animator Controllers, they are NOT the exact same!

There are a few key differences between the two which heavily limit the use cases and implementations of Direct Blend Trees compared to Animator Controllers. More info can be found in the Current Limitations And Known Issues section.

Direct_Blendtree_Comparison.png

A Direct Blend Tree with 3 Clothing Toggles



Creating Toggles And Radial Puppets

Making toggles and radial puppets in a Direct Blend Tree is not much different or any more difficult than creating a regular toggle in an Animator Layer.

Step 1

1.png

Write_Defaults.png


Step 2

2.png


Step 3

3.png


Step 4

Using only one animation clip like you would with a WD On workflow will not work! You need separate animation clips or a combined clip.

4.png


Step 5

5.png


Repeat steps for every toggle and radial puppet you want to create, there is no limit to how many you can add.

Screenshot_4919.png


Write Defaults

Direct Blend Trees are an exception when it comes to Write Defaults. Their Write Defaults value does not have to match that of the rest of your Animator Controller, meaning it is okay to mix Write Defaults, as long as you do not mix within the same layer.

In the case of Direct Blend Trees this means we can safely use Write Defaults On, even if the rest of the Animator Controller uses Write Defaults Off. This lets us avoid a handful of problems:

Write Defaults Off Direct Blend Trees

Therefore it is NOT advisable to use Write Defaults Off Direct Blend Trees as they are less stable and a lot more difficult to work with than their Write Defaults On counterpart. Again, it is completely safe to use Write Defaults On Direct Blend Trees even if the entire rest of your Animator Controller uses Write Defaults Off.

You can add the prefix (WD On) to the name of your Blend Tree and it will be skipped when using the https://github.com/VRLabs/Avatars-3.0-Manager to set the Write Defaults values of your Animator Controllers.

This is especially useful for Avatar and Prefab creators that want to make sure that users do not accidentally turn off the Write Defaults when using the tool.

Changing the Write Defaults value from On to Off WILL break the Blend Tree until Write Defaults is turned back to On!

Prefix.png

Nesting Direct Blend Trees

If you have a lot of toggles and radial puppets, your Direct Blend Tree can very quickly become really big and hard to read. You can nest Direct Blend Trees within each other to simulate folders and improve organization.

If you have already created all your toggles and radial puppets before nesting, you will have to delete and remake them inside their folder, so it is better to account for this in advance (unless you have a tool to rearrange Blend Trees).

Here we have a Direct Blend Tree containing nine children, we can organize them into folders by utilizing more Direct Blend Trees.

Screenshot_4920.png

Start by adding a child Blend Tree to your Direct Blend Tree for each folder you would like to create, the same way you would when making a toggle or radial puppet.

Next, select each child and change the Blend Type to Direct in the inspector.

Screenshot_4925.png

Now simply create your toggles and radial puppets the same way you would in the previous guide, except that now you are creating them from within the folder.

For better organization you can also rename the folders at the top of the inspector when selecting them.

You can use the same Weight parameter from your root Direct Blend Tree described in Step 3 for each of these sub-folders.

An example of combining multiple radial puppets and toggles can be found at Direct Blend Tree Radials and Toggles (Nested).

Screenshot_4921.png

You can double click on any of the Direct Blend Trees to open them in an isolated view, this can be especially helpful when working with a Blend Tree that is causing performance issues due to its size.

Screenshot_4922.png

You can navigate back to the full Blend Tree view by clicking on the arrows in the top left corner.

Screenshot_4924.png


Advanced Blend Tree Techniques

Blend Trees can be used for a lot more than just simple toggles and radial puppets, such as:

As of writing, these mentioned techniques are relatively undocumented and out of the scope of this guide.

An extension article may be added in the future if there’s enough demand.


Current Limitations And Known Issues


Revision #2
Created 4 September 2023 17:46:29 by jellejurre
Updated 4 September 2023 17:52:08 by jellejurre