diff options
Diffstat (limited to 'advanced_lighting/7.bloom/shaders/final.frag')
-rw-r--r-- | advanced_lighting/7.bloom/shaders/final.frag | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/advanced_lighting/7.bloom/shaders/final.frag b/advanced_lighting/7.bloom/shaders/final.frag new file mode 100644 index 0000000..fe9f5d7 --- /dev/null +++ b/advanced_lighting/7.bloom/shaders/final.frag @@ -0,0 +1,25 @@ +#version 330 core + +in VS_OUT { + vec2 tex_coords; +} vs_out; + +out vec4 frag_color; + +uniform sampler2D scene; +uniform sampler2D blur; +uniform bool bloom; +uniform float exposure; + +void main() +{ + const float gamma = 2.2; + vec3 scene_color = texture(scene, vs_out.tex_coords).rgb; + vec3 blur_color = texture(blur, vs_out.tex_coords).rgb; + if (bloom) { + scene_color += blur_color; + } + vec3 result = vec3(1.0) - exp(-scene_color * exposure); + result = pow(result, vec3(1.0 / gamma)); + frag_color = vec4(result, 1.0); +} |