- Home /
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: 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.
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 ;)
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 :)
Yep. It would actually be similar to the Unity water shader.
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?
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.
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.
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.