rhythmbullet/android/assets/shaders/combine.fsh

29 lines
673 B
Plaintext
Raw Normal View History

2017-09-03 08:29:33 +00:00
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D u_texture;
uniform sampler2D u_texture1;
uniform float exposure;
2018-09-04 01:39:26 +00:00
2017-09-03 08:29:33 +00:00
void main() {
vec3 origColor = texture2D(u_texture, vTexCoord).rgb;
vec3 blurredColor = texture2D(u_texture1, vTexCoord).rgb;
2018-09-04 01:39:26 +00:00
const float gamma = 2.2;
origColor += blurredColor; // additive blending
// tone mapping
vec3 result = vec3(1.0) - exp(-origColor * exposure);
// also gamma correct while we're at it
result = pow(result, vec3(1.0 / gamma));
gl_FragColor = vec4(result, 1.0);
2018-09-04 02:59:37 +00:00
2017-09-03 08:29:33 +00:00
}