vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
467 stars 75 forks source link

Writing gltf file (ModelRoot.Save) is slower after updating to version 17 from version 15 #53

Closed AhmedMakhlouf closed 4 years ago

AhmedMakhlouf commented 4 years ago

Saving a specific gltf file (55MB) takes 2.3 mins using version 15, writing the same file in version 17 took 5 mins (with or without WriteSettings.Validation)

vpenades commented 4 years ago

hmmm.... 55mb is quite a lot.... could it be possible to share the model? or send it to me privately?

AhmedMakhlouf commented 4 years ago

I can share it with you privately

vpenades commented 4 years ago

I can reproduce the issue, and I've found the problem happened between version 15 and 16... I'll continue investigating...

vpenades commented 4 years ago

Okey, this is what I found so far:

I'll see if I can add some optimizations to the validation code... but I guess you want to load/save fast, which can be solved with the SkipValidation in the next version.

BTW, the model is very slow to render, checking the contents I've noticed it uses thousands of materials, and many of the share the exact same properties (color and metallic).... you could improve the rendering performance by reusing the same materials on multiple meshes.

I don't know how you're building your model, but, if you're using SceneBuilder's toolkit, you can let the library find shared materials by NOT setting the MaterialBuilder's names. If you leave the material names to null, the library will be able to find matching materials and reuse them.

AhmedMakhlouf commented 4 years ago

Thanks a lot for the effort, we will wait for the stable version. Looking forwards

Kind regards Ahmed Makhlouf Game Developer Tel: (+20) 1096465010

On Thu, Jun 18, 2020 at 11:12 PM Vicente Penades notifications@github.com wrote:

Okey, this is what I found so far:

  • The current development branch (master) has the SkipValidation fixed, so, if you're in a hurry, you could clone the repository and compile it, at least until I release a new version of the library (in one or two weeks)
  • The increased load/save time seems to be due to some more strict hierarchy validation checks. Given that there's 40.000 nodes in the scene (wow!), it makes sense it takes a while to traverse the whole tree.

I'll see if I can add some optimizations to the validation code... but I guess you want to load/save fast, which can be solved with the SkipValidation in the next version.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vpenades/SharpGLTF/issues/53#issuecomment-646308311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIJJE7UGHWASK42REJEVGUDRXJ7MRANCNFSM4OBRDDIQ .

vpenades commented 4 years ago

Version 18 is up.

In my tests, the load/save operations with your file are down to 1 minute.

Without validation, just a few seconds.

Let me know if you have any other problem...