"Honey Select" pinch analysis

The article editor that breaks CSDN is too difficult to use, and it will be exhausting to pass a picture. I will turn it over after I finish writing it in Zhihu: https://zhuanlan.zhihu.com/p/28471808


Regarding the pinching system in the game, there is very little information about how to do it. I remember that only "Tianya Mingyue Knife" has shared it. Some time ago, I followed a public account for VR resource sharing, and often pushed HS's pinching works, so I only It aroused my curiosity and decided to find out.


The reason why HS can have such a strong customization ability is because of the existence of third-party MOD tools, players can freely import and export resources in the game, which also opens a back door for us to analyze the implementation mechanism of the game.


As we can see in the above image, the face has many bones, try to export the model and analyze it:


For the bones on the nose, do translation/rotation/scale, well, it looks like pinching the face is what it is.


For example, the nose wing bone affects this vertex, then we can adjust it to produce the following effect:


like the chin


The bones are used to pinch the face, what about the facial expression animation?


After analyzing the specifications of the model resources, it is found that there are a lot of morph animations. That is to say,  the head bones in HS are all used for pinching faces, and the expression animations are driven by MorphTargets .

The body can't also use MorphTargets to perform movements, can it?


After analyzing its model resources, it is found that the number of MorphTargets is 0, and the number of bones exceeds the previous empirical value.


Looking at its skinning information, it can be found that the names of all the bones that affect vertices have the word "_s_", and their parent bones are the bones with the same name without "_s_". That is to say, in  the HS body skeleton, the parent bone is responsible for animation , the child bone is responsible for skinning .

There are 67 adjustment parameters for the female character's face in the game:


There are a total of 34 adjustment parameters for the female character body, 2 of which are physical parameters and have nothing to do with bones


Let's see if these sliders can correspond to the bones one by one:


对于"鼻子整体上下"来说, 的确是只需要调节NoseBase的Y值就可以了, 我们需要做的就是根据滑杆在最大值和最小值之间进行线性插值.


对于"眉毛角度Z轴"的调节, 这时只调节一根骨骼就不对了, 需要左右对称着来. 也就是说, 有一些调节项需要同时调节左右对称的两根骨骼.


对于"眉毛左右位置", 如果在直线上两个端点之间进行插值, 很容易就跟面部三角形穿插了. 所以这里的插值路径只有最大值和最小值已经满足不了需求了, 而是需要按照曲线进行位置插值, 并且配合旋转插值贴合面部的法线方向. 也就是说, 一个调节项的插值可能是基于曲线(或多个关键帧), 而且可以同时影响骨骼Transform的多个分量.


眼睛的大小调节是最复杂的, 一共影响6根骨骼. 也就是说, 一个调节项是可以对应多根骨骼的.

我们总结一下, 脸型(或体型)调整原理就是:

  • 本质上修改的是骨骼的Local Transform(Translation, Rotation, Scale)
  • 一次只修改Local Transform的某个分量(或多个):Tx/Ty/Tz/Rx/Ry/Rz/Sx/Sy/Sz
  • 使用滑杆在预设的调节范围之间进行插值
  • 插值不一定是线性的, 可能是有多个关键帧
  • 每个调节项可能对应不只一根骨骼

以此为指导思想, 继续结合ILSpy对HS进行逆向分析, 终于找到了骨骼的配置数据.

首先是骨骼分类表:


  • 第1列, 类别编号: 每个编号代表UI上的一根滑杆. 重复出现的编号代表影响多根骨骼
  • 第2列, 骨骼名
  • 第3~11列, Transform Mask: 代表调节Bone Local Transform的哪些分量, 比如000000100代表只影响Sx, 即只缩放X轴

其次是骨骼调节关键帧表:


  • 第1列: 骨骼名
  • 第2~N列: 关键帧数据, 每一帧是9个float, 正好是一个Transform, 总共25帧.

可以说, I社的捏人系统, 最核心的就是这两张表格的数据了, 是他们这么多年捏人游戏的经验积累. 也正是这个原因, 他们舍不得每次新做一套骨架就重新调一版数据, 结果就是, 游戏中的骨架跟表格对不上:


游戏中的骨架, 不管是数量也好还是命名也好, 都跟表格对不上. 那这之间是怎么映射的呢?


原来是硬编码的, 真让人崩溃...好了, 那整个捏人的核心逻辑就搞清楚了:

  1. 根据骨骼分类表生成所有的调节滑杆, 并从预置的文件加载滑杆的默认值集合
  2. 如果滑杆值变了, 查分类表得到骨骼名(可能多个), 再根据骨骼名查关键帧表得到关键帧集合, 根据滑杆值插值出Local Transform
  3. 使用代码逻辑把老的Transform数据转换成新骨架能用的骨骼Transform
  4. 把骨骼Transform全部更新到模型上

尝试在UE4中使用PoseableMesh复刻了一下, 效果还不错:


PoseableMesh的问题是不兼容动画, 所以如果要修改SkeletalMesh的BoneTransforms话, 就只能在AnimationBlueprint里实现一个自定义的AnimNode了:


配上动画, 贴上材质, 效果就好多了:



(随便找了件衣服遮一遮)


最后, 顺便提一下捏人之外的东西, 因为对于角色的定制来说, 捏人起的作用还不如换一件衣服.


对衣服的资源进行分析可以发现两点值得学习的地方:

  • 每件衣服都配有一个剔除掉被遮住的三角形的裸模, 一方面可以提升绘制性能, 一方面能避免衣服和皮肤两层三角形的穿插
  • 裙摆/披风/长衫等都是共用同样的8条物理骨骼, 算是比较传统的布料模拟做法


挂件差不多都是StaticMesh, 最多带有物理骨骼, 直接挂在骨架挂点上, 可以跟随体型一起进行变换.


眼睛这里的Mesh有点扩张了, 分了很多层, 甚至有3个Mesh用来做眼泪的表现. 材质多了, 可以更换的样式自然也就多了:


头发分了前中后三部分, 每一部分可以单独隐藏或者替换, 配合大量的模型资源, 真正可以配出各种各样的发型, 更何况还有MOD的支持.

其它的类似皮肤/皱纹/眼影/腮红/唇彩/纹身/痣/晒痕/指甲等, 大多数都是换贴图, 没有多少技术上的复杂度, 但却是能够大大提升个性的功能:


通过GPA分析发现, 这些叠加的图层在运行时并没有独立的贴图:


所以并没有采用Decal的方式绘制, 而是跟皮肤贴图混合到了一起:



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325520560&siteId=291194637