decent bloom system

This commit is contained in:
2018-09-03 23:54:23 -05:00
parent 3c3d925e5a
commit 24dcabfb51
6 changed files with 25 additions and 93 deletions

View File

@@ -14,8 +14,8 @@ void main() {
vec4 color = texture(u_texture, vTexCoord);
float brightness = (color.r*0.2126) + (color.g*0.7152) + (color.b * 0.0722);
if (brightness > 0.7) {
gl_FragColor = color;
if (brightness > 0.6) {
gl_FragColor = color *0.75;
} else {
gl_FragColor = vec4(0.0);
}

View File

@@ -11,18 +11,17 @@ varying vec2 vTexCoord;
uniform sampler2D u_texture;
uniform sampler2D u_texture1;
uniform float exposure;
void main() {
vec3 origColor = texture2D(u_texture, vTexCoord).rgb;
vec3 blurredColor = texture2D(u_texture1, vTexCoord).rgb;
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);
vec4 origColor = texture2D(u_texture, vTexCoord);
vec4 blurredColor = texture2D(u_texture1, vTexCoord);
vec4 result;
result = origColor + blurredColor;
result.a = vColor.a;
result.rgb *= vColor.rgb;
gl_FragColor = result;
}