// TODO - this module is a WIP

/* eslint-disable camelcase */
var INITIAL_STATE = {
  color_uOpacity: 1.0,
  color_uDesaturate: 0.0,
  color_uBrightness: 1.0
};

function getUniforms() {
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;

  var uniforms = {};
  if (opts.opacity) {
    uniforms.color_uOpacity = opts.opacity;
  }
  return uniforms;
}

var vs = 'varying vec4 color_vColor;\n\ncolor_setColor(vec4 color) {\n  color_vColor = color;\n}\n';

var fs = 'uniform float color_uOpacity;\nuniform float color_uDesaturate;\nuniform float color_uBrightness;\n\nvarying vec4 color_vColor;\n\nvec4 color_getColor() {\n  return color_vColor;\n}\n\nvec4 color_filterColor(vec4 color) {\n  // apply desaturation and brightness\n  if (color_uDesaturate > 0.01) {\n    float luminance = (color.r + color.g + color.b) * 0.333333333 + color_uBrightness;\n    color = vec4(mix(color.rgb, vec3(luminance), color_uDesaturate), color.a);\n\n  // Apply opacity\n  color = vec4(color.rgb, color.a * color_uOpacity);\n  return color;\n}\n';

export default {
  name: 'color',
  vs: vs,
  fs: fs,
  getUniforms: getUniforms
};
//# sourceMappingURL=color.js.map