]> git.sesse.net Git - movit/blob - lift_gamma_gain_effect.cpp
Make the HSV pickers keep the same luminance no matter what the saturation is. Makes...
[movit] / lift_gamma_gain_effect.cpp
1 #include <math.h>
2
3 #include "lift_gamma_gain_effect.h"
4 #include "util.h"
5 #include "opengl.h"
6
7 LiftGammaGainEffect::LiftGammaGainEffect()
8         : lift(0.0f, 0.0f, 0.0f),
9           gamma(1.0f, 1.0f, 1.0f),
10           gain(1.0f, 1.0f, 1.0f)
11 {
12         register_vec3("lift", (float *)&lift);
13         register_vec3("gamma", (float *)&gamma);
14         register_vec3("gain", (float *)&gain);
15 }
16
17 std::string LiftGammaGainEffect::output_fragment_shader()
18 {
19         return read_file("lift_gamma_gain_effect.frag");
20 }
21
22 void LiftGammaGainEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num)
23 {
24         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
25
26         RGBTriplet gain_pow_inv_gamma(
27                 pow(gain.r, 1.0f / gamma.r),
28                 pow(gain.g, 1.0f / gamma.g),
29                 pow(gain.b, 1.0f / gamma.b));
30         set_uniform_vec3(glsl_program_num, prefix, "gain_pow_inv_gamma", (float *)&gain_pow_inv_gamma);
31
32         RGBTriplet inv_gamma_22(
33                 2.2f / gamma.r,
34                 2.2f / gamma.g,
35                 2.2f / gamma.b);
36         set_uniform_vec3(glsl_program_num, prefix, "inv_gamma_22", (float *)&inv_gamma_22);
37 }