Jump to content

GLTF Loading Speed


Josh

2,301 views

 Share

There are two aspects of GLTF files that have non-optimal loading speed. First, the vertex data is not stored in the same exact layout and format as our vertex structure. I found the difference in performance for this was pretty small, even for large models, so I was willing to let it go. Tangents can take a bit longer to build, but those are usually included in the model if they are needed.

The second issue is the triangle tree structure which is used for raycasting (the pick commands). I found the difference in debug mode was really significant when using a large (two million poly) mesh. Here are the numbers. The big concern is building the pick tree in debug mode, which takes two minutes using this model.

GLTF Loading Speed (milliseconds)

Release Mode

  • Vertices only: 1249
  • Vertices + build tangents: 1276
  • Vertices + build collision: 5563

Debug Mode

  • Vertices only: 3758
  • Vertices + build tangents: 12453
  • Vertices + build collision: 120,000

I was able to improve this speed significantly by saving vertex and pick tree data to a cache file after processing.

Release Mode

  • Cached data: 1233

Debug Mode

  • Cached data: 2707

This is sort of a halfway step between using GLTF natively and converting to our faster-loading GMF2 file format.

I like the idea of keeping all files in easily-accessible formats like DDS and GLTF, but there are some big questions. Where and how should the mesh cache files be stored? A published game will not necessarily have write access for files in its own install folder, so any files written should be in the user Documents or AppData folders. How should the GLTF file be identified? By checksum? By full file path? The full file path will change when the game is installed on another computer. Should the mesh cache files be shipped with the game, or generated the first time it is run? Do we even need to worry about caching when release mode is used? It seems like only debug mode has a significant performance problem, so maybe this should be something that only gets used during development?j I need to think about this.

  • Like 1
 Share

4 Comments


Recommended Comments

Another possibility would be to add new GLTF extensions that embed the raycast structure in the file, but that adds an extra step in the workflow of resaving the GLTF.

  • Like 1
Link to comment

Another option is to compile the raycast code as a separate library in release mode and pull that into the project so that the fast code with no debugging is always being used.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...