title: Binding custom vertex attributes for use in shaders
body: <p>I am writing a shader that does different things depending on a specific value tied to the vertex. Below is the struct that stores my vertex information:</p>
  
  <pre><code>typedef struct
  {
      GLKVector3 position;
      GLKVector3 normal;
      GLKVector2 texCoords0;
      GLKVector4 originalColor;
      GLushort isEmissive;
      GLushort colorIndex;
  } Vertex;
  </code></pre>
  
  <p>The important variable is <code>isEmissive</code>. I want to process different lighting/color effects in my fragment shader depending on this variable - it's essentially a BOOL (1 or 0). Since it's tied to my vertex information, I thought I could set an <code>attribute</code> property in my vertex shader but that doesn't seem to be the case. Is there a way to add/bind custom attributes for my vertex information to the vertex shader? All of the attributes I use in my vertex shader right now are standard - GLKVertexAttribPosition, GLKVertexAttribNormal, GLKVertexAttribColor, GLKVertexAttribTexCoord0 - or use NS_ENUMs from GLKit. Is there something I need to do to bind my own attributes to use in the vertex shader? I've tried binding <code>isEmissive</code> but it's always 0 in my shader. I want it to reflect the value when the vertex is created. I feel like I need to bind this data to the buffer so the vertex information on the GPU has access to this data. </p>
  
  <p>UPDATE - I added the code below per the comment below. I setup the pointer into the vertex array object specifying where the data is I need. It's a single float value - 0 or 1.</p>
  
  <pre><code>    // emissive bool
      glEnableVertexAttribArray(ATTRIB_EMISSIVE);
      glVertexAttribPointer(ATTRIB_EMISSIVE, 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLbyte *)NULL + offsetof(Vertex, isEmissive));
  </code></pre>
  
  <p>Then in my shader program I added the following to bind the attribute:</p>
  
  <pre><code>    glBindAttribLocation(_program, ATTRIB_EMISSIVE, "isEmissive");
  </code></pre>
  
  <p>Finally, as a test to see if the value works I have the following in my shader:</p>
  
  <pre><code>// calculate new color based on time
  if (isEmissive &gt; 0.5) {
      colorVarying = vec4(0, 1, 0, 1);
  } else {
      colorVarying = vec4(1, 0, 0, 1);
  }
  </code></pre>
  
  <p>isEmissive is always 0. I've explicitly set it to 1 to verify that I'm not actually getting the right value. Is there an additional step I'm missing?</p>