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
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.
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.