
uniform sampler2D texGlow;
uniform sampler2D texNoise;

uniform highp vec2 noiseTexCoordScale;

vec4 getGlowData(vec3 colorRaw, out vec3 lightMul)
{
    vec4 glowShadow = texture2D(texGlow, varyTexCoord);
	vec3 c1 = (glowShadow.rgb);
	
	//if(fract(c1.r * 10.0) < 0.1 && fract(c1.r * 10.0) > 0.05)
	//	c1 = vec3(1.0, 0.5, 0.5);

	vec3 noise = texture2D(texNoise, varyTexCoord * noiseTexCoordScale).rgb;
	
	const float noiseStr = 0.05; // this is tuned to remove most of the color banding on Nexus7 and on A50, and not introduce too much grain at the same time.
	c1 = max(c1 - noise * noiseStr, 0.0);
	c1 *= 1.0 / (1.0 - noiseStr); // scale the values back to 0-1, so that the glow can saturate at whites

	lightMul = vec3(1.0);
	return vec4(c1, 1.0);
}
