uniform half4 colorGreen, colorRed; | |
float sumArray(float a[5]) { | |
float sum = 0; | |
for (int i = 0; i < 5; ++i) { | |
sum += a[i]; | |
} | |
return sum; | |
} | |
float sumArrayMutating(float a[5]) { | |
for (int i = 1; i < 5; ++i) { | |
a[0] += a[i]; | |
} | |
return a[0]; | |
} | |
half4 main(float2 coords) { | |
float data[5]; | |
data[0] = 1; | |
data[1] = 2; | |
data[2] = 3; | |
data[3] = 4; | |
data[4] = 5; | |
return sumArray(data) == sumArrayMutating(data) ? colorGreen : colorRed; | |
} |