Repository navigation
fix(MeshHelper): compressed mesh bone weights and UV sets - #390
Open
nichinichisou0609 wants to merge 2 commits into
Open
nichinichisou0609 wants to merge 2 commits into
nichinichisou0609 wants to merge 2 commits into
Conversation
Compressed meshes store up to three 5-bit weights per vertex and imply the fourth one when they do not add up to 31. The running sum counts 5-bit units since K0lb3#338, but the implied weight was still computed as 1 - sum, which gives a negative weight (-24 for weights 10, 10, 5). It is now (31 - sum) / 31, so the four weights of a vertex add up to 1. tests/test_compressed_mesh.py decodes a synthetic CompressedMesh with one vertex that needs the implied weight and one with a single full weight.
With m_UVInfo set, a compressed mesh stores its texture coordinate sets back to back in m_UV. The read offset was assigned the size of the current set instead of advancing by it, so every set after the second one was read from the position of the second set and came back as a copy of it. The offset now accumulates, as the sets are stored. tests/test_compressed_mesh.py decodes three sets with 2, 3 and 2 components (sets 0, 1 and 3) from a synthetic CompressedMesh.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Meshes imported with Mesh Compression store their vertex data in
m_CompressedMesh. Two values decoded from it are wrong; one commit each, and each commit adds a regression test that fails on its parent and passes with the fix.weightsDatadequantization error #338 the running sum counts 5-bit units, but the implied weight is still computed as1 - sum, so weights 10, 10, 5 give a fourth weight of -24 and every skinned vertex with four influences gets a negative weight. It is now(31 - sum) / 31, the same formula as AssetStudio'sDecompressCompressedMesh, and the four weights of a vertex add up to 1.m_UVInfoset, the UV sets are stored back to back inm_UV. The read offset was assigned the size of the current set instead of advancing by it, so every set after the second one was read from the position of the second set and returned a copy of it. The offset now accumulates, as in AssetStudio.tests/test_compressed_mesh.py(new) decodes a syntheticCompressedMesh: one vertex whose fourth weight is implied and one with a single full weight, and three UV sets with 2, 3 and 2 components in channels 0, 1 and 3.Validation on Windows x86_64, CPython 3.11.13, pytest 9.1.1. The compiled path uses the
UnityPyBoostextension of the 1.25.4 wheel;UnityPyBoost/has no changes between 1.25.4 and417d595.417d595ruff checkandruff format --check