Hi, I’m new to both Cg and shaderlab, but I do have a little more experience in Cg. I have an extremely simple Cg shader that applies a texture to the active object, I know the Cg code works, but when I translate it into Unity I get a “Material doesn’t have a texture property ‘_MainTex’” and when I select the shader in the project pane, the shader shows a “No subshaders can run on this graphics card” warning, but I find that odd, after all I’m just applying a texture, so any ideas what I’m doing wrong? Here’s the code:
Shader “Custom/SimpleTexture”{
Properties {
_MainTex(“Fire”, 2D) = “white” {}
}
SubShader{
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include “UnityCG.cginc”
sampler2D _MainTex;
struct v2f
{
float4 position : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
struct a2v
{
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert(a2v In)
{
v2f OUT;
OUT.position = float4(In.vertex.xy, 0, 1);
OUT.texcoord = TRANSFORM_TEX(In.texcoord, _MainTex);
return OUT;
}
struct C3E3f_Output
{
float4 color : COLOR;
};
float4 frag( v2f In ): COLOR {
float4 color = tex2D(_MainTex, In.texcoord.xy);
return color;
}
ENDCG
}
}
}