Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

BLENDWEIGHTS and BLENDINDICES don't have effect in Google Pixel phone

Discussion in 'Shaders' started by jswn7561, Nov 13, 2020.

  1. jswn7561

    jswn7561

    Joined:
    Nov 27, 2018
    Posts:
    7
    I use BLENDWEIGHTS and BLENDINDICES in vertex Attributes, transform vertex position in vertex shader.
    It's ok in Editor, but no effect in phone.
    Code (CSharp):
    1. struct Attributes
    2. {
    3.     float4 positionOS    : POSITION;
    4.     float3 normalOS      : NORMAL;
    5.     float4 tangentOS     : TANGENT;
    6.     float2 texcoord      : TEXCOORD0;
    7.     float2 lightmapUV    : TEXCOORD1;
    8.     float4 weights       : BLENDWEIGHTS;
    9.     int4 indices        : BLENDINDICES;
    10.     UNITY_VERTEX_INPUT_INSTANCE_ID
    11. };
    12.  
    13. Varyings LitPassVertexSimple(Attributes input)
    14. {
    15.     Varyings output = (Varyings)0;
    16.  
    17.     UNITY_SETUP_INSTANCE_ID(input);
    18.     UNITY_TRANSFER_INSTANCE_ID(input, output);
    19.     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
    20.  
    21. #ifdef _SKIN
    22.     input.positionOS = mul(_Bones[input.indices[0]], input.positionOS) * input.weights[0] +
    23.         mul(_Bones[input.indices[1]], input.positionOS) * input.weights[1] +
    24.         mul(_Bones[input.indices[2]], input.positionOS) * input.weights[2] +
    25.         mul(_Bones[input.indices[3]], input.positionOS) * input.weights[3];
    26.  
    27.     input.normalOS = mul((float3x3)_Bones[input.indices[0]], input.normalOS) * input.weights[0] +
    28.         mul((float3x3)_Bones[input.indices[1]], input.normalOS) * input.weights[1] +
    29.         mul((float3x3)_Bones[input.indices[2]], input.normalOS) * input.weights[2] +
    30.         mul((float3x3)_Bones[input.indices[3]], input.normalOS) * input.weights[3];
    31.  
    32.     input.tangentOS = mul(_Bones[input.indices[0]], input.tangentOS) * input.weights[0] +
    33.         mul(_Bones[input.indices[1]], input.tangentOS) * input.weights[1] +
    34.         mul(_Bones[input.indices[2]], input.tangentOS) * input.weights[2] +
    35.         mul(_Bones[input.indices[3]], input.tangentOS) * input.weights[3];
    36. #endif
    37.  
    38.     VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
    39.     VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
    40.  
    41.     half3 viewDirWS = GetCameraPositionWS() - vertexInput.positionWS;
    42.     half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
    43.     half fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
    44.  
    45.     output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
    46.     output.posWS.xyz = vertexInput.positionWS;
    47.     output.positionCS = vertexInput.positionCS;
    48.  
    49. #ifdef _NORMALMAP
    50.     output.normal = half4(normalInput.normalWS, viewDirWS.x);
    51.     output.tangent = half4(normalInput.tangentWS, viewDirWS.y);
    52.     output.bitangent = half4(normalInput.bitangentWS, viewDirWS.z);
    53. #else
    54.     output.normal = NormalizeNormalPerVertex(normalInput.normalWS);
    55.     output.viewDir = viewDirWS;
    56. #endif
    57.  
    58.     OUTPUT_LIGHTMAP_UV(input.lightmapUV, unity_LightmapST, output.lightmapUV);
    59.     OUTPUT_SH(output.normal.xyz, output.vertexSH);
    60.  
    61.     output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
    62.  
    63. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
    64.     output.shadowCoord = GetShadowCoord(vertexInput);
    65. #endif
    66.  
    67.     return output;
    68. }
     
  2. jswn7561

    jswn7561

    Joined:
    Nov 27, 2018
    Posts:
    7