f00da879dce630d6d2f0e95d176da455ce9fbbbd
[movit] / lift_gamma_gain_effect.cpp
1 #include <GL/glew.h>
2 #include <math.h>
3
4 #include "effect_util.h"
5 #include "lift_gamma_gain_effect.h"
6 #include "util.h"
7
8 LiftGammaGainEffect::LiftGammaGainEffect()
9         : lift(0.0f, 0.0f, 0.0f),
10           gamma(1.0f, 1.0f, 1.0f),
11           gain(1.0f, 1.0f, 1.0f)
12 {
13         register_vec3("lift", (float *)&lift);
14         register_vec3("gamma", (float *)&gamma);
15         register_vec3("gain", (float *)&gain);
16 }
17
18 std::string LiftGammaGainEffect::output_fragment_shader()
19 {
20         return read_file("lift_gamma_gain_effect.frag");
21 }
22
23 void LiftGammaGainEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num)
24 {
25         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
26
27         RGBTriplet gain_pow_inv_gamma(
28                 pow(gain.r, 1.0f / gamma.r),
29                 pow(gain.g, 1.0f / gamma.g),
30                 pow(gain.b, 1.0f / gamma.b));
31         set_uniform_vec3(glsl_program_num, prefix, "gain_pow_inv_gamma", (float *)&gain_pow_inv_gamma);
32
33         RGBTriplet inv_gamma_22(
34                 2.2f / gamma.r,
35                 2.2f / gamma.g,
36                 2.2f / gamma.b);
37         set_uniform_vec3(glsl_program_num, prefix, "inv_gamma_22", (float *)&inv_gamma_22);
38 }