blob: 5e09f06f022865aa21aa3a3ea4f23436369f01a6 [file] [log] [blame]
#version 100
// Copyright Alastair F. Donaldson and Hugues Evrard, Imperial College London, 2017
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif
#endif
uniform vec2 injectionSwitch;
uniform vec2 resolution;
bool checkSwap(float a, float b)
{
return gl_FragCoord.y < resolution.y / 2.0 ? a > b : a < b;
}
void main()
{
float data[10];
for(
int i = 0;
i < 10;
i ++
)
{
data[i] = float(10 - i) * injectionSwitch.y;
}
for(
int i = 0;
i < 9;
i ++
)
{
for(
int j = 0;
j < 10;
j ++
)
{
if(j < i + 1)
{
continue;
}
bool doSwap = checkSwap(data[i], data[j]);
if(doSwap)
{
float temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
}
if(gl_FragCoord.x < resolution.x / 2.0)
{
gl_FragColor = vec4(data[0] / 10.0, data[5] / 10.0, data[9] / 10.0, 1.0);
}
else
{
gl_FragColor = vec4(data[5] / 10.0, data[9] / 10.0, data[0] / 10.0, 1.0);
}
}