Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve: Reduce the materials. Too many effect materials are exist. #15

Closed
mob-sakai opened this issue Jan 14, 2018 · 11 comments
Closed
Milestone

Comments

@mob-sakai
Copy link
Owner

Too many effect materials are exist.
Therefore, we generate effect materials as sub-asset.

image

@mob-sakai mob-sakai added this to the ver.2.0.0 milestone Jan 14, 2018
@mob-sakai
Copy link
Owner Author

Check build size

@mob-sakai
Copy link
Owner Author

OK, unused shader variants and materials are excluded from build.

@mob-sakai mob-sakai reopened this Jan 14, 2018
@mob-sakai
Copy link
Owner Author

mob-sakai commented Jan 14, 2018

UI-Effect material include 112 effect material variants as sub-asset.

UI-Effect
├ UI-Effect_Add
├ UI-Effect_Add_Fast
...
└ UI-Effect_Pixel_Sub_Medium

Sub-asset materials are hidden in project view & object picker window.
Apparently, the displayed materials became very few.
This is a great result :)
Of course, unused shader variants and materials are excluded from build.

Version UI-Effect.shader UI-EffectCapture.shader Materials
main-asset (ver.1.4-) 121KB 14.9KB about 7.0KB
sub-asset (ver.2.0-) 119KB 14.9KB 6.8KB

image

@mob-sakai
Copy link
Owner Author

OMG.
All sub-assets are included in asset bundle.

@mob-sakai
Copy link
Owner Author

mob-sakai commented Jan 16, 2018

  • prefab_1~4 contains UIEffect with UI-Effect_Sepia_Set_Fast material.
    • Asset bundle name is prefab_1~4
  • Asset bundle shared_0 contains following shared asset.
    • Material UI-Effect_Sepia_Set_Fast
    • Shader UI-Effect
    • Small texture Unity-chan
  • Load LZ4 compressed asset bundles, load asset and instantiate prefab in a frame (not async).

@mob-sakai
Copy link
Owner Author

mob-sakai commented Jan 16, 2018

Test on android (5 times average).
In ver.2.0, first loading is too late...

Version Build size (LZ4) Instantiate (first) Instantiate (later)
main-asset (ver.1.4-) 28KB 32.99ms, 10.1KB 5.73ms, 8.2KB
sub-asset (ver.2.0-) 340KB 153.14ms, 10.1KB 5.96ms, 8.2KB

@mob-sakai
Copy link
Owner Author

mob-sakai commented Jan 16, 2018

hmm...
Use ScriptableObject for material container. -> NG.

@mob-sakai
Copy link
Owner Author

OK.
Let's fix the default to sub-asset mode and switch it to main-asset mode.

@mob-sakai
Copy link
Owner Author

mob-sakai commented Jan 16, 2018

Sub-asset mode (ver.2.0 default)

  • Compact.
  • UI-Effect material include 112 effect material variants as sub-asset.
  • Sub-asset materials are hidden in project view & object picker window, and only UI-Effect material is displayed.
  • Unused shader variants and materials will be excluded from build, but they will be included in AssetBundle.
UI-Effect
├ UI-Effect_Add (Hidden)
├ UI-Effect_Add_Fast (Hidden)
...
└ UI-Effect_Pixel_Sub_Medium (Hidden)

image

Main-asset mode (ver.2.0 optional)

  • If necessary, generate effect material as asset.
  • All generated materials are displayed in project view & object picker window.
  • Unused shader variants and materials will be excluded from build and AssetBundle.
  • We recommend this mode only when "Prefabs contains UIEffect" is included in the asset bundle.

@mob-sakai
Copy link
Owner Author

mob-sakai commented Jan 16, 2018

How to switch mode

I have 2 ideas.

  1. Is Generated/Generated_UI-Effect_*** material exist?
    • To Main-asset mode: Generate Generated/Generated_UI-Effect_*** material.
    • To Sub-asset mode: Delete Generated/Generated_UI-Effect_*** material.
  2. Using script define symbol
    • ASSETBUNDLE_UI_EFFECT

@mob-sakai
Copy link
Owner Author

Adopted: Using script define symbol
UIEFFECT_SEPARATE

@mob-sakai mob-sakai changed the title Too many effect materials are exist. [Fixed: 2.0.0] Too many effect materials are exist. Jan 24, 2018
@mob-sakai mob-sakai reopened this Jan 24, 2018
@mob-sakai mob-sakai modified the milestone: ver.2.0.0 Jan 24, 2018
@mob-sakai mob-sakai changed the title [Fixed: 2.0.0] Too many effect materials are exist. Bug: Too many effect materials are exist. Mar 29, 2018
@mob-sakai mob-sakai changed the title Bug: Too many effect materials are exist. Improve: Reduce the materials. Too many effect materials are exist. Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant