PlanetEditor/grk/planet-editor/shaders/shader_bloom_final.frag

25 lines
579 B
GLSL

#version 430 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D scene;
uniform sampler2D bloomBlur;
uniform bool bloom;
uniform float exposure;
void main()
{
const float gamma = 1.5;
vec3 hdrColor = texture(scene, TexCoords).rgb;
vec3 bloomColor = texture(bloomBlur, TexCoords).rgb;
if(bloom)
hdrColor += bloomColor; // additive blending
// tone mapping
vec3 result = vec3(1.0) - exp(-hdrColor * exposure);
// gamma correction
result = pow(result, vec3(1.0 / gamma));
FragColor = vec4(result, 1.0);
}