Thank you it worked. For anyone having the same problem here’s the solution written out.
Vertex shader
flat varying int iid;
void main(void) {
...
iid = gl_InstanceID;
}
Fragment
flat varying int iid;
void main(void) {
float(iid); // instance index as float
}