Remove some unneeded conversions from ResampleEffect. Speeds up texture generation...
[movit] / lift_gamma_gain_effect.cpp
1 #include <epoxy/gl.h>
2 #include <math.h>
3
4 #include "effect_util.h"
5 #include "lift_gamma_gain_effect.h"
6 #include "util.h"
7
8 using namespace std;
9
10 namespace movit {
11
12 LiftGammaGainEffect::LiftGammaGainEffect()
13         : lift(0.0f, 0.0f, 0.0f),
14           gamma(1.0f, 1.0f, 1.0f),
15           gain(1.0f, 1.0f, 1.0f)
16 {
17         register_vec3("lift", (float *)&lift);
18         register_vec3("gamma", (float *)&gamma);
19         register_vec3("gain", (float *)&gain);
20         register_uniform_vec3("gain_pow_inv_gamma", (float *)&uniform_gain_pow_inv_gamma);
21         register_uniform_vec3("inv_gamma_22", (float *)&uniform_inv_gamma22);
22 }
23
24 string LiftGammaGainEffect::output_fragment_shader()
25 {
26         return read_file("lift_gamma_gain_effect.frag");
27 }
28
29 void LiftGammaGainEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
30 {
31         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
32
33         uniform_gain_pow_inv_gamma = RGBTriplet(
34                 pow(gain.r, 1.0f / gamma.r),
35                 pow(gain.g, 1.0f / gamma.g),
36                 pow(gain.b, 1.0f / gamma.b));
37
38         uniform_inv_gamma22 = RGBTriplet(
39                 2.2f / gamma.r,
40                 2.2f / gamma.g,
41                 2.2f / gamma.b);
42 }
43
44 }  // namespace movit