I’m trying to include a texture’s Tiling and Offset values in my shader, and understand that the TRANSFORM_TEX macro must be used for that to work. Following this guide, I wrote a shader.
Shader "Custom/Displacement Ramp Debug"
{
Properties
{
_DispTex ("Displacement Texture", 2D) = "gray" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
Cull Off
LOD 300
CGPROGRAM
#pragma surface surf Lambert vertex:disp nolightmap
#pragma target 3.0
#pragma glsl
#include "UnityCG.cginc"
sampler2D _DispTex;
uniform float4 _DispTex_ST; // Needed for TRANSFORM_TEX(v.texcoord, _DispTex)
struct Input
{
float2 uv_DispTex;
};
void disp (inout appdata_full v)
{
float2 newUV = TRANSFORM_TEX(v.texcoord.xy, _DispTex);
v.vertex.xyz += newUV.x;
}
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = tex2D(_DispTex, IN.uv_DispTex);
o.Albedo = c.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
When compiling, I get this error on a non-existent line:
Shader error in 'Custom/Displacement Ramp Debug': declaration of "_DispTex_ST" conflicts with previous declaration at (21) at line 62
But if I try to remove _DispTex_ST, I get this error:
Shader error in 'Custom/Displacement Ramp Debug': undefined variable "_DispTex_ST" undefined variable "_DispTex_ST" at line 30
Any ideas on why this is happening?