private void copyVertexColor(int triIndex, int index, int colorIndex,
                               float[] contrib) {
    float[] triColor = triangleColors[triIndex][colorIndex];
    float[] v = vertices[index];

    triColor[TRI_DIFFUSE_R] =
      clamp(v[ER] + v[AR] * contrib[LIGHT_AMBIENT_R] + v[DR] * contrib[LIGHT_DIFFUSE_R]);
    triColor[TRI_DIFFUSE_G] =
      clamp(v[EG] + v[AG] * contrib[LIGHT_AMBIENT_G] + v[DG] * contrib[LIGHT_DIFFUSE_G]);
    triColor[TRI_DIFFUSE_B] =
      clamp(v[EB] + v[AB] * contrib[LIGHT_AMBIENT_B] + v[DB] * contrib[LIGHT_DIFFUSE_B]);
    triColor[TRI_DIFFUSE_A] = clamp(v[DA]);

    triColor[TRI_SPECULAR_R] = clamp(v[SPR] * contrib[LIGHT_SPECULAR_R]);
    triColor[TRI_SPECULAR_G] = clamp(v[SPG] * contrib[LIGHT_SPECULAR_G]);
    triColor[TRI_SPECULAR_B] = clamp(v[SPB] * contrib[LIGHT_SPECULAR_B]);
  }