Hello, I am trying this shader below from Cg Programming/Unity/Billboards - Wikibooks, open books for an open world
and I keep getting error:
Material doesn’t have a texture property ‘_MainTex’.
Along with these errors:
Unsupported: Cg shader for billboards
Unsupported: Cg shader for billboards
done. [Time: 84.483981 ms]
Unsupported: Cg shader for billboards
Shader error in 'Cg shader for billboards': FindCgParams failed (compiling for flash) at line 7
(Filename: wikibillboard Line: 7)
Shader error in 'Cg shader for billboards': Vertex program 'vert': unknown input channel 'tex' at line 7
(Filename: wikibillboard Line: 7)
Shader error in 'Cg shader for billboards': Shader program had errors at line 8
(Filename: wikibillboard Line: 8)
Anyone see any problems with this shader? I can’t get it working. I’m trying to learn how it works, but hard when doesn’t work from the start!
Shader "Cg shader for billboards" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// User-specified uniforms
uniform sampler2D _MainTex;
struct vertexInput {
float4 vertex : POSITION;
float4 tex : TEXCOORD0;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
};
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_P,
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
- float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
output.tex = input.tex;
return output;
}
float4 frag(vertexOutput input) : COLOR
{
return tex2D(_MainTex, float2(input.tex.xy));
}
ENDCG
}
}
}
EDIT: I tested a sort of similar shader in the docs(the one called “Chess”) and get the same type of errors:
It appears it doesnt understand texcoord0 in the “Chess” shader, which makes me think it doesnt understand TEXCOORD0 in the wiki shader. So, why is this?..
EDIT2: Did more testing. The problem is definately having to do with texture coordinates used in a struct, or possibly vertex positions. I tried just about all the shaders on the documentation, and none with texture coordinates work. If I use the “ChessOpt” shader, which has no texture coordinate structs, it works great, but the normal Chess shader, does not. I’m starting to think this might be a problem worth bringing to UT attention.