4 #include "gamma_expansion_effect.h"
7 GammaExpansionEffect::GammaExpansionEffect()
8 : source_curve(GAMMA_LINEAR)
10 register_int("source_curve", (int *)&source_curve);
11 memset(expansion_curve, 0, sizeof(expansion_curve));
12 register_1d_texture("expansion_curve_tex", expansion_curve, EXPANSION_CURVE_SIZE);
15 std::string GammaExpansionEffect::output_fragment_shader()
17 if (source_curve == GAMMA_LINEAR) {
18 return read_file("identity.frag");
20 if (source_curve == GAMMA_sRGB) {
21 for (unsigned i = 0; i < EXPANSION_CURVE_SIZE; ++i) {
22 float x = i / (float)(EXPANSION_CURVE_SIZE - 1);
24 expansion_curve[i] = (1.0/12.92f) * x;
26 expansion_curve[i] = pow((x + 0.055) * (1.0/1.055f), 2.4);
29 invalidate_1d_texture("expansion_curve_tex");
30 return read_file("gamma_expansion_effect.frag");
32 if (source_curve == GAMMA_REC_709) { // And Rec. 601.
33 for (unsigned i = 0; i < EXPANSION_CURVE_SIZE; ++i) {
34 float x = i / (float)(EXPANSION_CURVE_SIZE - 1);
36 expansion_curve[i] = (1.0/4.5f) * x;
38 expansion_curve[i] = pow((x + 0.099) * (1.0/1.099f), 1.0f/0.45f);
41 invalidate_1d_texture("expansion_curve_tex");
42 return read_file("gamma_expansion_effect.frag");