Hi all,
I’m stumbling onto a very simple problem. For some reason, I can’t get tex2Dproj to work properly in a simple shader, although I did use the recommended UNITY_PROJ_COORD helper
The shader I am trying this with simply transforms the vertices and is supposed to texture the object using its mesh’s UVs, but WITHOUT perspective correction.
No matter what I do, I still get the same perspective corrected mapping with my shader as with the default diffuse shader. I’m probably overlooking some thing stupid, so if anyone cares to have a quick look at that shader code, thanks very much:
Shader "Custom/projective" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
Pass {
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct appdata {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
};
struct v2f {
float4 pos : SV_POSITION;
float4 uv : TEXCOORD0;
};
v2f vert (appdata v)
{
v2f o;
// Transform the input points.
o.pos = mul( UNITY_MATRIX_MVP,v.vertex);
o.uv = float4(v.texcoord.x,v.texcoord.y,0f,1f);
return o;
}
half4 frag( v2f i ) : COLOR {
half4 c = tex2Dproj(_MainTex, UNITY_PROJ_COORD(i.uv));
return c;
}
ENDCG
}
}
FallBack "Diffuse"
}
Thanks for any help