glacier-modding / RPKG-Tool

The RPKG tool allows for easy (un)packing of files from the Glacier Engine RPKG file format! Hitman 3 has the most support.
https://glaciermodding.org/rpkg/
Other
47 stars 9 forks source link

[BUG] Rebuilt Custom .PRIM Doesn't Retain Exact Weight Values or Normalized 1.0 Weights #10

Closed HMBM47 closed 2 years ago

HMBM47 commented 3 years ago

Describe the bug RPKG Tool doesn't seem to retain weight values or the "1.0" Normalization of weights when rebuilding custom .PRIMs. As a result, since weights are no longer normalized, in game it causes models to look "spiky" and/or "wavy".

To Reproduce

  1. With RPKG Tool export .PRIM as .glb
  2. With Blender: a. Open .glb in Blender b. Import or create custom mesh c. Join it to original mesh (and delete original geometry) d. Parent it to the armature and weight paint, or transfer weights from original mesh e. Limit total of weights to 6 and Normalize All. f. Export glTF. Format: glTF Binary, Transform:+Y Up Unchecked, Animation: Skinning: Include All Bone Influences
  3. With RPKG Tool rebuild .PRIM
  4. Put created .rpkg into Runtime folder and see how in game the mesh will looks "spiky" and/or "wavy".
  5. Import the .rpkg created by RPKG Tool that contains the custom .PRIM
  6. Export that .PRIM as .glb.
  7. Import that .glb into Blender and observe how there are many vertices whose weights are no longer normalized and the values have changed ever so slightly.

Expected behavior Retain vertex weights and Normalization.

Screenshots Left is my original, Normalized vertices, before conversion. (1.0) Right is the same model converted with RPKG Tool, then exported. (0.996) Weights Shirt

RPKG tool version: 2.16.1

Hitman Version: Any

Notexe commented 3 years ago

Just want to confirm that this is with "Include All Bone Influences" enabled in the export settings in Blender?

HMBM47 commented 3 years ago

Just want to confirm that this is with "Include All Bone Influences" enabled in the export settings in Blender?

Yes. Of course.

HMBM47 commented 3 years ago

Interesting tidbit, this seems to be ALL the weight numbers that are actually exported by RPKG Tool. Every single weight of the original PRIM meshes follow this formula. It seems RPKG Tool actually uses this same formula to round out the weight values of the custom .PRIM when it's rebuilt. (If the exported .glb of the custom .PRIM is an accurate representation of how it was imported.) But in doing so, it usually mean those numbers don't add up to 1.0.

Even 0.002 = 0.001961 0.004 = 0.003922 0.006 = 0.005882 0.008 = 0.007843 0.010 = 0.009804 0.012 = 0.011765 0.014 = 0.013725 0.016 = 0.015686 0.018 = 0.017647 0.020 = 0.019608 0.022 = 0.021569 0.024 = 0.023529 Odd 0.025 = 0.02549 0.027 = 0.027451 0.029 = 0.029412 0.031 = 0.031373 0.033 = 0.033333 0.035 = 0.035294 0.037 = 0.037255 0.039 = 0.039216 0.041 = 0.041176 0.043 = 0.043137 0.045 = 0.045098 0.047 = 0.047059 0.049 = 0.04902 0.051 = 0.05098 0.053 = 0.052941 0.055 = 0.054902 0.057 = 0.056863 0.059 = 0.058824 0.061 = 0.060784 0.063 = 0.062745 0.065 = 0.064706 0.067 = 0.066667 0.069 = 0.068627 0.071 = 0.070588 0.073 = 0.072549 0.075 = 0.07451 Even 0.076 = 0.076471 0.078 = 0.078431 0.080 = 0.080392 0.082 = 0.082353 0.084 = 0.084314 0.086 = 0.086275 0.088 = 0.088235 0.090 = 0.090196 0.092 = 0.092157 0.094 = 0.094118 0.096 = 0.096078 0.098 = 0.098039

0.1 = 0.1 0.2 = 0.2 0.3 = 0.3 0.4 = 0.4 0.5 = 0.5 0.6 = 0.6 0.7 = 0.7 0.8 = 0.8 0.9 = 0.9

Example of weights of a single vertex in Blender: 0.173 = 0.172549 0.012 = 0.011765 0.522 = 0.521569 0.243 = 0.243137 0.027 = 0.027451 0.024 = 0.023529

Notexe commented 2 years ago

Fixed in 32f6da50571aedabcc609b2c7509b44d1f121e04