Vertex Fragment Shaders are BROKEN?

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! :frowning:

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.

Yes that’s the thing with those wiki shaders some of them don’t work because shaderlab is updating from time to time. I don’t know shader lang so good to be able to fix that, but it’s probably something with changed syntax.

No, I didn’t build, I don’t know why it says that.

However, I am finding that that wiki page with the code was edited, to include TEXCOORD0 in the vertexInput struct. So I think maybe Unity did upgrade or change something in Unity 4, and so Unity 3.5 does not support updated code or documentation to have TEXCOORD0 set up like that, for some reason. Can only use it in the Output struct(for 3.5). So need to keep an eye out and calculate the input/output by hand.