mediump vec3 brightness3(mediump vec3 c, mediump float val)
{
   return clamp(c + vec3(val * 2.0 - 1.0), vec3(0), vec3(1));
}

mediump vec3 contrast3(mediump vec3 c, mediump float val)
{
   val = val * 2.0 - 1.0;
   mediump float factor = ((259.0 / 255.0) * (val + 1.0)) / (1.0 * ((259.0 / 255.0) - val));
   return clamp(factor * (c - 0.5) + 0.5, vec3(0), vec3(1));
}

mediump float brightness1(mediump float c, mediump float val)
{
   return clamp(c + (val * 2.0 - 1.0), 0.0, 1.0);
}

mediump float contrast1(mediump float c, mediump float val)
{
   val = val * 2.0 - 1.0;
   mediump float factor = ((259.0 / 255.0) * (val + 1.0)) / (1.0 * ((259.0 / 255.0) - val));
   return clamp(factor * (c - 0.5) + 0.5, 0.0, 1.0);
}
