Facepunch / sbox-issues

176 stars 12 forks source link

[Modeldoc] RemoveBoneAndChildren flag doesn't work with LODs #5613

Closed Grodbert closed 2 months ago

Grodbert commented 3 months ago

Describe the bug

This is a pretty big performance issue, In models, one of the biggest FPS killer is bones, we found you could use the RemoveBoneAndChildren flag on a mesh and use that for LODs to increasingly discard bones according to the LOD, which boosted FPS massively, especially when Max implemented it on the citizen. citizen This no longer works, bones aren't getting culled correctly with LODs. I've troubleshooted a couple factors:

  1. With multiple RenderMesheFiles, the behavior is it will only cull whatever the first mesh added has, meaning it will not cull at all if it has no "RemoveBoneAndChildren"
  2. If there are LODs, even when the first mesh is not rendered, the bones are not culled according to the current LOD, but according to the first mesh's
  3. Even when nothing is rendered (LOD is left empty), it will still have the bones of the first mesh. nothing
  4. The same applies with the other flag, "DiscardSkeleton"

To Reproduce

  1. Create a model with LODs
  2. Add the "RemoveBoneAndChildren" flag to one of the latter LOD meshes
  3. Test LOD with "Rendering Info" to see the number of bones doesn't change

Alternatively, download the vmdl file below for a quick setup (place in assets folder).

Expected behavior

The bones should be getting discarded on the fly using the current rendered mesh's flags.

It using only the first mesh for the bones is probably intentional, as all the files contain the armature (culling bones in one file still leaves them in the others), however, this issue isn't as it's recent behavior.

Media/Files

models.zip

Example of first mesh not having any culling, LOD1 has RemoveBoneAndChildren, and LOD2 has DiscardSkeleton:

https://github.com/Facepunch/sbox-issues/assets/86626409/99f16652-6e8e-4419-834a-e804bb670074

Additional context

No response

matekdev commented 3 months ago

holy carp

aylaylay commented 2 months ago

I've restored it to how it used to compile skeletons. Note that the bone count that's printed has always been the number of bones in the model, not the number of bones in the mesh.

Grodbert commented 2 months ago

I see, could've sworn they updated on the fly! That could be a cool feature, but that's for another issue.

I've confirmed it works by comparing 500 models with a weak LOD (remove fingers and penis bones) and then without.

WITHOUT: (Peak of 84 FPS)

no_lod

WITH LODs: (Peak of 112 FPS)

lod

An increase of 33%! Not too shabby for removing only 4 bones out of 32.

aylaylay commented 2 months ago

Fantastic