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

25 lines
579 B
GLSL
Raw Normal View History

#version 430 core
2024-02-04 22:00:38 +01:00
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D scene;
uniform sampler2D bloomBlur;
uniform bool bloom;
uniform float exposure;
void main()
{
2024-02-07 20:16:03 +01:00
const float gamma = 1.5;
2024-02-04 22:00:38 +01:00
vec3 hdrColor = texture(scene, TexCoords).rgb;
vec3 bloomColor = texture(bloomBlur, TexCoords).rgb;
if(bloom)
hdrColor += bloomColor; // additive blending
2024-02-08 11:11:26 +01:00
2024-02-04 22:00:38 +01:00
// tone mapping
vec3 result = vec3(1.0) - exp(-hdrColor * exposure);
2024-02-08 11:11:26 +01:00
// gamma correction
2024-02-04 22:00:38 +01:00
result = pow(result, vec3(1.0 / gamma));
FragColor = vec4(result, 1.0);
}