Volumetrics-io / mrjs

An extensible WebComponents library for the Spatial Web
https://mrjs.io
MIT License
160 stars 9 forks source link

notes - figure out why we have way too many draw calls / fix for reducing the number of redundant glPrograms #652

Open hanbollar opened 4 months ago

hanbollar commented 4 months ago

Linking

related to #651

Problem

Description of the problem including potential code and/or screenshots as an example

Solution

Quick explanation of change to be done

Breaking Change

If this is a breaking change describe the before and after and why the change was necessary

Notes

Notes and any associated research or links


Required to Merge

render[bot] commented 4 months ago

Your Render PR Server URL is https://examples-mrjs-pr-652.onrender.com.

Follow its progress at https://dashboard.render.com/static/srv-cp17fegl6cac73emhid0.

hanbollar commented 4 months ago

the issue

the issue is due to too many materials being created with new that are redundant to each other - where their differences are just selected uniform variables

the supposed fix i found

instead of doing new everywhere, we should grabbing from a catalogue of materials unless a user creates something specific (for normal and debug items) and use the uniforms properly for differences.


implementing now to confirm

hanbollar commented 4 months ago

down from 22 --> 14 draw calls --> still looking into

Screenshot 2024-05-13 at 3 13 30 PM
hanbollar commented 4 months ago
Screenshot 2024-05-13 at 7 28 31 PM

still looking into ways to reduce the number of glPrograms, but here's where we're at for now

hanbollar commented 4 months ago
Screenshot 2024-05-16 at 5 11 50 PM
hanbollar commented 4 months ago
Screenshot 2024-05-16 at 5 33 32 PM

same out come

hanbollar commented 4 months ago

things to do:

hanbollar commented 4 months ago
  • number of draw calls depends on number of models in scene with differing materials (including text and otherwise)
  • draw call count changes depending on what is within frustum area
  • glprogram count increases as scene loads in (and scroll down to new items) - until has loaded int data all items from scene

things to do:

  • [ ] see if can optimize troika material setup / reusability
  • [ ] instancing geometry (that's a future pr)
  • [ ] LOD - i think we're okay on this being something user specified if they want to define that in the scene directly

we're going to need an actual material caching system setup - same thing with geometry instancing

hanbollar commented 4 months ago

turning this into a draft since we'll be doing a rework of MeshInstancing and MaterialInstancing in a future pr and those are super relevant to this getting improved