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 /
avatar image
1
Question by SamBaker · Oct 14, 2016 at 06:42 PM · shaders

Is it possible to tell Unity not to auto-upgrade a shader?

I have a Unity 5.4 project that I need to work with Unity 5.1 also.

There's a shader using the matrix unity_ObjectToWorld in 5.4. I'm using conditional compilation:

 #if UNITY_VERSION < 540
   return mul(UNITY_MATRIX_V, mul(_Object2World, float4(pos, 1.0))).xyz;
 #else
   return mul(UNITY_MATRIX_V, mul(unity_ObjectToWorld, float4(pos, 1.0))).xyz;
 #endif

This works in both versions of Unity but as soon as I reimport the shader in Unity 5.4 it auto-upgrades the shader and replaces _Object2World in the conditional with unity_Object2World, breaking the 5.1 version of the project.

Any ideas for a fix that will allow me to keep this backwards compatibility? Is there anything I can add to tell Unity not to auto-upgrade the shader file?

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 txzeenath · Oct 15, 2016 at 11:53 AM 0
Share

There is a line you can put in a file to prevent upgrade I believe. I just can't find where I read about it now :/

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by JakeTurner · Oct 18, 2016 at 09:15 AM

From the 5.4 release notes:

Shaders: Added ability to exclude shaders from automatic upgrade by having "UNITY_SHADER_NO_UPGRADE" anywhere in shader source file.

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 SamBaker · Oct 19, 2016 at 04:55 PM 0
Share

Thanks - putting it in a comment did work. Crowd-sourced documentation search FTW.

avatar image
0

Answer by SamBaker · Oct 14, 2016 at 09:25 PM

I've found a workaround until a better solution comes along.

I renamed the compat.cginc file with the conditional compilation in it, to compat.cginchack. So far that stops Unity from auto-upgrading it. It also doesn't show up in Monodevelop so it's not great but it gets me by for now. You can #include "compat.cginchack" fine though.

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 tanoshimi · Oct 15, 2016 at 06:29 AM 0
Share

Who downvoted this? Seems like a good workaround to me - thanks for sharing :)

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

up the contrast (0-1) in shader code 0 Answers

ShaderLab CG question 0 Answers

Make a complex object semi transparent without changing it 2 Answers

Images with gradient poorly managed by Unity 1 Answer

Shadow sprite rotation regardless of the light source 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