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
0
Question by Max_Bol · May 12, 2016 at 07:26 PM · shadersshader programmingopacityprocessghost

Modifying shaders' snippets.

Greetings all!

I was wondering what is the best practice to modify some of Unity's existing shaders snippets. To be more precise, I'm currently looking at the Standard and Standard (Specular setup) shaders because I wish to change how their Opacity output is managed.

My goal is to build a ghost/spirit shader based on Unity 5 physically based shader, meaning I wish to make it so that the Z-buffer is read and only the first faces of the mesh is shown through the transparency. It's nothing that strange and it has been done plenty of times with the legacy shaders.

It's not only for my project, but also to learn more about Unity physically based shaders management so please, don't post anything about some shaders from the store asset as it's not the point of my question.

Okay. Now the thing is that I now understand how the default standard shader is working in Unity as I looked up the .shader and .cginc files. That much is clear and I'm able to work with it.

But the thing is that I would like to modify some of them for a project, but as .cginc files aren't directly within the project files like the ones you can get for learning purpose, I'm not sure how I can replace the content of the shaders' snippets within a project without risking some conflict between the hidden and modified snippets.

Does importing a .cginc file in the unity project with snippets automatically replace the existing default snippets or will I have to literally recreate the whole standard shader and its whole set of .cginc files with modified snippets references just for the sake of modifying a single part of the rendering process? (That's 1 shader + 9 .cginc files to recreate and modify with different snippets names. That's would be a huge pain in the butt to be honest and I'm not even thinking about the risk of errors.)

Thanks in advance!

P.S. The reason why I'm trying to do it this way instead of just building the shader from scratch is because I would like to add this within the Rendering Modes of the Standard and Standard (Specular Setup) shaders. I think about adding a X-Ray (0 to 1) slider that makes overlapping parts from the same mesh invisible if behind another part of the same mesh. (So that it's possible to make a material that is like the current fade or transparent, but using the same shader to make z-based fade and transparency.

If this is possible and I succeed, I'll add the file as free asset on the Asset Store. ;)

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

1 Reply

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

Answer by Max_Bol · May 15, 2016 at 05:41 PM

After testing things out, I have found out that you can modify snippets and any hidden content in Unity by using the same name convention within your own project. Any hidden system (or shader in this case) files functions are automatically replaced by those in the project's folder.

So, you can modify any shader snippets by creating .cginc file with the modified snippets properly named, but it seems like you have to copy the whole original file and then modify it for it to work properly as, once the reference within the .cginc files change, it "forget" about the original .cginc file.

That's the result of my tests. Due to this, I looked for a less perfect yet really useful solution you can find here : Link to the forum page

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

43 People are following this question.

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

Related Questions

Making objects less transparent when light hits them (lighting only shader) 1 Answer

Grabpass 2D water reflection, UV issue 0 Answers

How to move alpha mask along the floor plane as the user (camera) moves 1 Answer

Is it possible to avoid writing to certain g-buffers? 1 Answer

My shader code is having an error with returns at lines 50 and 60. 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