目前的换装方案主要有:
实现参考
SkinMeshRender改变模型Transform无效是因为模型上的顶点位置已经是实时通过骨骼位置和权重实时计算出来的。所以对Unity中带有skinMeshRenderer组件的GameObject进行移动,旋转等操作,并不会影响模型的最终渲染。
参考的核心代码
该代码没有对mesh进行优化,可以对skinmeshrender进行合并来优化,减少recall,优化采用CombineInstance对mesh进行合并
代码根据性别加载主骨架,再根据角色装扮信息读取各部件资源中的所有蒙皮信息生成新的Mesh,将Mesh与子物体中所有的bones,materials赋予父物体的SkinnedMeshRenderer中。
官方的换装粒子,不修改代码不能再unity5中运行。换装原理是更改蒙皮和合并mesh。换装时有内存泄露。原因是并没有从内存中清除(AssetBundle),不断的更换就会在内存中不断的累加。
UMA分为改变Wardrobe(换装),Color(皮肤颜色),DNA(设置骨骼(T-pose)矩阵) 换装的核心原理为更改蒙皮+合并mesh。 SkinnedMeshCombiner.cs–>CombineMeshes 会合并骨骼和顶点MergeSortedTransforms(按照hash的大小排序骨骼)把所有的顶点合并成一个mesh
制作的所有衣服基于同一套完整骨骼,导出的时候导出衣服和衣服所受影响的那些骨骼,动画可以不需要。
有二种方式。一是用Blendshape(融合变形),通常用于面部动画,直接修改顶点。二就是用骨骼驱动,采用修改骨骼矩阵的方式影响SkinMesh。二种方式最终的目的都是修改顶点。
How the software does this blending, as explained by some of the other answers written here, is achieved by the delta or the differences in shape between the target expressions and the base shape. Maya keeps track of how much each vertex is displaced in relation to the original Base shape. Thus when the animator blends or morphs the expression in, Maya translates those vertices towards the final positions as described by that particular BlendShape.
Since Maya compares the base shape and the BlendShape objects vertex for vertex, we should always maintain consistency in vertex count, vertex order or topology across all BlendShapes.
UMA的骨骼男女角色层次结构一样为
人物骨骼一共158块骨骼
UMADynamicCharacterAvatar
-Root
--Global
---Position
----Hips
-----LowerBack
------LowerBackAdjust
-------LowerBackBelly
------Spine
-------Spine1
--------Neck
---------Head
----------RightEar
-----------RightEarAdjust
----------RightEye
-----------RightLowerLid
------------RightLowerLidAdjust
-----------RightEyeAdjust
-----------RightUpperLid
------------RightUpperLidAdjust
-----------RightEyeGlobe
----------RightLipsSuperiorMiddle
-----------RightLipsSuperiorMiddleAdjust
----------LeftLipsSuperiorMiddle
-----------LeftLipsSuperiorMiddleAdjust
----------RightEyebrowLow
-----------RightEyebrowLowAdjust
----------NoseBase
-----------NoseBaseAdjust
----------RightLowCheek
-----------RightLowCheekAdjust
----------LipsSuperior
-----------LipsSuperiorAdjust
----------RightNose
-----------RightNoseAdjust
----------HeadAdjust
----------LeftEyebrowMiddle
-----------LeftEyebrowMiddleAdjust
----------LeftEar
-----------LeftEarAdjust
----------LeftEye
-----------LeftEyeAdjust
-----------LeftEyeGlobe
-----------LeftUpperLid
------------LeftUpperLidAdjust
-----------LeftLowerLid
------------LeftLowerLidAdjust
----------LeftNose
-----------LeftNoseAdjust
----------NoseTop
-----------NoseTopAdjust
----------RightCheek
-----------RightCheekAdjust
----------NoseMiddle
-----------NoseMiddleAdjust
----------UpperLips
-----------UpperLipsAdjust
----------LeftEyebrowUp
-----------LeftEyebrowUpAdjust
----------RightEyebrowUp
-----------RightEyebrowUpAdjust
----------LeftCheek
-----------LeftCheekAdjust
----------Mandible
-----------LeftLipsInferior
------------LeftLipsInferiorAdjust
-----------RightLowMaxilar
------------RightLowMaxilarAdjust
-----------RightLips
------------RightLipsAdjust
-----------LipsInferior
------------LipsInferiorAdjust
-----------MandibleAdjust
-----------RightLipsInferior
------------RightLipsInferiorAdjust
-----------Tongue01
------------Tongue02
-----------LeftLips
------------LeftLipsAdjust
-----------LeftLowMaxilar
------------LeftLowMaxilarAdjust
----------RightEyebrowMiddle
-----------RightEyebrowMiddleAdjust
----------LeftLowCheek
-----------LeftLowCheekAdjust
----------LeftEyebrowLow
-----------LeftEyebrowLowAdjust
---------NeckAdjust
--------RightOuterBreast
---------RightInnerBreast
--------RightShoulder
---------RightTrapezius
---------RightArm
----------RightArmAdjust
----------RightForeArm
-----------RightForeArmAdjust
-----------RightForeArmTwist
------------RightForeArmTwistAdjust
-----------RightHand
------------RightHandFinger03_01
-------------RightHandFinger03_02
--------------RightHandFinger03_03
------------RightHandFinger05_01
-------------RightHandFinger05_02
--------------RightHandFinger05_03
------------RightHandFinger04_01
-------------RightHandFinger04_02
--------------RightHandFinger04_03
------------RightHandFinger02_01
-------------RightHandFinger02_02
--------------RightHandFinger02_03
------------RightHandFinger01_01
-------------RightHandFinger01_02
--------------RightHandFinger01_03
---------RightShoulderAdjust
--------LeftOuterBreast
---------LeftInnerBreast
--------Spine1Adjust
--------LeftShoulder
---------LeftShoulderAdjust
---------LeftTrapezius
---------LeftArm
----------LeftForeArm
-----------LeftHand
------------LeftHandFinger04_01
-------------LeftHandFinger04_02
--------------LeftHandFinger04_03
------------LeftHandFinger01_01
-------------LeftHandFinger01_02
--------------LeftHandFinger01_03
------------LeftHandFinger02_01
-------------LeftHandFinger02_02
--------------LeftHandFinger02_03
------------LeftHandFinger03_01
-------------LeftHandFinger03_02
--------------LeftHandFinger03_03
------------LeftHandFinger05_01
-------------LeftHandFinger05_02
--------------LeftHandFinger05_03
-----------LeftForeArmTwist
------------LeftForeArmTwistAdjust
-----------LeftForeArmAdjust
----------LeftArmAdjust
-------SpineAdjust
-----LeftUpLeg
------LeftLeg
-------LeftLegAdjust
-------LeftFoot
--------LeftToeBase
------LeftUpLegAdjust
------LeftGluteus
-----RightUpLeg
------RightGluteus
------RightLeg
-------RightFoot
--------RightToeBase
-------RightLegAdjust
------RightUpLegAdjust
用于修改DNA的骨骼有一共74块,其中Adjust骨骼大部分为单位矩阵,skinMesh大部分绑定在这些可修改的骨骼上,在名为***adjust骨骼上没有动画数据,UMA2动画采用avatar人形骨骼系统进行重定向。
用于调整的骨骼有:
HeadAdjust
NeckAdjust
LeftOuterBreast
RightOuterBreast
LeftEye
RightEye
LeftEyeAdjust
RightEyeAdjust
Spine1Adjust
SpineAdjust
LowerBackBelly
LowerBackAdjust
LeftTrapezius
RightTrapezius
LeftArmAdjust
RightArmAdjust
LeftForeArmAdjust
RightForeArmAdjust
LeftForeArmTwistAdjust
RightForeArmTwistAdjust
LeftShoulderAdjust
RightShoulderAdjust
LeftUpLegAdjust
RightUpLegAdjust
LeftLegAdjust
RightLegAdjust
LeftGluteus
RightGluteus
LeftEarAdjust
RightEarAdjust
NoseBaseAdjust
NoseMiddleAdjust
LeftNoseAdjust
RightNoseAdjust
UpperLipsAdjust
MandibleAdjust
LeftLowMaxilarAdjust
RightLowMaxilarAdjust
LeftCheekAdjust
RightCheekAdjust
LeftLowCheekAdjust
RightLowCheekAdjust
NoseTopAdjust
LeftEyebrowLowAdjust
RightEyebrowLowAdjust
LeftEyebrowMiddleAdjust
RightEyebrowMiddleAdjust
LeftEyebrowUpAdjust
RightEyebrowUpAdjust
LipsSuperiorAdjust
LipsInferiorAdjust
LeftLipsSuperiorMiddleAdjust
RightLipsSuperiorMiddleAdjust
LeftLipsInferiorAdjust
RightLipsInferiorAdjust
LeftLipsAdjust
RightLipsAdjust
Global
Position
LowerBack
Head
LeftArm
RightArm
LeftForeArm
RightForeArm
LeftHand
RightHand
LeftFoot
RightFoot
LeftUpLeg
RightUpLeg
LeftShoulder
RightShoulder
Mandible
优点:可以控制的非常细微捏脸变化。
缺点:Blendshape在捏脸制作上工作量非常大,我想把一个结构捏的多么细微就要制作多少张脸,这个细微度和工作量是成正比的。这样会导致后期修改不方便,更重要的是性能消耗非常大。另外跟我们第三方动画软件不兼容。
优点:制作量比较少,性能消耗相对少些,和现有动画系统兼容,另外捏脸骨骼和动画骨骼是同一套骨骼,就通过MorphemeConnect动画软件跟面部骨骼做了融合。当你捏出来任何形状的脸都可以套用同一个动画,这样也减少很大的工作量。
缺点:权重分配受限较多,捏练的细致程度有限。
脸型(或体型)调整原理就是:
本质上修改的是骨骼的Local Transform(Translation, Rotation, Scale)
一次只修改Local Transform的某个分量(或多个):Tx/Ty/Tz/Rx/Ry/Rz/Sx/Sy/Sz
使用滑杆在预设的调节范围之间进行插值
插值不一定是线性的, 可能是有多个关键帧
每个调节项可能对应不只一根骨骼
参考制作:
https://docs.unrealengine.com/latest/CHN/Engine/Content/FBX/MorphTargets/index.html
http://jjyy.guru/unity-animation