_bloomThreshold.vsh
{
	include generic_vertex.vsh
}

_bloomThreshold.fsh
{
	uniform sampler2DRect	u_ScreenBuffer;
	uniform	float		u_BloomThreshold;
	out	vec3	fragData;
	void main(void)
	{
		vec3 c = texture(u_ScreenBuffer, gl_FragCoord.xy).rgb;
		float lum = dot(vec3(0.2125, 0.7154, 0.0721), c);
 		if (lum > u_BloomThreshold)
			fragData = c;
		else
			fragData = vec3(0.0);
	}
}


_bloomStarBlur.vsh
{
	include generic_vertex.vsh
}

_bloomStarBlur.fsh
{
	uniform sampler2DRect	u_BloomBuffer;
	uniform float		u_bloomWidth;
	uniform	vec3		u_chromOffsGaussFact0;
	uniform	vec3		u_chromOffsGaussFact1;
	uniform	vec3		u_chromOffsGaussFact2;
	uniform	vec3		u_chromOffsGaussFact3;
	uniform	vec3		u_chromOffsGaussFact4;
	uniform	vec3		u_chromOffsGaussFact5;
	uniform	vec3		u_chromOffsGaussFact6;
	uniform	vec3		u_chromOffsGaussFact7;

	out	vec3	fragData;
	void main(void)
	{
		vec2 tc, dx, dx2, sdx, sdx2;
		vec3 sColor;

		tc = gl_FragCoord.xy;
		float bloomWidth = clamp(u_bloomWidth, 1.0, 5.0);
		sdx = dx = vec2(bloomWidth);
		sdx2 = dx2 = vec2(-bloomWidth, bloomWidth);

		sColor = texture(u_BloomBuffer, tc).rgb * u_chromOffsGaussFact0;

		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact1;	sdx += dx;
		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact2;	sdx += dx;
		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact3;	sdx += dx;
		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact4;	sdx += dx;
		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact5;	sdx += dx;
		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact6;	sdx += dx;
		sColor += (texture(u_BloomBuffer, tc+sdx).rgb + texture(u_BloomBuffer, tc-sdx).rgb) * u_chromOffsGaussFact7;
		
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact1;	sdx2 += dx2;
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact2;	sdx2 += dx2;
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact3;	sdx2 += dx2;
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact4;	sdx2 += dx2;
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact5;	sdx2 += dx2;
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact6;	sdx2 += dx2;
		sColor += (texture(u_BloomBuffer, tc+sdx2).rgb + texture(u_BloomBuffer, tc-sdx2).rgb) * u_chromOffsGaussFact7;

		fragData = sColor;
	}
}


_bloomBlurX.vsh
{
	include generic_vertex.vsh
}

_bloomBlurX.fsh
{
	uniform sampler2DRect	u_BloomBuffer;
	out	vec3	fragData;
	void main(void)
	{
		const	float m0 = 0.1562500;
		const	float m1 = 0.1367188;
		const	float m2 = 0.1171875;
		const	float m3 = 0.0820313;
		const	float m4 = 0.0468750;
		const	float m5 = 0.0298438;
		const	float m6 = 0.0078125;
		const	float delta = 1.0;
		vec3 c;
		vec2 tc = gl_FragCoord.xy + vec2(-6.0, 0.0);
		c  = m6 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m5 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m4 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m3 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m2 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m1 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m0 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m1 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m2 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m3 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m4 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m5 * texture(u_BloomBuffer, tc).rgb;	tc.x += delta;
		c += m6 * texture(u_BloomBuffer, tc).rgb;
		fragData = c;
	}
}


_bloomBlurY.vsh
{
	include generic_vertex.vsh
}

_bloomBlurY.fsh
{
	uniform sampler2DRect	u_BloomBuffer;
	out	vec3	fragData;
	void main(void)
	{
		const	float m0 = 0.1562500;
		const	float m1 = 0.1367188;
		const	float m2 = 0.1171875;
		const	float m3 = 0.0820313;
		const	float m4 = 0.0468750;
		const	float m5 = 0.0298438;
		const	float m6 = 0.0078125;
		const	float delta = 1.0;
		vec3 c;
		vec2 tc = gl_FragCoord.xy + vec2(0.0, -6.0);
		c  = m6 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m5 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m4 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m3 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m2 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m1 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m0 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m1 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m2 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m3 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m4 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m5 * texture(u_BloomBuffer, tc).rgb;	tc.y += delta;
		c += m6 * texture(u_BloomBuffer, tc).rgb;
		fragData = c;
	}
}


_bloomFinal.vsh
{
	include generic_vertex.vsh
}

_bloomFinal.fsh
{
	uniform sampler2DRect	u_BloomBuffer;
	uniform	float		u_BloomIntensity;
	out	vec3	fragData;
	void main(void)
	{
		fragData = texture(u_BloomBuffer, gl_FragCoord.xy * (1.0/8.0)).rgb * u_BloomIntensity;	//	1 / BLOOM_DOWNSCALE
	}
}
