Hello! So I just started messing with shaders, and I’m trying to follow a tutorial. In the tutorial, inside the vert() function we used
o.pos = mul(UNITY_MATRIX_MVP, i.pos)
That was fine, but it seems like Unity automatically converts this line to
o.pos = UnityObjectToClipPos(i.pos);
OK… that’s great, but now this line gives my shader a compile error:
Shader error in 'Custom/Elasticity': 'UnityObjectToClipPos': ambiguous function call at line 27 (on d3d11)
So not only is Unity changing my code to something I didn’t ask for, but now it just doesn’t compile. Anyone know what I can do? Below is the full code from the tutorial I was following:
Shader "Custom/MyShader"
{
Properties
{
}
SubShader
{
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct VertInput {
float pos : POSITION;
};
struct VertOutput {
float4 pos : SV_POSITION;
half3 color : COLOR;
};
VertOutput vert(VertInput i) {
VertOutput o;
o.pos = UnityObjectToClipPos(i.pos);
o.color = i.pos.xyz;
return o;
}
half4 frag(VertOutput i) : COLOR {
return half4(o.color, 1.0f);
}
ENDCG
}
}
FallBack "Diffuse"
}
Thanks!