Hi, all !
I 'm working on a car paint shader .
So the problem is that i can’t make specular to change color .
I can’t solve this problem at all, but i think that is very easy to solve .
I really hope that someone can this figure out.
Thanks in advance for the answers ![]()
Here’s a picture on the fly :
Here is the shader :
Shader "Car Paint Shader" {
Properties {
_Color ("Diffuse Color", Color) = (1,1,1,1)
_SpecularColor ("Specular Color", Color) = (1,1,1,1)
_ShinPower ("Shininess", Range(0.01,1)) = 0.5
_GlossPower ("Gloss", Range(0.01,1)) = 0.5
_MainTex ("Diffuse", 2D) = "white" {}
_BumpMap ("NormalMap", 2D) = "bump" {}
_SpecularTex ("SpecularMap", 2D) = "gray" {}
_Cube ("ReflectionMap", CUBE) = "" {}
_ReflPower ("Reflection Power", Range(0.01,0.5)) = 0.25
}
SubShader {
Tags { "RenderType" = "Opaque" }
Cull Back
Zwrite On
CGPROGRAM
#pragma surface surf Car
#pragma only_renderers d3d9
#pragma target 3.0
inline fixed4 LightingCar (SurfaceOutput s, fixed3 lightDir, fixed3 viewDir, fixed atten)
{
fixed3 h = normalize (lightDir + viewDir);
fixed NdotL = dot (s.Normal, lightDir);
fixed diff = NdotL * 0.5 + 0.5;
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, s.Gloss * 256.0) * s.Specular;
fixed4 c;
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * (atten * 2);
return c;
}
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float3 worldRefl;
INTERNAL_DATA
};
sampler2D _MainTex, _BumpMap, _SpecularTex;
samplerCUBE _Cube;
fixed4 _Color;
fixed4 _SpecularColor;
float _ReflPower;
float _ShinPower;
float _GlossPower;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * _Color;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
float3 specGloss = tex2D(_SpecularTex, IN.uv_MainTex);
o.Specular = specGloss.r * _ShinPower;
o.Gloss = specGloss.g * _GlossPower;
o.Emission = texCUBE (_Cube, WorldReflectionVector (IN, o.Normal)).rgb * _ReflPower;
}
ENDCG
}
Fallback "Reflective/BumpedSpecular"
}
