Hi,
we recently tried importing our Unity 4.6 project to Unity 5. Everything works fine so far except a strange issue with a custom shader. Every object using that shader seems to have very pronounced specular highlights (especially on sharp edges). I attached a screenshot with an example. Note that the object has a specular color of pure white (255, 255, 255), but with the same shader and material settings did not have those white points in Unity 4. Setting the color to pure black (0, 0, 0) solves the problem, however at the cost of no specularity at all.
I read that Unity 5 doubles the intensity of lights, but this seems not to be the issue (also it should only effect custom lightning functions if I understand it correctly, which we do not use). Here is the shader code, any help would be appreciated:
Shader "Damage, Rust, Occlusion/Bumped Specular Glow Reflection" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_RustColor ("Rust Color", Color) = (1,0,0,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
_Damage ("Damage", Range (0, 1)) = 0
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
_GlowMap ("Glow Map (RGBA)", 2D) = "black" {}
_ComboMap ("Combination Map (RGBA)", 2D) = "white" {}
_Cube("Reflection Cubemap (RGB)",Cube)=""{}
_ReflectionFactor ("ReflectionFactor", Range (0, 1)) = 0.35
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 400
CGPROGRAM
#pragma surface surf BlinnPhong
#pragma target 3.0
samplerCUBE _Cube;
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _ComboMap;
sampler2D _GlowMap;
float4 _Color;
float _Shininess;
float _ReflectionFactor;
struct Input {
float2 uv_BumpMap;
float2 uv2_ComboMap;
float3 worldRefl;
INTERNAL_DATA
};
uniform float4 _RustColor;
uniform float _Damage;
void surf (Input IN, inout SurfaceOutput o)
{
float2 uv1=IN.uv_BumpMap; //uv1.y+=0.108; uv1.x+=0.031f;
half4 tex = tex2D(_MainTex, IN.uv_BumpMap);
o.Albedo = _Color.rgb;
o.Gloss = tex.a;
o.Alpha = tex.a * _Color.a;
o.Specular = _Shininess;
o.Normal = UnpackNormal(tex2D(_BumpMap, uv1));
float4 glow = tex2D( _GlowMap, uv1 );
float4 texcol = tex2D( _MainTex, uv1 );
float4 cmSource2 = tex2D( _ComboMap, IN.uv2_ComboMap );
// R = OCCLUSION
// B = DAMAGE
// G = RUST
float Rust=_RustColor.w*(1-cmSource2.g);
float Occ=cmSource2.r;
half4 c;
c.rgb = o.Albedo;
float cSpec=c.x;
// remove rust from specular color
c.rgb=c.rgb*(1-Rust);
float3 rc=_RustColor*Rust;
// add texture diffuse
c.rgb=c.rgb*texcol.rgb;
// add colored rust
c.rgb+=0.7*rc*cSpec;
c.rgb+=0.2*rc;
//add damage
c=c-_Damage*(1-cmSource2.b)*0.5;
//add occlusion
c=c*Occ;
o.Albedo=c.rgb;
float3 worldRefl = WorldReflectionVector (IN, o.Normal);
float4 reflcol = texCUBE (_Cube, worldRefl);
reflcol *= tex.a*Occ*(1-Rust);
o.Emission = reflcol.rgb*_ReflectionFactor+glow;
}
ENDCG
}
FallBack "Bumped Specular"
}
