Skip to main content

虚拟形象遮罩

原始页面:https://notes.sleightly.dev/animator-masks/

Unity Behaviour

遮罩会根据遮罩中启用和禁用的内容,屏蔽更改人形肌肉值、材质切换和变换值的功能。遮罩会根据其中人体部位的开关情况,屏蔽对应位置的人形肌肉值、材质切换和场景对象功能。
如果某一层有一个遮罩,且该遮罩的某个值被启用,且该遮罩的某个部位被启用,那么动画就可以对该值进行动画处理。
如果某一层有一个遮罩,且该遮罩的某个值被禁用,且该遮罩的某个部位被禁用,那么动画就不能对该值进行动画处理。具体来说:

  • 如果某一层有一个遮罩,且该遮罩的 humanoid 值(如左手)被启用,那么该人形肌肉就可以被该层动画修改。
  • 如果某一层有一个遮罩,且该遮罩的 humanoid 值(如左手)被禁用,那么该人形肌肉就不能被该层动画修改。
  • 如果某一层有一个遮罩,且该遮罩的变换值被启用或未指定,那么该变换的位置、旋转和缩放就可以被该层动画修改,同时还可以修改第一个材质槽的材质交换。
  • 如果某一层有一个遮罩,且该遮罩的变换值被禁用,那么该变换的位置、旋转或缩放,或者第一个材质槽的材质交换就不能被该层动画修改。

如果某一层有任何遮罩,那么它就不能对第一个材质槽之外的任何材质槽进行材质交换动画,或者对带有动画器的对象的根变换进行动画。

任何其他内容(混合形状和任何其他组件)都不受遮罩影响。

我们之所以使用遮罩,是因为如果你在一个图层上为一个人形肌肉制作动画,然后在另一个图层上为另一个人形肌肉制作动画(无论是更低层的动画器还是另一个可播放图层),那么第一个动画的内容将被第二个动画覆盖(除非第二个图层是添加层,如果是,则将两个动画相加)。

对于变换,这只会在第二个动画使用 WD 关闭并且是在更晚应用的可播放图层上发生时发生。

所以,例如,如果我们没有遮罩,如果你在手势层上为手部移动制作一个人形肌肉动画,然后在特效层上使用另一个动画来制作面部表情,而这个动画也恰好为人形肌肉制作动画,那么手部移动的值将被特效层覆盖。

注意:

这意味着,如果你有一个人形动画,如果不只是屏蔽你想要启用的人形肌肉,而其他部分被禁用,那么所有其他的人形肌肉都将被覆盖。

这也意味着,如果你在手势层上有变换动画,而你在特效层上有一个未加遮罩的 WD 关闭变换动画,那么所有手势层变换动画都将被覆盖。

默认的 VRChat 特效层使用了一个未加遮罩的FX 层使用了一个未加遮罩的 WD 关闭混合树。这可能会导致变换动画在 VRChat 中无法播放,只要你在使用默认特效层。如果你想在手势层上制作变换动画,你必须使用自己的特效层或者删除默认的并设置为空。

 

VRChat layer behaviour

All playable layers are played one after the other. First the Base, then Additive, then Gesture, then Action and lastly FX.

On the first four layers (Base, Additive, Gesture & Action), you should only use animations which affect transforms (so either humanoid muscles or transform animations) and toggle gameobjects on/off.

This isn't because of masking, but because these four layers are played only on your local avatar clone, but not on your mirror and shadow clones. VRChat copies the transforms and on/off state of every GameObject on your local avatar and applies them to your avatars mirror and shadow clone. However, VRChat does not copy anything other than transforms and the on/off state of each GameObject, meaning that if you were to animate anything other than that, such as blendshapes, material swaps or shader settings, VRChat will not copy those attributes to the mirror and shadow clones. The clones do however play their own FX Layer, which is why anything other than the transforms and on/off states of GameObjects should be animated in the FX Layer.

For example: if you do a material swap on the Base Layer, it won't run on the mirror & shadow clones.

This article only goes into detail when it comes to masking and behaviour. If you want more information on what VRChat does with layers or what VRChat recommends you do with them, you can find this at the following page:

Playable Layers | VRChat Creation

Base Layers

Base

This layer should only animate transforms (either directly or through humanoid muscles) and/or GameObject on/off states for the reasons stated above.

VRChat recommends this layer to be used for locomotion and to only animate humanoid muscles.

Additive

This layer should only animate transforms and/or GameObject on/off states for the reasons stated above. It is blended additively, meaning that any animations don’t replace the base layer ones, but instead the values get added.

VRChat recommends this layer to be used for tweaks to locomotion, like breathing effects, and to only animate humanoid muscles.

Gesture

This layer should only animate transforms and/or GameObject on/off states for the reasons stated above. It has some special behaviour, namely that VRChat takes the mask on the first layer, and applies it to all the layers in a way where if an animation (humanoid or transform) is disabled in either this mask or the layer mask itself, it is disabled.

So if you want to animate any of the humanoid muscles, you will have to make a mask that specifically allows those muscles and put it in the top layer.

And if you want to animate any transforms with WD off, you will have to make a mask that specifically allows those transforms and disables the others, and put it in the top layer.

VRChat recommends this layer to be used for animations that animate transforms and humanoid animations that only affect certain body parts.

Action

This layer should only animate transforms and/or GameObject on/off states for the reasons stated above. This layer is blended to zero by default. Before you do anything in the action layer, you need to use the Playable Layer Control State Behavior to blend this layer up before transitioning to the actual action you're performing. Make sure you blend it back to zero when you're done, otherwise other animations won’t play.

VRChat recommends this layer to be used to overwrite any humanoid animations from the previous layers, like for example for emotes or AFK animations.

FX

Since this layer runs on all your clones, this is where you can run any animations. Note that you can still animate transforms, given the right masking.

If the first layer mask is empty, it will create a default mask that disables all humanoid muscles and enables all transforms, and applies it to all the layers in a way where if it is disabled in either this mask or the layer mask itself, it is disabled.

If the first layer mask isn't empty, it will take the first layer mask and apply it to all layers in the same way.

So if you want to animate any of the humanoid muscles, you will have to make a mask that specifically allows those muscles and denies the others and put it in the top layer. If you don’t deny them, they will replace the Gesture animations on them.

If you are using WD off, this same logic applies to transforms.

<aside> ⚠️ VRC's default FX layer has a blendtree with write defaults off, this can break transform animations. If you want to use transform animations on any layer, do not use the default VRC FX layer.

</aside>

VRChat recommends this layer to be used for anything that isn’t transform animations, like enabling/disabling GameObjects, components, material swaps, shader animations, particle system animating, etc.

Special Layers

T-pose:

The T-Pose is used to determine various measurements of your avatar, especially for placement of your viewpoint (or view-ball). It is played on its own, so masking doesn't really matter

IK Pose:

IK Pose is used to determine major joint bends. In the IK pose, your joints should be bent slightly in the direction they're intended to bend. It is played on its own, so masking doesn't really matter

Sitting Pose:

The controller used in this slot is used for both animation and posing. When you sit, the viewpoint of your avatar is used for calibration. The animation is played, allowing you to create a "sitting down" animation, as well as a "sitting" idle animation. It is used like Action, where it should override all humanoid animations to make your character sit.