- Home /
Shader returning lots of ambiguous errors
I have the following code:
Shader "VXR/Car" {
Properties {
_MainCol ("Colour", Color) = (1,1,1,1)
_PaintTex ("Paint Texture", 2D) = "" {}
_PaintCol ("Secondary Colour", Color) = (1,1,1,1)
_AO ("Baked Ambient Occlusion", 2D) = "white" {}
_Cube ("Cubemap", CUBE) = "" {}
_RimPower ("Reflection Strength", Range(0.5,8.0)) = 3.0
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_BadgeTex ("Badge Texture", 2D) = "" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf BlinnPhong
fixed4 _MainCol;
sampler2D _PaintTex;
fixed4 _PaintCol;
sampler2D _AO;
samplerCUBE _Cube;
float _RimPower;
half _Shininess;
sampler2D _BadgeTex;
struct Input {
fixed4 uv_MainCol;
float2 uv_PaintTex;
fixed4 uv_PaintCol;
float2 uv_AO;
float3 worldRefl;
float3 viewDir;
float2 uv_BadgeTex;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = 1.0 - tex2D (_PaintTex, IN.uv_PaintTex).a;
o.Albedo *= _MainCol;
o.Albedo += _PaintCol * tex2D(_PaintTex, IN.uv_PaintTex).a;
o.Albedo *= -tex2D (_BadgeTex, uv_BadgeTex).a;
o.Albedo += tex2D (_BadgeTex, uv_BadgeTex).a * tex2D (_BadgeTex, uv_BadgeTex).rgb;
o.Albedo *= tex2D (_AO, IN.uv_AO).rgb;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = texCUBE (_Cube, IN.worldRefl) * pow (rim, _RimPower);
o.Gloss = _SpecColor.a;
o.Specular = _Shininess;
o.Alpha = 1.0;
}
ENDCG
}
FallBack "Specular"
}
It was all working until I added _BadgeTex, and then it returned 33 similar errors; Material doesn't have a --- property '---'
Any Help would be great, thanks in advance.
Answer by Owen-Reynolds · Jan 23, 2014 at 04:12 PM
There's probably a single real error in the shader, hopefully near the top of the error list. "Missing property" are just Unity pile-on errors, sprayed each frame by the Editor when the shader is broken in a particular way.
I don't see the error off-hand. Typing a line at a time can help. You might be running into too many texture lookups. Tex2D is expensive, but a real graphics card can handle at least 16. Even so, might be faster and cleaner to get badgeTexture just once: half4 bCol = tex2D(_BadgeTex...);
and then o.Albedo+=bCol.a * bCol.rgb;
and so on.
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Multiple materials on same object 0 Answers
How to apply different textures to one model? 1 Answer
Texture2D to Texture3D 2 Answers
Tracing in Unity3D 2 Answers