Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the skin's scale to modify lod to avoid lod scaling errors. #63812

Closed
wants to merge 1 commit into from

Conversation

fire
Copy link
Member

@fire fire commented Aug 2, 2022

Fixes: #58570

@fire fire requested review from a team as code owners August 2, 2022 07:32
@akien-mga akien-mga added this to the 4.0 milestone Aug 2, 2022
@fire fire force-pushed the modify-lod-bind-scale branch 3 times, most recently from b1b3b24 to 0624877 Compare August 2, 2022 08:52
@fire
Copy link
Member Author

fire commented Aug 2, 2022

Character.zip
Test case from #58570

@fire fire force-pushed the modify-lod-bind-scale branch from 0624877 to 7fddaeb Compare August 2, 2022 15:03
@fire fire requested a review from a team as a code owner August 2, 2022 15:03
@fire fire force-pushed the modify-lod-bind-scale branch 2 times, most recently from 5d98035 to 9927474 Compare August 7, 2022 20:01
@fire fire force-pushed the modify-lod-bind-scale branch from 9927474 to 4a25723 Compare August 10, 2022 17:36
@fire fire force-pushed the modify-lod-bind-scale branch from 4a25723 to d687a21 Compare August 18, 2022 15:41
@fire fire force-pushed the modify-lod-bind-scale branch from d687a21 to 571f41e Compare August 18, 2022 15:42
@fire
Copy link
Member Author

fire commented Aug 20, 2022

Discussed during a pull request review meeting that @reduz will see if @JFonS can find some time to "bake" the skins of the mesh so we don't have this problem.

@fire
Copy link
Member Author

fire commented Sep 7, 2022

Reduz

4:56 AM
fire Saracen Tokage It should be something along these lines:

  • For every mesh, you need to send the index buffer and vertices to the LOD code.
  • When the mesh has a skeleton, if bones are scaled, the mesh sent to the LOD code will not > represent its true size if bones are scaled, hence LOD will be wrong
  • Hence, the mesh neds to be transformed by applying its skin, to do this:
  1. Obtain all vertices, normals, tangents, weights and indices from mesh
  2. Get the skin transforms and map to vertices (with index), invert the matrices
  3. Go vertex by vertex, transform each by the transform at each index and apply the weight > (basically for each vertex where weight > 0, its final_vertex += (xform[bone_index] * vertex) * bone_weight;
  4. With the transformed mesh, run the LOD code.

@fire
Copy link
Member Author

fire commented Sep 7, 2022

This was agreed in consensus to be the wrong approach. I reposted the new reduz design @SaracenOne said he was interested in looking at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LOD causes bones skinning errors with GLTF import
2 participants