# Passing Custom Vertex Attributes to Vertex Shader

**URL:** <https://discourse.processing.org/t/passing-custom-vertex-attributes-to-vertex-shader/24342>\
**Category:** Coding Questions\
**Created:** [October 4, 2020, 9:01pm UTC](https://discourse.processing.org/t/passing-custom-vertex-attributes-to-vertex-shader/24342 "2020-10-04T21:01:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelnighttime](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@michaelnighttime](https://discourse.processing.org/u/michaelnighttime)\
**Post date:** [October 4, 2020, 9:01pm UTC](https://discourse.processing.org/t/passing-custom-vertex-attributes-to-vertex-shader/24342/1 "2020-10-04T21:01:19Z")

</div>

Trying to understand how to pass custom per-vertex Attributes along to be used in the shaders in processing 3, but seem to be missing something. In processing

```auto
  s = createShape();
  s.beginShape(POINTS);
    for(int i = 0; i< totPoints; i++){
          PVector r = new PVector(random(width),random(height));
          s.attrib("pointIndex" , float(i));
          s.vertex(r.x,r.y);
    }
   s.endShape();

```

Now I am trying to use the custom attribute “pointIndex” to (for instance, just to test) modify the vertex color.

```auto
uniform mat4 transformMatrix;

attribute vec4 position;
attribute vec4 color;
attribute float pointIndex;

varying vec4 vertColor;

void main() {
    gl_Position = transformMatrix * position;
    vec4 c = vec4(1.0,.1*pointIndex,1.,1.);
    vertColor = c;
}

```

But alas this does nothing. I have also tried attribColor() and I have tried looping over the vertices in a subsequent loop and using setAttrib() to assign them each directly, still no go.
