When using ParallaxOffset in this shader the faces are lit by Directional Light improperly?
//Shader written by Keehan Roberts (@keehan12)
Shader "Custom/Reflective/Diffuse" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
_Detail ("Detail Map", 2D) = "white" {}
_DetailColor ("Detail Color", Color) = (1,1,1,1)
_HeightMap("Height Map", 2D) = "white" {}
_Height("Height", Range(0,.125)) = 0
_Occlusion ("Height Occlusion", 2D) = "white" {}
_Reflective("Reflective (RGB)", 2D) = "white" {}
_ReflectiveColor ("Reflection Color", Color) = (1,1,1,0.5)
_Emissive("Emissive (RGB)", 2D) = "white" {}
_EmissiveColor ("Emissive Color", Color) = (1,1,1,0.5)
_Cube ("Reflection Cubemap", Cube) = "_Skybox" {}
}
SubShader {
LOD 200
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma target 3.0
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Detail;
sampler2D _HeightMap;
float _Height;
sampler2D _Occlusion;
sampler2D _Reflective;
sampler2D _Emissive;
samplerCUBE _Cube;
fixed4 _Color;
fixed4 _DetailColor;
fixed4 _ReflectiveColor;
fixed4 _EmissiveColor;
struct Input {
float2 uv_MainTex;
float2 uv_Detail;
float2 uv_HeightMap;
float2 uv_Occlusion;
float2 uv_Reflective;
float3 viewDir;
float2 uv_Emissive;
float3 worldRefl;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o) {
float2 viewDir = ParallaxOffset(tex2D(_HeightMap, IN.uv_HeightMap).rgb, _Height, IN.viewDir);
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex) * _Color;
fixed4 reflcol = texCUBE(_Cube, IN.worldRefl);
fixed4 occ = tex2D(_Occlusion, IN.uv_Occlusion) * _Color;
fixed4 detail = tex2D(_Detail, IN.uv_Detail) * _DetailColor;
fixed4 ref = occ * tex2D(_Reflective, IN.uv_Reflective - viewDir) * _ReflectiveColor;
reflcol *= tex.a;
o.Albedo = detail.rgb + (tex.rgb * occ.a) + (reflcol.rgb * _ReflectiveColor.rgb) * ref.a;
o.Alpha = reflcol.a * _ReflectiveColor.a * (reflcol.a * _ReflectiveColor.a);
o.Emission = (tex2D(_Emissive, IN.uv_Emissive - viewDir).a * _EmissiveColor) * (reflcol.rgb * _ReflectiveColor.rgb);
o.Normal = tex2D(_HeightMap, IN.uv_HeightMap);
}
ENDCG
}
FallBack "Legacy Shaders/Reflective/VertexLit"
}