• 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 Caleb_1701 · Mar 01, 2016 at 03:53 PM · shadershadersmaterialsreflectionspecular

how to do color separation in specular reflections

Does anybody know if it's possible to have a material's specular reflections be different colors, sort of like what you would see in a puddle of oil or something? This is more or less what I'm looking for: alt text I did this in Blender using the color ramp on the specularity, applied on a quad with a dragon-scales normal map. But I have no idea how to do it in Unity. I've looked in the documentation in the section about shaders, but I can't find anything about that kind of color separation. If I want to get this effect, will I have to write my own shader? I don't know anything about writing shaders.

black-scales.png (252.5 kB)
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 Graphics_Dev · Mar 01, 2016 at 04:02 PM

Use the standard shader with specular setup, then plug texture into specular input. The Specular levels for the material are controlled by the color (rgb) channels of the texture, and the Smoothness levels for the material are controlled by the Alpha channel of the same texture.

Note: This will not be physically accurate because the color won't change based on viewing angle.

Let me know if this helps ;)

Comment
Add comment · Show 6 · 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 multinfs · Mar 01, 2016 at 07:32 PM 0
Share

To make it based on viewing angle though you'd need to make a new shader that reflects different colors depending on the direction you're looking at it, not too hard math here but it might be a bit trickier to get the shader put together :)

avatar image Graphics_Dev multinfs · Mar 01, 2016 at 07:46 PM 0
Share

Yep. It would actually be similar to the Unity water shader.

avatar image Caleb_1701 · Mar 01, 2016 at 09:17 PM 0
Share

So I will have to write my own shader? I haven't actually written a shader before; the built-in ones have always been good enough. Any tips or tutorials? Anything that could help me get started?

avatar image Graphics_Dev Caleb_1701 · Mar 01, 2016 at 09:27 PM 0
Share

If you want physical accuracy you will need to write your own or buy one, but you should be able get good results from the standard shader as well.

avatar image Graphics_Dev Caleb_1701 · Mar 01, 2016 at 09:34 PM 0
Share

Start reading here if you want to get started with shaders. Also, there is a section on the forums for help with shader code.

http://docs.unity3d.com/$$anonymous$$anual/SL-Reference.html

You can download the built-in shaders here to use as a reference or starting point:

http://unity3d.com/get-unity/download/archive

Please mark my answer as correct to close the question.

avatar image multinfs Caleb_1701 · Mar 01, 2016 at 11:18 PM 0
Share

One resource I found helpful is this youtube tutorial: https://www.youtube.com/playlist?list=PLV4HCa5XqFT02gZOZ_Jb_A66wqDhZ$$anonymous$$CkN

It's a tutorial series made by unitycookie and there he explains and shows how you add different features to a shader.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

UGUI button gray shader 1 Answer

Why do materials created at runtime show up incorrectly in the inspector? 1 Answer

Lit, Simple Lit and Complex Lit Shaders are not Avaiable 1 Answer

Bast way to combine multiple materials into one 0 Answers

Adding specular to shader 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