Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

UnityObjectToClipPos : ambiguous function call

Discussion in 'Shaders' started by pjlloyd100_unity, Oct 15, 2019.

  1. pjlloyd100_unity

    pjlloyd100_unity

    Joined:
    Oct 15, 2019
    Posts:
    1
    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

    Code (CSharp):
    1. o.pos = mul(UNITY_MATRIX_MVP, i.pos)
    That was fine, but it seems like Unity automatically converts this line to

    Code (CSharp):
    1. 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:

    Code (CSharp):
    1. Shader "Custom/MyShader"
    2. {
    3.     Properties
    4.     {
    5.     }
    6.     SubShader
    7.     {
    8.         Pass {
    9.             CGPROGRAM
    10.  
    11.             #pragma vertex vert
    12.             #pragma fragment frag
    13.  
    14.             struct VertInput {
    15.                 float pos : POSITION;
    16.             };
    17.  
    18.             struct VertOutput {
    19.                 float4 pos : SV_POSITION;
    20.                 half3 color : COLOR;
    21.             };
    22.  
    23.             VertOutput vert(VertInput i) {
    24.                 VertOutput o;
    25.              
    26.                 o.pos = UnityObjectToClipPos(i.pos);
    27.                 o.color = i.pos.xyz;
    28.  
    29.                 return o;
    30.             }
    31.  
    32.             half4 frag(VertOutput i) : COLOR {
    33.                 return half4(o.color, 1.0f);
    34.             }
    35.  
    36.             ENDCG
    37.         }
    38.     }
    39.     FallBack "Diffuse"
    40. }
    41.  

    Thanks!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,640
    Code (csharp):
    1. struct VertInput {
    2.      float pos : POSITION;
    3. };
    The vertex position is a float4