Fixed bloom. Improved performance.

This commit is contained in:
Jonathas Costa
2019-06-27 22:00:19 -04:00
parent 6b5ce52173
commit f3e972790b
7 changed files with 93 additions and 39 deletions

View File

@@ -30,21 +30,24 @@ layout(location = 1) out vec4 gPosition;
layout(location = 2) out vec4 gNormal;
layout(location = 3) out vec4 filterBuffer;
uniform bool automaticBloom;
uniform float bloom_thresh_min;
uniform float bloom_thresh_max;
void main() {
Fragment f = getFragment();
_out_color_ = f.color;
gPosition = f.gPosition;
gNormal = f.gNormal;
bool automaticBloom = false;
if (automaticBloom) {
// Extract luminance
float Y = dot(f.color.rgb, vec3(0.299, 0.587, 0.144));
// Apply Bloom on the bloom threshold range values
//vec4 bColor = f.color * 4.0 * smoothstep(bloom_thresh_min, bloom_thresh_max, Y);
//filterBuffer = bColor
filterBuffer = vec4(f.filterFlag);
vec3 bColor = f.color.rgb * 4.0 * smoothstep(bloom_thresh_min, bloom_thresh_max, Y);
filterBuffer = vec4(bColor, f.color.a);
} else {
if (f.filterFlag == 1)
filterBuffer = f.color;