Search Unity

OpenGL warning: trying to bind too many vertex attributes (got 18, max is 15

Discussion in 'Shaders' started by tmcthee, May 18, 2020.

  1. tmcthee

    tmcthee

    Joined:
    Mar 8, 2013
    Posts:
    119
    I'm getting this error when trying to build to iOS

    ”OpenGL warning: trying to bind too many vertex attributes (got 18, max is 15”

    Could this be a shader issue?

    I've found a couple of threads elsewhere that might indicate this is an issue with the unity version we're using. But we've been able to build with this version previously. The only difference is done new shaders I've been writing... :(
    https://forum.unity.com/threads/error-in-build-2019-2-7f2-with-shader-guitextureclip.755054/
    https://answers.unity.com/questions...attri.html?childToView=1676683#answer-1676683

    Thanks in advance
     
  2. Magdoca

    Magdoca

    Joined:
    Jun 3, 2019
    Posts:
    7
    It sounds like you just have too many attributes defined for your vertex struct in your shader. You can remove anything you don't need for the final result, and if you for some reason need all of that data, you can combine some pieces of data. A vertex attribute can have up to four values associated with it (float4). Each attribute you have for a vertex, even if it is just a single float value, will take up the space of four floats internally. Because of this, you can pack two or more values into one attribute and then use the individual parts of the float4 in your fragment shader as if they were separate. For example, if you had this:
    float a;
    float b;
    float c;
    float d;

    That would take up four attributes. You could combine them into one by declaring this:
    float4 a_b_c_d;

    And when you needed one of the components, you would access it with the x, y, z, w components respective to where the value is stored. If you wanted to extract or write to 'c' from the float4 above you would just use the z component:

    float extracted_c = a_b_c_d.z;
     
  3. tmcthee

    tmcthee

    Joined:
    Mar 8, 2013
    Posts:
    119
    Thanks,
    It seems like it was the version of unity we were using. We upgraded and the issue went away...