/**
 * Full-screen textured quad shader
 */

const StarShader = {
  name: "StarShader",

  uniforms: {
    tDiffuse: { value: null },
    opacity: { value: 1.0 },
    red: { value: 1.0 },
    green: { value: 1.0 },
    blue: { value: 1.0 },
  },

  vertexShader: /* glsl */ `

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,

  fragmentShader: /* glsl */ `

		uniform float opacity;

		uniform sampler2D tDiffuse;
    uniform float red;
    uniform float green;
    uniform float blue;

		varying vec2 vUv;

		void main() {

			vec4 texel = texture2D( tDiffuse, vUv );
      vec4 original_color = opacity * texel;
      float brightness = (original_color.r + original_color.g + original_color.b) / 3.0;
      if (original_color.a > 0.0) {
        gl_FragColor.r = red * brightness;
        gl_FragColor.g = green * brightness;
        gl_FragColor.b = blue * brightness;
      }

      gl_FragColor.a = original_color.a;


		}`,
};

export { StarShader };
