X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gamma_expansion_effect.cpp;h=95437906f4c63134232e7775ba630016b2b6748f;hp=5f9423f7c749081f965d57bbb8ba06901381ca08;hb=95edbfccb0843da3cc105dadc5bc6d8e102f6071;hpb=b912dbaa253ed1f091fd7201efd366c6f3154257 diff --git a/gamma_expansion_effect.cpp b/gamma_expansion_effect.cpp index 5f9423f..9543790 100644 --- a/gamma_expansion_effect.cpp +++ b/gamma_expansion_effect.cpp @@ -1,17 +1,20 @@ -#include #include #include "effect_util.h" #include "gamma_expansion_effect.h" #include "util.h" +using namespace std; + +namespace movit { + GammaExpansionEffect::GammaExpansionEffect() : source_curve(GAMMA_LINEAR) { register_int("source_curve", (int *)&source_curve); } -std::string GammaExpansionEffect::output_fragment_shader() +string GammaExpansionEffect::output_fragment_shader() { if (source_curve == GAMMA_LINEAR) { return read_file("identity.frag"); @@ -24,7 +27,7 @@ std::string GammaExpansionEffect::output_fragment_shader() assert(false); } -void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); @@ -37,7 +40,7 @@ void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const std::stri // However, pow() is relatively slow in GLSL, so we approximate this // part by a minimax polynomial, whose coefficients are precalculated // in Maple. (It is very hard to accurately model the curve as a whole - // using minimax polynomials; both Maple and Mathematically generally + // using minimax polynomials; both Maple and Mathematica generally // just error out if you ask them to optimize over 0..1 with a higher-degree // polynomial.) // @@ -74,6 +77,9 @@ void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const std::stri // maxerror = 0.000094 // error at beta = 0.000012 // error at 1.0 = 0.000012 + // + // Note that the worst _relative_ error by far is just at the beginning + // of the exponential curve, ie., just around β. set_uniform_float(glsl_program_num, prefix, "linear_scale", 1.0 / 12.92); set_uniform_float(glsl_program_num, prefix, "c0", 0.001324469581); set_uniform_float(glsl_program_num, prefix, "c1", 0.02227416690); @@ -117,3 +123,5 @@ void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const std::stri set_uniform_float(glsl_program_num, prefix, "beta", 0.0181 * 4.5); } } + +} // namespace movit