Shapes Lite?

Avatar
  • updated
  • Under Consideration

After installing Shapes for our mobile game so that we can get improved line drawing quality, we noticed the build size went up by 3MB, which is quite a bit if you're a mobile or WebGL game. Almost all of the size is due to Shapes files that are in Resources folders for immediately mode usage. "Shapes Assets" takes quarter MB and the rest is mostly all the various shaders and materials. No doubt these shaders will only grow as more features are added to Shapes in the future. It seems like I can probably reduce the size of the Shapes Assets by reducing the detail levels significantly on the various primitives that we don't use (in Shapes Settings). But it would be GREAT to also have a way to select which shapes we actually are using in the game and also which blend modes. Then when we generate the shaders, it wouldn't bother creating or loading materials and shaders for those variations. Then if some future unaware coder on our team did try to use them in immediate mode, Shapes would just use a magenta shader or something obvious to show that the shader wasn't generated. Or even just a warning message and graceful fail would be fine.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
4.1.3
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
stuart denman

As a followup, we manually deleted the materials and shaders that we're not using and that worked, but having this feature would allow us to more easily add Shapes features and primitives to the game in the future. Likewise after reducing the quality of the primitives to save memory, there's not a convenient way to restore the detail levels to the default values if, in the future, we start using one of these other primitives. So having a way to disable certain primitives (but keep the default detail levels) would solve this problem.

Avatar
Freya Holmér creator
  • Under Consideration

this is a complicated one unfortunately, the reason they are all always included, is because with immediate mode drawing, there's no way for me to predict which assets are used or unused, and so builds will have missing shaders/assets if they're not included.

I can possibly implement some sort of, opt-out, where you could basically do what you did, untick things you know you aren't using, but then they're automatically excluded.
I'd have to think about it! not entirely sure how to architect that system

Avatar
stuart denman

Thank you for considering this feature! 


Yeah opt-out is exactly what I was thinking too. Include all of them by default and then if you opt-out of a primitive and/or blend mode, any immediate mode commands for opt-out primitives that you execute would log a warning and fail. 

Right now when we manually deleted the shaders+materials, we get hundreds of warnings about missing materials upon first use of Shapes. The primitives we do use work fine (we are using immediate mode for these). If we try to use immediate mode primitives for deleted materials then it says that it found a null material, followed by a NullReferenceException.