aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out
diff options
context:
space:
mode:
authorGravatar Niklas Haas <git@nand.wakku.to>2016-05-30 12:48:01 +0200
committerGravatar wm4 <wm4@nowhere>2016-05-30 16:58:25 +0200
commit15bb05d2fe7394478144d323a41023722d1a9d38 (patch)
tree0d5f2e57a53cb3856ae0ede262b45124db8ce326 /video/out
parent48015009b7f8073de1a81cf9624c104f071496bc (diff)
vo_opengl: add hable tone-mapping algorithm
Developed by John Hable for use in Uncharted 2. Also used by Frictional Games in SOMA. Originally inspired by a filmic tone mapping algorithm created by Kodak. From http://frictionalgames.blogspot.de/2012/09/tech-feature-hdr-lightning.html
Diffstat (limited to 'video/out')
-rw-r--r--video/out/opengl/video.c1
-rw-r--r--video/out/opengl/video.h1
-rw-r--r--video/out/opengl/video_shaders.c11
3 files changed, 13 insertions, 0 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 7bfcf17e2a..380e768126 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -385,6 +385,7 @@ const struct m_sub_options gl_video_conf = {
OPT_CHOICE("hdr-tone-mapping", hdr_tone_mapping, 0,
({"clip", TONE_MAPPING_CLIP},
{"reinhard", TONE_MAPPING_REINHARD},
+ {"hable", TONE_MAPPING_HABLE},
{"gamma", TONE_MAPPING_GAMMA},
{"linear", TONE_MAPPING_LINEAR})),
OPT_FLOAT("tone-mapping-param", tone_mapping_param, 0),
diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h
index 5b837ca3ad..a4a9fb703b 100644
--- a/video/out/opengl/video.h
+++ b/video/out/opengl/video.h
@@ -106,6 +106,7 @@ enum prescalers {
enum tone_mapping {
TONE_MAPPING_CLIP,
TONE_MAPPING_REINHARD,
+ TONE_MAPPING_HABLE,
TONE_MAPPING_GAMMA,
TONE_MAPPING_LINEAR,
};
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index 911bf377c7..d940c415e8 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -335,6 +335,17 @@ void pass_tone_map(struct gl_shader_cache *sc, float peak_src, float peak_dst,
break;
}
+ case TONE_MAPPING_HABLE: {
+ float A = 0.15, B = 0.50, C = 0.10, D = 0.20, E = 0.02, F = 0.30;
+ GLSLHF("vec3 hable(vec3 x) {\n");
+ GLSLHF("return ((x * (%f*x + %f)+%f)/(x * (%f*x + %f) + %f)) - %f;\n",
+ A, C*B, D*E, A, B, D*F, E/F);
+ GLSLHF("}\n");
+
+ GLSLF("color.rgb = hable(color.rgb) / hable(vec3(%f));\n", scale);
+ break;
+ }
+
case TONE_MAPPING_GAMMA: {
float gamma = isnan(param) ? 1.8 : param;
GLSLF("color.rgb = pow(color.rgb / vec3(%f), vec3(%f));\n",