I’m trying to retrofit an old, obsolete package from the forums, and am running into shader errors that I have no idea how to handle.
This is the original shader:
// Upgrade NOTE: replaced 'PositionFog()' with multiply of UNITY_MATRIX_MVP by position
// Upgrade NOTE: replaced 'V2F_POS_FOG' with 'float4 pos : SV_POSITION'
Shader "TestShader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0.5)
_MainTex ("Base (RGB)", 2D) = "grass" {}
_LightPower ("Light Power", Float) = 0.0
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#include "UnityCG.cginc"
float4 _Color;
sampler2D _MainTex;
float _LightPower;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 color : COLOR0;
//float4 lighting : TEXCOORD1;
};
struct indata
{
float4 vertex;
float3 normal;
float4 texcoord;
float4 color;
};
v2f vert(indata v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_UV(0);
o.color = v.color; //_Color; //v.normal * 0.5 + 0.5;
//o.lighting = v.color;
return o;
}
half4 frag(v2f i) : COLOR
{
return half4(i.color*tex2D(_MainTex, i.uv).rgb, 1);//*i.lighting;
}
ENDCG
//Material {
// Diffuse [_Color]
//}
//Lighting On
//SetTexture [_MainTex] {
// constantColor[_Color]
//}
}
}
}
This throws this error :
Shader error in 'TestShader': 'vert': input parameter 'v' missing semantics at line 38 (on d3d11)
I fixed this by changing the ‘indata’ struct to this:
struct indata
{
float4 vertex : POSITION;
//float3 normal;
//float4 texcoord;
float4 color : COLOR;
};
This reveals the following error:
Shader error in 'TestShader': invalid subscript 'texcoord' at line 42 (on d3d11)
I now know that this is due to the presence of the macro “TRANSFORM_UV”. I only know this because of this page, the only reference to what “TRANSFORM_UV” actually does that I could find.
Why can’t I find any documentation whatsoever concerning this? What does it do, and how do I fix this error?