Search Unity

Vertex shader question

Discussion in 'Shaders' started by UnityLighting, May 7, 2017.

  1. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,876
    Hi

    I found this vert function to simulate billboard facing to camera . It works fine in editor and pc but in Android build doesn't works and fallbacked to diffuse:

    What is non supported feature in this code for android device ?

    Code (CSharp):
    1.     void vert (inout appdata_full v, out Input o)
    2.     {
    3.  
    4.          UNITY_INITIALIZE_OUTPUT(Input, o);
    5.         float3 forward = -normalize(UNITY_MATRIX_V._m20_m21_m22);
    6.         float3 up = float3(0, 1, 0); //normalize(UNITY_MATRIX_V._m10_m11_m12);
    7.         float3 right = normalize(UNITY_MATRIX_V._m00_m01_m02);
    8.      
    9.         // rotate to face camera
    10.         float4x4 rotationMatrix = float4x4(right,   0,
    11.                                            up,      0,
    12.                                            forward, 0,
    13.                                            0, 0, 0, 1);
    14.      
    15.         //float offset = _Object2World._m22 / 2;
    16.         float offset = 0;
    17.         v.vertex = mul(v.vertex + float4(0, offset, 0, 0), rotationMatrix) + float4(0, -offset, 0, 0);
    18.         v.normal = mul(v.normal, rotationMatrix);
    19.  
    20.     }
     
    Deleted User likes this.
  2. tom_bb

    tom_bb

    Joined:
    Sep 21, 2016
    Posts:
    8
    Have you tried switching the project to android and reimporting the shader? I sometimes find that shows up some errors, also the build logs of the android build might show errors related to the shader.
     
    UnityLighting likes this.
  3. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,876

    yes thank you.

    Now i got this error:
    in this line of the code :

    59:
    v.normal = mul(v.normal, rotationMatrix);
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    v.normal = mul(v.normal, (float3x3)rotationMatrix);
     
    UnityLighting and Deleted User like this.