Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by scabnog · May 12, 2015 at 10:50 AM · shadershadersshaderlab

Does liberal use of #pragma shader_feature have an undocumented load time/parsing cost?

I have a shader that makes fairly liberal use of #pragma shader_feature (extending the standard shader), but the actual number of variations in use at runtime is very small.

The documentation states "Under all default settings, Unity loads the shaderlab Shader object into memory, but does not create the internal shader variants until they are actually needed.

This means that shader variants that are included into the game build can still potentially be used, but there’s no memory or load time cost paid until they are needed."

Contrary to my expectations after reading this, every time I add a new "#pragma shader_feature" to my shader and hit save, I have to wait an increasing amount of time for the editor to become responsive again. It appears that there might be a bunch of housekeeping going on that is related to the number of potential variations even if the compiler is not actually being invoked for all of them, since the delay appears to be increasing rapidly (possibly quadratic based on the number of features).

Is this expected behavior, or should I be able to make extensive use of #pragma shader_feature without large increases to load times? The load time is not dependent on the actual number of variations that are being used by the game, just the number that could potentially be used.

I'm going to have to merge a bunch of features into a few dedicated shaders if I'm pushing up against some limitation in the way that this feature is implemented. Please let me know if you have additional info on this.

Thank you.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Lex-DRL · Oct 08, 2015 at 04:09 PM

Same issue here. From docs, I'm pretty sure Unity should give no performance hit (or lag or any other "cost"). But in reality, seems like lag in the editor is linearly increases depending on total amount of possible variants. Since this behavior conflicts with what's told in docs, I'm assuming this is a bug.

Comment
Add comment · Show 1 · 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
avatar image fenderrex · Jan 04, 2017 at 06:48 AM 0
Share

what im getting on 940$$anonymous$$X preforms the same as my integrated graphics in the editor view but game view in massively improved. this is not the case if i use basic shader with less shader_feature's

avatar image
0

Answer by scabnog · Jan 04, 2017 at 08:21 PM

I recently had a response from Unity, and apparently it has been fixed in Unity 5.6. Some lookup tables were being created ahead of time for all the potential shader permutations, not just the ones being compiled. I haven't checked the beta release yet, but hopefully this issue should be resolved.

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

Shader - What is float3.xy? 1 Answer

Why does this shader show up black on iOS? 1 Answer

How do I keep an object lit when a light moves past it? 0 Answers

How to achive the same look? Which shaders to use? 2 Answers

Why does the shader make some transparent pixels non-transparent? 1 Answer


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