Hi, I keep getting the following error on a custom shader,
“Shader error in […]: D3D shader assembly failed with: (##): error X5204: Read of uninitialized component(*) in r0: r/x/0 v/x/1 b/x/2 *a/x/3”
BUT!
a. the shader used to work perfectly with an older version of unity, something like 4 updates back,
b. it works perfectly on my mac, with the same version.
Been looking around a lot, and stripped it down to the bare minimum, but there is no way to get the rgba plugged in there for the PC version it seems…
Shader "Custom/DepthBaked" {
Properties {
_Diffuse ("Diffuse", 2D) = "white" {}
_Normal ("Normals", 2D) = "bump" {}
_Specular ("Specular", 2D) = "white" {}
_SpecInt ("Specular max intensity", range(0.0,10.0)) = 4.0
_SpecMax ("Specular max falloff", range(300,100)) = 180.0
_Depth ("Depth map", 2D) = "white" {}
_Parallax ("Depth", range(0,0.05)) = 0.01
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 600
CGPROGRAM
#pragma surface surf BakedDepth nolightmap
sampler2D _Diffuse;
sampler2D _Depth;
sampler2D _Specular;
sampler2D _Normal;
fixed3 _SpecTint;
fixed _SpecInt;
fixed _SpecMax;
fixed _Parallax;
struct SurfaceOutputDeep {
fixed3 Albedo;
fixed4 SpecularC;
fixed3 Normal;
fixed Emission;
fixed Depth;
fixed Alpha;
fixed Specular;
};
struct Input {
float2 uv_Diffuse;
float2 uv_Depth;
float3 viewDir;
float2 uv_Specular;
float2 uv_Normal;
};
half4 LightingBakedDepth (SurfaceOutputDeep s, half3 lightDir, half3 viewDir, half atten){
fixed4 c;
half3 h = normalize(viewDir + lightDir);
float nh = max(0, dot(s.Normal, h));
float spec = pow(nh, (s.SpecularC.a+0.05)*_SpecMax*5) * _SpecInt *max(0,atten);
c.rgb = spec * s.SpecularC.rgb * _LightColor0.rgb;
return c;
}
void surf (Input IN, inout SurfaceOutputDeep o) {
half h = tex2D(_Depth, IN.uv_Depth);
float2 offset = ParallaxOffset(h, _Parallax, IN.viewDir);
IN.uv_Diffuse += offset;
IN.uv_Specular += offset;
IN.uv_Normal += offset;
o.Albedo.rgb = tex2D(_Diffuse, IN.uv_Diffuse).rgb;
o.SpecularC = tex2D(_Specular, IN.uv_Specular).rgba;
o.Normal = UnpackNormal(tex2D(_Normal, IN.uv_Normal));
o.Depth = tex2D(_Depth, IN.uv_Depth);
}
ENDCG
}
FallBack "Diffuse"
}
Any and all help or helpfull idea is greatly welcome, if I can get past that hurdle, I’ll be able to push the shader to what it is I’m looking for.