Search Unity

Question [SOLVED] RectMask2D not works with my shader! Why?

Discussion in 'Shaders' started by IEdge, Dec 6, 2020.

  1. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    This is the vertex and fragment of my shader, what I doing wrong?

    Code (CSharp):
    1. v2f vert(appdata_t v)
    2. {
    3.     v2f OUT;
    4.     UNITY_SETUP_INSTANCE_ID(v);
    5.     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
    6.     OUT.worldPosition = v.vertex;
    7.     OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
    8.  
    9.     // Calculate the frame index over time
    10.     uint index = _FrameCount > 0 ? ((int)(_Time.y / (1 / _Fps)) % _FrameCount) : 0;
    11.  
    12.     // Set the frame
    13.     OUT.texcoord = v.texcoord * _Scale + _Frames[index];
    14.  
    15.     OUT.color = v.color * _Color;
    16.     return OUT;
    17. }
    18.  
    19. fixed4 frag(v2f IN) : SV_Target
    20. {
    21.     half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
    22.  
    23.     #ifdef UNITY_UI_CLIP_RECT
    24.     color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
    25.     #endif
    26.  
    27.     #ifdef UNITY_UI_ALPHACLIP
    28.     clip (color.a - 0.001);
    29.     #endif
    30.  
    31.     return color;
    32. }
     
  2. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    Update: Solved by adding built-in source (2020.1.15) to my shader.