1
0
Fork 0
fgdata/Shaders/HDR/bloom-threshold.frag

25 lines
552 B
GLSL
Raw Normal View History

2021-04-10 09:14:16 +00:00
#version 330 core
out vec3 fragColor;
in vec2 texCoord;
uniform sampler2D hdr_tex;
uniform sampler2D lum_tex;
uniform float bloom_threshold;
vec3 applyExposure(vec3 color, float avgLuminance, float threshold);
2021-04-10 09:14:16 +00:00
void main()
{
vec3 hdrColor = texture(hdr_tex, texCoord).rgb;
float avgLuminance = texelFetch(lum_tex, ivec2(0), 0).r;
2021-04-10 09:14:16 +00:00
vec3 exposedHdrColor = applyExposure(hdrColor, avgLuminance, bloom_threshold);
if (dot(exposedHdrColor, vec3(0.333)) <= 0.001)
2021-04-10 09:14:16 +00:00
fragColor = vec3(0.0);
else
fragColor = exposedHdrColor;
2021-04-10 09:14:16 +00:00
}