Search Unity

Lose precision on IOS Metal.

Discussion in 'Shaders' started by zhutianlun810, Jan 9, 2020.

  1. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    172
    I tried to test a simple scene exported from Unity3D in my iPhone. However, I find that some float4 variables are automatically converted to half4.

    This is my shader code in Unity:
    Code (CSharp):
    1. struct VertexInput
    2. {
    3.     float4 vertex : POSITION;
    4.     half3 normal : NORMAL;
    5.     half4 tangent : TANGENT;
    6.     float2 uv0 : TEXCOORD0;
    7.     float2 uv1 : TEXCOORD1;
    8.  
    9. #if defined(USE_UV2)
    10.     float2 uv2 : TEXCOORD2;
    11. #endif
    12.  
    13. #if defined(USE_TREE_ANIMATION)
    14.     float4 uv2 : TEXCOORD2;
    15.     float4 uv3 : TEXCOORD3;
    16. #endif
    17.  
    18.  
    19. #if defined(USE_VERTEX_COLOR)
    20.     fixed4 vertexColor : COLOR;
    21. #endif
    22.  
    23.     UNITY_VERTEX_INPUT_INSTANCE_ID
    24. };
    And when I test my scene in XCode:

    Why does Metal convert my float4 type to half4?