Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by SuperHero · Feb 08, 2016 at 03:50 PM · shadermaterialassetbundle

About shaders included in assetbundles

Dear all.

I created an assetbundle which includes all shaders being used in a scene, and some 3D models using those shaders are bundled separately. In short,

  1. Asset Bundle 0 : shared shaders

  2. Asset Bundle 1 : A 3D model. Its material uses a shader in 'Asset Bundle 0'.

  3. Asset Bundle 2: A 3D model. This one also has a material uses a shader in 'Asset Bundle 0'.



Here is the problem.
When I load Asset Bundle 0, 'Shader.Parse' is called for all shaders included
in Asset Bundle 0.
So I expected all necessary shader compilations have to be done here,
but after this, when I load Asset Bundle 1 and Asset Bundle 2,
'Shader.Parse' is executed again and again on a same named shader which is included in Asset Bundle 0 although its compilation would have done when Asset Bundle 0 had loaded.
(I caught this result from Unity Profiler)


Are they different shader instances even though its shader name & code is same?
If they are, did I miss some necessary settings to share shaders between asset bundles?
I have spent half day to find a solution but all I found are out-dated ones related to 'BuildPipeline.PopAssetDependencies'.

A post below was quite useful but not enough.
http://forum.unity3d.com/threads/new-assetbundle-build-system-in-unity-5-0.293975/


Did I miss something important?
If so, how do I share custom shaders correctly among assetbundles and avoid unnecessary shader compilations?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sewy · May 13, 2021 at 02:09 PM 0
Share

Hello, sorry to necro this post, but how do you build AB1 and AB2 without shaders? Was it enough to assign shader to AB0 and build it together? I have multiple scenes which are using the same shaders over and over, but because I am building the scene as AB, unity is packing every shader multiple times to every scene AB which takes a lot of time. I was thinking about separating the shaders to their own AB as you are.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SuperHero · Feb 12, 2016 at 12:56 AM

Solved.
AssetBundle0 has to be built with 1 & 2.
and after loading it in a scene, I have to keep shader instances inside AssetBundle0 if I want to control its deletion time.
But still there are some problmes.
1. Built-in shaders: even though I set them as preloaded shader, still it takes long time to compile them on runtime.
2. How do aseetbundled materials work with 'Always includes shaders' on Graphics setting?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Anyway to detect for missing material from Renderer component? 1 Answer

Sorting (rendering) order of materials in mesh renderer 1 Answer

I can see the objects through the terrain. 1 Answer

Material.SetTexture doesn't work if not "_MainTex" 0 Answers

Assetbundled materials / Always Included Shaders / Preloaded Shaders 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges