mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 09:02:38 +00:00
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
This commit is contained in:
parent
48015009b7
commit
15bb05d2fe
@ -1074,6 +1074,9 @@ Available video output drivers are:
|
||||
reinhard
|
||||
Reinhard tone mapping algorithm. Very simple continuous curve.
|
||||
Preserves dynamic range and peak but uses nonlinear contrast.
|
||||
hable
|
||||
Similar to ``reinhard`` but preserves dark contrast better (slightly
|
||||
sigmoidal). Developed by John Hable for use in video games.
|
||||
gamma
|
||||
Fits a logarithmic transfer between the tone curves.
|
||||
linear
|
||||
|
@ -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),
|
||||
|
@ -106,6 +106,7 @@ enum prescalers {
|
||||
enum tone_mapping {
|
||||
TONE_MAPPING_CLIP,
|
||||
TONE_MAPPING_REINHARD,
|
||||
TONE_MAPPING_HABLE,
|
||||
TONE_MAPPING_GAMMA,
|
||||
TONE_MAPPING_LINEAR,
|
||||
};
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user