summaryrefslogtreecommitdiff
path: root/src/renderergl2/glsl/tonemap_fp.glsl
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2014-04-16 05:26:03 -0700
committerTim Angus <tim@ngus.net>2014-06-17 17:43:42 +0100
commiteadaba4913c24cfc8b96d813a3017c9081ad0dbd (patch)
treeddcf4fdf6ca4ccfa0f32a4874d6760acf2e7828c /src/renderergl2/glsl/tonemap_fp.glsl
parentd9ed6a7cf6f7091c8c7e44df93b9fa3e1f772643 (diff)
OpenGL2: Remove sRGB support, replace with gamma cvars.
Diffstat (limited to 'src/renderergl2/glsl/tonemap_fp.glsl')
-rw-r--r--src/renderergl2/glsl/tonemap_fp.glsl9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/renderergl2/glsl/tonemap_fp.glsl b/src/renderergl2/glsl/tonemap_fp.glsl
index 9b18de8a..4c914aca 100644
--- a/src/renderergl2/glsl/tonemap_fp.glsl
+++ b/src/renderergl2/glsl/tonemap_fp.glsl
@@ -32,6 +32,11 @@ vec3 FilmicTonemap(vec3 x)
void main()
{
vec4 color = texture2D(u_TextureMap, var_TexCoords) * u_Color;
+
+ #if defined(r_framebufferGamma)
+ color.rgb = pow(color.rgb, vec3(r_framebufferGamma));
+ #endif
+
vec3 minAvgMax = texture2D(u_LevelsMap, var_TexCoords).rgb;
vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x);
@@ -44,5 +49,9 @@ void main()
vec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x));
color.rgb = FilmicTonemap(color.rgb) * fWhite;
+ #if defined(r_tonemapGamma)
+ color.rgb = pow(color.rgb, vec3(1.0 / r_tonemapGamma));
+ #endif
+
gl_FragColor = clamp(color, 0.0, 1.0);
}