Синтаксис:
Используется glsl
Shader "Learning/1" {
Properties {
_MainTex ("_mainTex", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float3 color : COLOR0;
float dotValue: COLOR1;
float2 uv : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.color = v.normal * 0.5 + 0.5;
o.dotValue=dot(float3(0,0,-1),v.vertex);
o.uv= TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv);//(float3(abs(i.dotValue), 0,0), abs(i.dotValue));
}
ENDCG
}
}
Fallback "VertexLit"
}
Properties {
_MainTex ("_mainTex", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float3 color : COLOR0;
float dotValue: COLOR1;
float2 uv : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.color = v.normal * 0.5 + 0.5;
o.dotValue=dot(float3(0,0,-1),v.vertex);
o.uv= TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv);//(float3(abs(i.dotValue), 0,0), abs(i.dotValue));
}
ENDCG
}
}
Fallback "VertexLit"
}
Ругается на строку
Синтаксис:
Используется glsl
o.uv= TRANSFORM_TEX(v.texcoord, _MainTex);
говорит, мол
Shader error in 'Learning/1': undeclared identifier '_MainTex_ST' at line 31 (on d3d11)
Compiling Vertex program
Почему так? Как починить?