MaterialX icon indicating copy to clipboard operation
MaterialX copied to clipboard

Performance Enhancements for Web Viewer

Open kwokcb opened this issue 3 weeks ago • 0 comments

Performance Enhancements

  • Add in dirty/refresh mechanism triggered by actions which require a re-render. Reduce big performance overhead of constantly re-rendering which can be quite slow for more complex shading models such as OpenPBR.
  • Add in texture cache reuse using ThreeJS cache. Handle http/blob/data encodings properly.
  • Add in sphere geometry as this is the lightest weight geometry performance-wise.

Implementation Changes

  • Simple implementation of adding in a refresh counter which get's incremented when an action calls to "require an update".
  • Refresh look still does constant polling but will only re-render if refresh counter is > 0.
  • The actions where refresh requests are added include:
    • material, geometry load (menu or drag-drop)
    • texture load
    • transform changes: camera, viewport resize , turntable
    • background texture toggle

Note: There is no refresh queue management (e.g. compressing the number of requests) so that all camera, property edits, turntable updates are queued. This will never be worse than what occurs before this change and is thus as "safe" as before (no refreshes will be "list". Re-render is gated by how often ThreeJS triggers a refresh/render.

@jstone-lucasfilm : This makes OpenPBR not max-out the GPU on my laptop and should help a fair bit with scenes with more textures such as the chess set as the texture cache is used. Will also help drag-drop.

Example

  • OpenPBR with negligible GPU usage (was 100% on my Windows laptop before, about 40% on a Mac M1).

image

kwokcb avatar Jun 18 '24 15:06 kwokcb