#define MAX_ITER 5 attribute vec4 a_position; uniform int u_iter; uniform vec4 u_deltas[MAX_ITER]; int my_min(int a, int b) { if (a < b) { return a; } else { return b; } } void main() { gl_Position = a_position; for (int i = 0; i < my_min(u_iter, MAX_ITER); i++) { gl_Position += u_deltas[i]; } }