aboutsummaryrefslogtreecommitdiff
path: root/client/shaders/extract_bloom/opengl_fragment.glsl
blob: 45f5e9c6fdaf21d10bf265f4b24e7c8ef71cd952 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#define rendered texture0

struct ExposureParams {
	float compensationFactor;
};

uniform sampler2D rendered;
uniform mediump float bloomStrength;
uniform ExposureParams exposureParams;

#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif

varying float exposure;

void main(void)
{
	vec2 uv = varTexCoord.st;
	vec3 color = texture2D(rendered, uv).rgb;
	// translate to linear colorspace (approximate)
	color = pow(color, vec3(2.2));

	color *= pow(2., exposure) * exposureParams.compensationFactor * bloomStrength;
	gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
}